peachsim 0.1.745 → 0.1.747
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/cloud-client.ts +28 -12
- package/cli/commands/install-desktop.ts +0 -25
- package/cli/drivers/playwright-sim-host.ts +2 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +98 -10
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +158 -17
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +4 -4
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +159 -18
- package/dist-lib/swift-compile.cjs +58 -6
- package/dist-lib/swift-compile.mjs +57 -6
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +384 -10
- package/dist-lib/vite.cjs +4 -4
- package/package.json +1 -1
- package/src/desktop-host-delivery.ts +23 -0
- package/src/swift-compile.ts +76 -8
- package/src/swift-host.ts +23 -3
- package/src/vite-plugin-one.ts +2 -2
- package/src/vite-plugin.ts +10 -1
- package/src/xcode-project.ts +86 -1
package/src/swift-compile.ts
CHANGED
|
@@ -38,7 +38,10 @@ const WASM_TRIPLE = 'wasm32-unknown-wasip1'
|
|
|
38
38
|
// binaryen's own cap holds it to 4 threads (400%, 26 -> 32 s); swiftpm's jobs
|
|
39
39
|
// take half the cores, as the fixture build does.
|
|
40
40
|
const cores = os.availableParallelism()
|
|
41
|
-
const BUILD_ENV = {
|
|
41
|
+
const BUILD_ENV = {
|
|
42
|
+
...process.env,
|
|
43
|
+
BINARYEN_CORES: String(Math.min(4, cores)),
|
|
44
|
+
}
|
|
42
45
|
const BUILD_JOBS = String(Math.max(1, Math.floor(cores / 2)))
|
|
43
46
|
|
|
44
47
|
export interface SwiftCompileInput {
|
|
@@ -121,7 +124,9 @@ export function swiftModuleInputFiles(root: string): string[] {
|
|
|
121
124
|
'toolchain.json',
|
|
122
125
|
]
|
|
123
126
|
const walk = (dir: string) => {
|
|
124
|
-
for (const entry of readdirSync(path.join(root, dir), {
|
|
127
|
+
for (const entry of readdirSync(path.join(root, dir), {
|
|
128
|
+
withFileTypes: true,
|
|
129
|
+
})) {
|
|
125
130
|
const relative = `${dir}/${entry.name}`
|
|
126
131
|
if (entry.isDirectory()) walk(relative)
|
|
127
132
|
else if (/\.(swift|c|cpp|h)$/.test(entry.name)) files.push(relative)
|
|
@@ -1294,9 +1299,16 @@ export function swiftSourceAsIOS(
|
|
|
1294
1299
|
const reusableBodies: number[] = []
|
|
1295
1300
|
let depth = 0
|
|
1296
1301
|
let opensReusableBody = false
|
|
1302
|
+
const sceneLifecycleBodies = new Set<number>()
|
|
1297
1303
|
for (const at of tokens) {
|
|
1298
1304
|
const rest = conditioned.slice(at, at + 400)
|
|
1299
1305
|
if (rest.startsWith('{')) {
|
|
1306
|
+
if (sceneLifecycleBodies.has(at)) {
|
|
1307
|
+
out +=
|
|
1308
|
+
conditioned.slice(copied, at + 1) +
|
|
1309
|
+
' public var _peachUsesSceneLifecycle: Bool { true };'
|
|
1310
|
+
copied = at + 1
|
|
1311
|
+
}
|
|
1300
1312
|
depth++
|
|
1301
1313
|
if (opensReusableBody) reusableBodies.push(depth)
|
|
1302
1314
|
opensReusableBody = false
|
|
@@ -1335,12 +1347,36 @@ export function swiftSourceAsIOS(
|
|
|
1335
1347
|
opensReusableBody = true
|
|
1336
1348
|
}
|
|
1337
1349
|
const modifiers = conditioned.slice(conditioned.lastIndexOf('\n', at - 1) + 1, at)
|
|
1350
|
+
const delegateClass = DELEGATE_CLASS.exec(rest)
|
|
1351
|
+
if (delegateClass && /\bUIApplicationDelegate\b/.test(delegateClass[0])) {
|
|
1352
|
+
const body = at + delegateClass[0].lastIndexOf('{')
|
|
1353
|
+
let bodyDepth = 0
|
|
1354
|
+
for (const token of tokens) {
|
|
1355
|
+
if (token < body) continue
|
|
1356
|
+
if (conditioned[token] === '{') bodyDepth++
|
|
1357
|
+
else if (conditioned[token] === '}' && --bodyDepth === 0) break
|
|
1358
|
+
else if (
|
|
1359
|
+
bodyDepth === 1 &&
|
|
1360
|
+
/^func\s+application\s*\([^{}]*\bconfigurationForConnecting\s+/.test(
|
|
1361
|
+
conditioned.slice(token, token + 600),
|
|
1362
|
+
)
|
|
1363
|
+
) {
|
|
1364
|
+
sceneLifecycleBodies.add(body)
|
|
1365
|
+
break
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1338
1369
|
if (DELEGATE_CLASS.test(rest) && !/\b(?:final|open)\b/.test(modifiers)) {
|
|
1339
1370
|
out += `${conditioned.slice(copied, at)}final `
|
|
1340
1371
|
copied = at
|
|
1341
1372
|
}
|
|
1342
1373
|
continue
|
|
1343
1374
|
}
|
|
1375
|
+
if (/^@UIApplicationMain\b/.test(rest)) {
|
|
1376
|
+
out += conditioned.slice(copied, at) + '@main'.padEnd('@UIApplicationMain'.length)
|
|
1377
|
+
copied = at + '@UIApplicationMain'.length
|
|
1378
|
+
continue
|
|
1379
|
+
}
|
|
1344
1380
|
const selector = SELECTOR.exec(rest)
|
|
1345
1381
|
const match = selector ?? OBJC_ATTRIBUTE.exec(rest)
|
|
1346
1382
|
if (!match) continue
|
|
@@ -1358,6 +1394,25 @@ export function swiftSourceAsIOS(
|
|
|
1358
1394
|
return lowerAnyObjectDoubleValue(out + conditioned.slice(copied))
|
|
1359
1395
|
}
|
|
1360
1396
|
|
|
1397
|
+
/** Swift's application entry declarations, ignoring comments and strings. */
|
|
1398
|
+
export function swiftApplicationEntry(file: string, source: string): boolean {
|
|
1399
|
+
const { tokens } = swiftCodeScan(source)
|
|
1400
|
+
let depth = 0
|
|
1401
|
+
for (const at of tokens) {
|
|
1402
|
+
if (source[at] === '{') depth++
|
|
1403
|
+
else if (source[at] === '}') depth--
|
|
1404
|
+
else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
|
|
1405
|
+
return true
|
|
1406
|
+
else if (
|
|
1407
|
+
depth === 0 &&
|
|
1408
|
+
path.basename(file) === 'main.swift' &&
|
|
1409
|
+
/^UIApplicationMain\s*\(/.test(source.slice(at))
|
|
1410
|
+
)
|
|
1411
|
+
return true
|
|
1412
|
+
}
|
|
1413
|
+
return false
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1361
1416
|
// the offsets of the lines that begin in code, and of every `@`, `#`,
|
|
1362
1417
|
// `class`, `extension` and `override` keyword that stands in code (an interpolation's code included), from a scan of Swift's
|
|
1363
1418
|
// lexical contexts: nested block comments, line comments, string literals (single and
|
|
@@ -1369,7 +1424,10 @@ type Lexical =
|
|
|
1369
1424
|
| { kind: 'block'; depth: number }
|
|
1370
1425
|
| { kind: 'string'; hashes: number; multiline: boolean }
|
|
1371
1426
|
| { kind: 'regex'; hashes: number }
|
|
1372
|
-
function swiftCodeScan(source: string): {
|
|
1427
|
+
function swiftCodeScan(source: string): {
|
|
1428
|
+
lineStarts: Set<number>
|
|
1429
|
+
tokens: number[]
|
|
1430
|
+
} {
|
|
1373
1431
|
const starts = new Set<number>()
|
|
1374
1432
|
const tokens: number[] = []
|
|
1375
1433
|
const stack: Lexical[] = [{ kind: 'code', parens: 0 }]
|
|
@@ -1459,9 +1517,13 @@ function swiftCodeScan(source: string): { lineStarts: Set<number>; tokens: numbe
|
|
|
1459
1517
|
? 'override'
|
|
1460
1518
|
: source.startsWith('import', i)
|
|
1461
1519
|
? 'import'
|
|
1462
|
-
: source.startsWith('
|
|
1463
|
-
? '
|
|
1464
|
-
:
|
|
1520
|
+
: source.startsWith('func', i)
|
|
1521
|
+
? 'func'
|
|
1522
|
+
: source.startsWith('UIApplicationMain', i)
|
|
1523
|
+
? 'UIApplicationMain'
|
|
1524
|
+
: source.startsWith('NSClassFromString', i)
|
|
1525
|
+
? 'NSClassFromString'
|
|
1526
|
+
: null
|
|
1465
1527
|
if (
|
|
1466
1528
|
keyword &&
|
|
1467
1529
|
!/[\w$]/.test(source[i - 1] ?? '') &&
|
|
@@ -1796,10 +1858,16 @@ export function compileSwiftProjectUnit(
|
|
|
1796
1858
|
plugin,
|
|
1797
1859
|
]),
|
|
1798
1860
|
],
|
|
1799
|
-
{
|
|
1861
|
+
{
|
|
1862
|
+
env: BUILD_ENV,
|
|
1863
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
1864
|
+
timeout: options.timeoutMs,
|
|
1865
|
+
},
|
|
1800
1866
|
)
|
|
1801
1867
|
} catch (error) {
|
|
1802
|
-
throw new Error(projectDiagnostic(outputOf(error), layout), {
|
|
1868
|
+
throw new Error(projectDiagnostic(outputOf(error), layout), {
|
|
1869
|
+
cause: error,
|
|
1870
|
+
})
|
|
1803
1871
|
}
|
|
1804
1872
|
return {
|
|
1805
1873
|
hash,
|
package/src/swift-host.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
swiftPeachModules,
|
|
22
22
|
withNativeSourceGlue,
|
|
23
23
|
swiftModuleInputFiles,
|
|
24
|
+
swiftApplicationEntry,
|
|
24
25
|
} from './swift-compile'
|
|
25
26
|
import { swiftDistributionRoot, swiftModuleToolchain } from './swift-distribution'
|
|
26
27
|
import { swiftImplicitResourcePaths, swiftManifestTargets } from './swift-package'
|
|
@@ -259,6 +260,7 @@ function xcodeLayout(root: string): XcodeLayout | null {
|
|
|
259
260
|
if (!registered) return null
|
|
260
261
|
const app = readXcodeAppTarget(registered.xcodeproj, registered.target)
|
|
261
262
|
const files = new Set([app.pbxproj, ...app.sources, ...app.resources])
|
|
263
|
+
if (app.infoPlistFile) files.add(app.infoPlistFile)
|
|
262
264
|
const targets: XcodeLayout['targets'] = []
|
|
263
265
|
for (const dir of app.localPackages) {
|
|
264
266
|
const manifest = path.join(dir, 'Package.swift')
|
|
@@ -289,7 +291,12 @@ function xcodeLayout(root: string): XcodeLayout | null {
|
|
|
289
291
|
})
|
|
290
292
|
for (const file of target.files) files.add(file)
|
|
291
293
|
}
|
|
292
|
-
return {
|
|
294
|
+
return {
|
|
295
|
+
app,
|
|
296
|
+
targets,
|
|
297
|
+
unavailable: remote.unavailable,
|
|
298
|
+
files: [...files].sort(),
|
|
299
|
+
}
|
|
293
300
|
}
|
|
294
301
|
|
|
295
302
|
// the manifest the compile reads for an xcode app: the app target and each
|
|
@@ -557,6 +564,18 @@ export function buildSwiftBundleFiles(
|
|
|
557
564
|
const files: Record<string, string> = {}
|
|
558
565
|
const watched: string[] = []
|
|
559
566
|
let total = 0
|
|
567
|
+
const xcode = xcodeLayout(packagePath)
|
|
568
|
+
if (xcode) {
|
|
569
|
+
const bytes = Buffer.from(xcode.app.infoPlist)
|
|
570
|
+
if (bytes.length > limits.resourceBytes || bytes.length > limits.resourceTotalBytes)
|
|
571
|
+
throw new Error('swift launch Info.plist exceeds bundle resource limits')
|
|
572
|
+
files['Info.plist'] = bytes.toString('base64')
|
|
573
|
+
total += bytes.length
|
|
574
|
+
if (xcode.app.infoPlistFile)
|
|
575
|
+
watched.push(
|
|
576
|
+
path.relative(packagePath, xcode.app.infoPlistFile).split(path.sep).join('/'),
|
|
577
|
+
)
|
|
578
|
+
}
|
|
560
579
|
for (const { base, file } of enumerateBundleJson(relative)) {
|
|
561
580
|
watched.push(file)
|
|
562
581
|
const disk = path.join(packagePath, ...file.split('/'))
|
|
@@ -1072,14 +1091,15 @@ export async function swiftPackageMetadata(
|
|
|
1072
1091
|
): Promise<SwiftEntryModuleArgs> {
|
|
1073
1092
|
packagePath = fs.realpathSync(packagePath)
|
|
1074
1093
|
const mains = sourceFiles(packagePath).filter((file) =>
|
|
1075
|
-
|
|
1094
|
+
swiftApplicationEntry(
|
|
1095
|
+
file,
|
|
1076
1096
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString('utf8'),
|
|
1077
1097
|
),
|
|
1078
1098
|
)
|
|
1079
1099
|
const native = nativeSourceDescriptor(packagePath)
|
|
1080
1100
|
if (mains.length > 1 || (mains.length === 0 && !native)) {
|
|
1081
1101
|
throw new Error(
|
|
1082
|
-
`swift package ${packageName} needs exactly one
|
|
1102
|
+
`swift package ${packageName} needs exactly one application entry source or generated native modules; found ${mains.length}`,
|
|
1083
1103
|
)
|
|
1084
1104
|
}
|
|
1085
1105
|
const project = projectFor(packagePath, hosted)
|
package/src/vite-plugin-one.ts
CHANGED
|
@@ -10,7 +10,6 @@ import fs from 'fs'
|
|
|
10
10
|
import { randomUUID } from 'node:crypto'
|
|
11
11
|
import { createRequire } from 'node:module'
|
|
12
12
|
import path from 'path'
|
|
13
|
-
import { swiftPackageDirectories } from 'vxrn'
|
|
14
13
|
import { WebSocket, WebSocketServer } from 'ws'
|
|
15
14
|
import { DEFAULT_SOOTSIM_BRIDGE_PORT } from './bridge-constants'
|
|
16
15
|
import {
|
|
@@ -62,8 +61,9 @@ export function rnxPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
62
61
|
return { optimizeDeps: { include: ['use-latest-callback'] } }
|
|
63
62
|
},
|
|
64
63
|
|
|
65
|
-
configureServer(server) {
|
|
64
|
+
async configureServer(server) {
|
|
66
65
|
if (options.enabled === false) return
|
|
66
|
+
const { swiftPackageDirectories } = await import('vxrn')
|
|
67
67
|
let swiftPackages: Map<string, string> | undefined
|
|
68
68
|
// the workspace SwiftUI module beside peachsim compiles locally; an
|
|
69
69
|
// npm install has none (null), and its packages compile on Contrast.
|
package/src/vite-plugin.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { createRequire } from 'module'
|
|
|
14
14
|
import { runInNewContext, Script } from 'node:vm'
|
|
15
15
|
import path from 'path'
|
|
16
16
|
import { fileURLToPath, pathToFileURL } from 'url'
|
|
17
|
+
import { minify } from 'terser'
|
|
17
18
|
import { type Plugin, transformWithOxc } from 'vite'
|
|
18
19
|
|
|
19
20
|
declare module '@babel/core' {
|
|
@@ -648,10 +649,18 @@ export function workerBootChunkPlugin(closures: WorkerBootClosure[]): Plugin {
|
|
|
648
649
|
if (!isWorker) return null
|
|
649
650
|
// vite introduces relative child-worker urls during rendering. resolve
|
|
650
651
|
// their module base after that pass, using syntax-aware replacement.
|
|
651
|
-
|
|
652
|
+
const transformed = await transformWithOxc(code, chunk.fileName, {
|
|
652
653
|
define: { 'import.meta.url': 'globalThis.location.href' },
|
|
653
654
|
sourcemap: true,
|
|
654
655
|
})
|
|
656
|
+
const compact = await minify(transformed.code, {
|
|
657
|
+
module: true,
|
|
658
|
+
compress: { passes: 2 },
|
|
659
|
+
mangle: true,
|
|
660
|
+
sourceMap: { content: transformed.map, asObject: true },
|
|
661
|
+
})
|
|
662
|
+
if (!compact.code) this.error('worker minification produced no code')
|
|
663
|
+
return { code: compact.code, map: compact.map }
|
|
655
664
|
},
|
|
656
665
|
},
|
|
657
666
|
generateBundle(_options, bundle) {
|
package/src/xcode-project.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import fs from 'node:fs'
|
|
8
8
|
import path from 'node:path'
|
|
9
|
+
import plist from 'plist'
|
|
9
10
|
import { swiftManifestGraph } from './swift-package'
|
|
10
11
|
|
|
11
12
|
type PlistValue = string | PlistValue[] | { [key: string]: PlistValue }
|
|
@@ -130,6 +131,9 @@ export interface XcodeAppTarget {
|
|
|
130
131
|
sources: string[]
|
|
131
132
|
/** absolute paths of every resource file the target copies, bundles expanded. */
|
|
132
133
|
resources: string[]
|
|
134
|
+
/** the target's processed launch plist, including generated build settings. */
|
|
135
|
+
infoPlist: string
|
|
136
|
+
infoPlistFile: string | null
|
|
133
137
|
languageMode: number
|
|
134
138
|
mainActorIsolation: boolean
|
|
135
139
|
/** directories of the local swift packages whose products the target links. */
|
|
@@ -344,6 +348,82 @@ export function readXcodeAppTarget(
|
|
|
344
348
|
: productName,
|
|
345
349
|
)
|
|
346
350
|
|
|
351
|
+
const variables = {
|
|
352
|
+
...settings,
|
|
353
|
+
EXECUTABLE_NAME: settings.EXECUTABLE_NAME ?? productName,
|
|
354
|
+
DEVELOPMENT_LANGUAGE:
|
|
355
|
+
settings.DEVELOPMENT_LANGUAGE ?? str(project.developmentRegion) ?? 'en',
|
|
356
|
+
TARGET_NAME: name,
|
|
357
|
+
PRODUCT_NAME: productName,
|
|
358
|
+
PRODUCT_MODULE_NAME: moduleName,
|
|
359
|
+
SRCROOT: projectDir,
|
|
360
|
+
SOURCE_ROOT: projectDir,
|
|
361
|
+
}
|
|
362
|
+
const expand = (value: string): string => {
|
|
363
|
+
const seen = new Set<string>()
|
|
364
|
+
while (/\$[({][A-Za-z_][A-Za-z0-9_]*[)}]/.test(value)) {
|
|
365
|
+
if (seen.has(value)) throw new Error(`${name} has cyclic Info.plist build settings`)
|
|
366
|
+
seen.add(value)
|
|
367
|
+
value = value.replace(
|
|
368
|
+
/\$[({]([A-Za-z_][A-Za-z0-9_]*)[)}]/g,
|
|
369
|
+
(match, key: string) => {
|
|
370
|
+
const replacement = Object.entries(variables).find(
|
|
371
|
+
([name]) => name === key,
|
|
372
|
+
)?.[1]
|
|
373
|
+
if (replacement === undefined)
|
|
374
|
+
throw new Error(`${name} Info.plist has unresolved setting ${match}`)
|
|
375
|
+
return replacement
|
|
376
|
+
},
|
|
377
|
+
)
|
|
378
|
+
}
|
|
379
|
+
return value
|
|
380
|
+
}
|
|
381
|
+
const expandValue = (value: plist.PlistValue): plist.PlistValue => {
|
|
382
|
+
if (typeof value === 'string') return expand(value)
|
|
383
|
+
if (Array.isArray(value)) return value.map(expandValue)
|
|
384
|
+
if (
|
|
385
|
+
typeof value === 'object' &&
|
|
386
|
+
!(value instanceof Date) &&
|
|
387
|
+
!Buffer.isBuffer(value)
|
|
388
|
+
) {
|
|
389
|
+
return Object.fromEntries(
|
|
390
|
+
Object.entries(value).map(([key, value]) => [key, expandValue(value)]),
|
|
391
|
+
)
|
|
392
|
+
}
|
|
393
|
+
return value
|
|
394
|
+
}
|
|
395
|
+
const infoPlistFile = settings.INFOPLIST_FILE
|
|
396
|
+
? path.resolve(projectDir, expand(settings.INFOPLIST_FILE))
|
|
397
|
+
: null
|
|
398
|
+
const sourceInfo = infoPlistFile
|
|
399
|
+
? plist.parse(fs.readFileSync(infoPlistFile, 'utf8'))
|
|
400
|
+
: {}
|
|
401
|
+
if (
|
|
402
|
+
!sourceInfo ||
|
|
403
|
+
typeof sourceInfo !== 'object' ||
|
|
404
|
+
Array.isArray(sourceInfo) ||
|
|
405
|
+
sourceInfo instanceof Date ||
|
|
406
|
+
Buffer.isBuffer(sourceInfo)
|
|
407
|
+
) {
|
|
408
|
+
throw new Error(`${name} Info.plist must contain a dictionary`)
|
|
409
|
+
}
|
|
410
|
+
const info: Record<string, plist.PlistValue> = {}
|
|
411
|
+
for (const [key, value] of Object.entries(sourceInfo)) info[key] = expandValue(value)
|
|
412
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
413
|
+
if (!key.startsWith('INFOPLIST_KEY_') || key.endsWith('_Generation')) continue
|
|
414
|
+
info[key.slice('INFOPLIST_KEY_'.length)] =
|
|
415
|
+
value === 'YES' ? true : value === 'NO' ? false : expand(value)
|
|
416
|
+
}
|
|
417
|
+
if (
|
|
418
|
+
settings.INFOPLIST_KEY_UIApplicationSceneManifest_Generation === 'YES' &&
|
|
419
|
+
info.UIApplicationSceneManifest === undefined
|
|
420
|
+
) {
|
|
421
|
+
info.UIApplicationSceneManifest = {
|
|
422
|
+
UIApplicationSupportsMultipleScenes: true,
|
|
423
|
+
UISceneConfigurations: {},
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
347
427
|
const sources = new Set<string>()
|
|
348
428
|
const resources = new Set<string>()
|
|
349
429
|
const addResource = (file: string) => {
|
|
@@ -463,7 +543,10 @@ export function readXcodeAppTarget(
|
|
|
463
543
|
if (!dependency || !product) continue
|
|
464
544
|
const reference = object(str(dependency.package))
|
|
465
545
|
if (reference?.isa === 'XCRemoteSwiftPackageReference') {
|
|
466
|
-
remoteProducts.push({
|
|
546
|
+
remoteProducts.push({
|
|
547
|
+
product,
|
|
548
|
+
repositoryURL: str(reference.repositoryURL) ?? '',
|
|
549
|
+
})
|
|
467
550
|
} else if (reference?.isa === 'XCLocalSwiftPackageReference') {
|
|
468
551
|
localPackages.add(path.resolve(projectDir, str(reference.relativePath) ?? ''))
|
|
469
552
|
} else if (localProducts.has(product)) {
|
|
@@ -516,6 +599,8 @@ export function readXcodeAppTarget(
|
|
|
516
599
|
moduleName,
|
|
517
600
|
sources: [...sources].sort(),
|
|
518
601
|
resources: [...resources].sort(),
|
|
602
|
+
infoPlist: plist.build(info),
|
|
603
|
+
infoPlistFile,
|
|
519
604
|
languageMode: swiftVersion >= 6 ? 6 : 5,
|
|
520
605
|
mainActorIsolation: settings.SWIFT_DEFAULT_ACTOR_ISOLATION === 'MainActor',
|
|
521
606
|
localPackages: [...localPackages].sort(),
|