peachsim 0.1.758 → 0.1.759
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/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 +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +729 -371
- 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 +2 -4
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +495 -139
- 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 +466 -110
- 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 +920 -557
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- 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 +539 -179
- package/dist-lib/vite.cjs +2 -4
- package/package.json +1 -1
- package/src/host/replacement-module-handler.ts +2 -1
- package/src/swift-host.ts +4 -2
- package/src/xcode-json-project.ts +450 -0
- package/src/xcode-project.ts +55 -22
package/dist-lib/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.759 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -643,9 +643,7 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
643
643
|
sendJavaScript(
|
|
644
644
|
req,
|
|
645
645
|
res,
|
|
646
|
-
|
|
647
|
-
//# sourceMappingURL=data:application/json;base64,${map}
|
|
648
|
-
`
|
|
646
|
+
compiled.code + "\n//# sourceMappingURL=data:application/json;base64," + map + "\n"
|
|
649
647
|
);
|
|
650
648
|
} catch (error) {
|
|
651
649
|
const message = error instanceof Error ? error.message : String(error);
|
package/package.json
CHANGED
|
@@ -182,11 +182,12 @@ export async function handleReplacementModuleRequest(
|
|
|
182
182
|
})
|
|
183
183
|
// inline the map: the file is the app author's own source, and the
|
|
184
184
|
// simulator page is the only thing that ever loads it.
|
|
185
|
+
// stack mappers scan the bundled host source too; keep the map url quoted.
|
|
185
186
|
const map = Buffer.from(JSON.stringify(compiled.sourceMap), 'utf8').toString('base64')
|
|
186
187
|
sendJavaScript(
|
|
187
188
|
req,
|
|
188
189
|
res,
|
|
189
|
-
|
|
190
|
+
compiled.code + '\n//# sourceMappingURL=data:application/json;base64,' + map + '\n',
|
|
190
191
|
)
|
|
191
192
|
} catch (error) {
|
|
192
193
|
const message = error instanceof Error ? error.message : String(error)
|
package/src/swift-host.ts
CHANGED
|
@@ -265,7 +265,7 @@ function xcodeLayout(root: string): XcodeLayout | null {
|
|
|
265
265
|
const registered = xcodeProjects.get(root)
|
|
266
266
|
if (!registered) return null
|
|
267
267
|
const app = readXcodeAppTarget(registered.xcodeproj, registered.target)
|
|
268
|
-
const files = new Set([...app.
|
|
268
|
+
const files = new Set([...app.projectFiles, ...app.sources, ...app.resources])
|
|
269
269
|
if (app.infoPlistFile) files.add(app.infoPlistFile)
|
|
270
270
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]))
|
|
271
271
|
const targets: XcodeLayout['targets'] = []
|
|
@@ -446,7 +446,9 @@ export function sourceFiles(root: string): string[] {
|
|
|
446
446
|
|
|
447
447
|
function resourceCandidateFiles(root: string): string[] {
|
|
448
448
|
return packageFiles(root).filter(
|
|
449
|
-
(file) =>
|
|
449
|
+
(file) =>
|
|
450
|
+
!file.endsWith('.swift') &&
|
|
451
|
+
!['project.pbxproj', 'project.xcproj'].includes(path.basename(file)),
|
|
450
452
|
)
|
|
451
453
|
}
|
|
452
454
|
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
// reads xcode's json project format (`project.xcproj`, xcode 27.2) into the
|
|
2
|
+
// object table `project.pbxproj` holds, so one reader serves both formats.
|
|
3
|
+
// the schema is apple's xcode-project-format package (XCSchema): a tree of
|
|
4
|
+
// files that name their own target membership, targets referring to each
|
|
5
|
+
// other by name, settings with `[config=Name]` conditions in their keys, and
|
|
6
|
+
// cross-project references by the referenced project's file in the tree.
|
|
7
|
+
// paths resolve here, so every emitted file reference is absolute or lives in
|
|
8
|
+
// the build products directory.
|
|
9
|
+
|
|
10
|
+
import path from 'node:path'
|
|
11
|
+
import JSON5 from 'json5'
|
|
12
|
+
import type { PlistDict, PlistValue } from './xcode-project'
|
|
13
|
+
|
|
14
|
+
type Json = null | boolean | number | string | Json[] | { [key: string]: Json }
|
|
15
|
+
type JsonObject = { [key: string]: Json }
|
|
16
|
+
|
|
17
|
+
const isObject = (value: Json | undefined): value is JsonObject =>
|
|
18
|
+
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
19
|
+
const text = (value: Json | undefined): string | undefined =>
|
|
20
|
+
typeof value === 'string' ? value : undefined
|
|
21
|
+
const items = (value: Json | undefined): Json[] => (Array.isArray(value) ? value : [])
|
|
22
|
+
|
|
23
|
+
const PHASE_ISA: Record<string, string> = {
|
|
24
|
+
'compile-sources': 'PBXSourcesBuildPhase',
|
|
25
|
+
resources: 'PBXResourcesBuildPhase',
|
|
26
|
+
frameworks: 'PBXFrameworksBuildPhase',
|
|
27
|
+
headers: 'PBXHeadersBuildPhase',
|
|
28
|
+
copy: 'PBXCopyFilesBuildPhase',
|
|
29
|
+
script: 'PBXShellScriptBuildPhase',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface TreeNode {
|
|
33
|
+
id: string
|
|
34
|
+
name: string
|
|
35
|
+
/** the directory a child's group-relative path resolves against. */
|
|
36
|
+
dir: string | null
|
|
37
|
+
parent: TreeNode | null
|
|
38
|
+
children: TreeNode[]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** the root of a json project, shaped as parseOpenStepPlist returns a pbxproj. */
|
|
42
|
+
export function readXcodeJsonProject(xcodeproj: string, source: string): PlistDict {
|
|
43
|
+
const json: unknown = JSON5.parse(source)
|
|
44
|
+
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`)
|
|
45
|
+
const projectDir = path.dirname(xcodeproj)
|
|
46
|
+
const objects: PlistDict = {}
|
|
47
|
+
let next = 0
|
|
48
|
+
const add = (entry: PlistDict, id?: string): string => {
|
|
49
|
+
const key = id ?? `XCPROJ${(next++).toString(16).toUpperCase().padStart(18, '0')}`
|
|
50
|
+
objects[key] = entry
|
|
51
|
+
return key
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// a file path's base: `<PROJECT>/`, `<PRODUCTS>/`, `<USER:VAR>/`, absolute,
|
|
55
|
+
// or relative to the enclosing group.
|
|
56
|
+
const locate = (
|
|
57
|
+
raw: string,
|
|
58
|
+
groupDir: string | null,
|
|
59
|
+
): { sourceTree: string; path: string } | null => {
|
|
60
|
+
if (raw.startsWith('<USER:')) return null
|
|
61
|
+
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw)
|
|
62
|
+
if (base) {
|
|
63
|
+
if (base[1] === 'PROJECT')
|
|
64
|
+
return { sourceTree: '<absolute>', path: path.join(projectDir, base[2]!) }
|
|
65
|
+
if (base[1] === 'PRODUCTS')
|
|
66
|
+
return { sourceTree: 'BUILT_PRODUCTS_DIR', path: base[2]! }
|
|
67
|
+
return null
|
|
68
|
+
}
|
|
69
|
+
const unescaped = raw.replaceAll('\\<', '<')
|
|
70
|
+
if (unescaped.startsWith('/')) return { sourceTree: '<absolute>', path: unescaped }
|
|
71
|
+
if (unescaped.startsWith('~')) return null
|
|
72
|
+
return groupDir === null
|
|
73
|
+
? null
|
|
74
|
+
: { sourceTree: '<absolute>', path: path.join(groupDir, unescaped) }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// the groups and files tree, with each reference's target memberships
|
|
78
|
+
const memberships: { refId: string; entry: Json }[] = []
|
|
79
|
+
const folders: { id: string; folder: JsonObject }[] = []
|
|
80
|
+
const projectFiles: string[] = []
|
|
81
|
+
const root: TreeNode = { id: '', name: '', dir: projectDir, parent: null, children: [] }
|
|
82
|
+
const walk = (entries: Json[], parent: TreeNode): string[] =>
|
|
83
|
+
entries.flatMap((entry) => {
|
|
84
|
+
if (!isObject(entry)) return []
|
|
85
|
+
const kind = text(entry.kind) ?? 'file-reference'
|
|
86
|
+
const raw = text(entry.path) ?? ''
|
|
87
|
+
const located = raw === '' ? null : locate(raw, parent.dir)
|
|
88
|
+
const name = text(entry.name) ?? path.basename(raw)
|
|
89
|
+
const node: TreeNode = { id: '', name, dir: null, parent, children: [] }
|
|
90
|
+
if (kind === 'group' || kind === 'variant-group' || kind === 'version-group') {
|
|
91
|
+
node.dir =
|
|
92
|
+
raw === ''
|
|
93
|
+
? parent.dir
|
|
94
|
+
: located?.sourceTree === '<absolute>'
|
|
95
|
+
? located.path
|
|
96
|
+
: null
|
|
97
|
+
const childIds = walk(items(entry.children), node)
|
|
98
|
+
node.id = add(
|
|
99
|
+
kind === 'version-group' && located
|
|
100
|
+
? {
|
|
101
|
+
isa: 'PBXFileReference',
|
|
102
|
+
...located,
|
|
103
|
+
lastKnownFileType: 'wrapper.xcdatamodel',
|
|
104
|
+
}
|
|
105
|
+
: {
|
|
106
|
+
isa: kind === 'variant-group' ? 'PBXVariantGroup' : 'PBXGroup',
|
|
107
|
+
children: childIds,
|
|
108
|
+
...(kind === 'variant-group'
|
|
109
|
+
? {}
|
|
110
|
+
: { sourceTree: '<absolute>', path: node.dir ?? '' }),
|
|
111
|
+
name,
|
|
112
|
+
},
|
|
113
|
+
text(entry.id),
|
|
114
|
+
)
|
|
115
|
+
} else if (kind === 'folder') {
|
|
116
|
+
node.id = add(
|
|
117
|
+
{
|
|
118
|
+
isa: 'PBXFileSystemSynchronizedRootGroup',
|
|
119
|
+
...(located ?? { sourceTree: 'SDKROOT', path: raw }),
|
|
120
|
+
},
|
|
121
|
+
text(entry.id),
|
|
122
|
+
)
|
|
123
|
+
folders.push({ id: node.id, folder: entry })
|
|
124
|
+
} else {
|
|
125
|
+
node.id = add(
|
|
126
|
+
{
|
|
127
|
+
isa: 'PBXFileReference',
|
|
128
|
+
...(located ?? { sourceTree: 'SDKROOT', path: raw }),
|
|
129
|
+
name,
|
|
130
|
+
},
|
|
131
|
+
text(entry.id),
|
|
132
|
+
)
|
|
133
|
+
if (located?.sourceTree === '<absolute>' && located.path.endsWith('.xcodeproj'))
|
|
134
|
+
projectFiles.push(node.id)
|
|
135
|
+
}
|
|
136
|
+
parent.children.push(node)
|
|
137
|
+
for (const membership of items(entry['target-membership'])) {
|
|
138
|
+
if (kind !== 'folder') memberships.push({ refId: node.id, entry: membership })
|
|
139
|
+
}
|
|
140
|
+
return [node.id]
|
|
141
|
+
})
|
|
142
|
+
const mainGroupChildren = walk(items(json.files), root)
|
|
143
|
+
const mainGroup = add({
|
|
144
|
+
isa: 'PBXGroup',
|
|
145
|
+
children: mainGroupChildren,
|
|
146
|
+
sourceTree: '<absolute>',
|
|
147
|
+
path: projectDir,
|
|
148
|
+
})
|
|
149
|
+
root.id = mainGroup
|
|
150
|
+
|
|
151
|
+
// a reference into the tree: `id:<object id>`, or names from the root
|
|
152
|
+
const lookup = (
|
|
153
|
+
reference: Json | undefined,
|
|
154
|
+
from: TreeNode = root,
|
|
155
|
+
): string | undefined => {
|
|
156
|
+
if (isObject(reference)) {
|
|
157
|
+
const anchor = lookupNode(reference.anchor, root)
|
|
158
|
+
return anchor ? lookup(reference['relative-path'], anchor) : undefined
|
|
159
|
+
}
|
|
160
|
+
if (Array.isArray(reference)) {
|
|
161
|
+
return lookupNode(
|
|
162
|
+
reference
|
|
163
|
+
.map((component) =>
|
|
164
|
+
isObject(component) ? (text(component.name) ?? '') : (text(component) ?? ''),
|
|
165
|
+
)
|
|
166
|
+
.join('/'),
|
|
167
|
+
from,
|
|
168
|
+
)?.id
|
|
169
|
+
}
|
|
170
|
+
return lookupNode(reference, from)?.id
|
|
171
|
+
}
|
|
172
|
+
const lookupNode = (
|
|
173
|
+
reference: Json | undefined,
|
|
174
|
+
from: TreeNode,
|
|
175
|
+
): TreeNode | undefined => {
|
|
176
|
+
const value = text(reference)
|
|
177
|
+
if (value === undefined) return undefined
|
|
178
|
+
if (value.startsWith('id:')) {
|
|
179
|
+
const id = value.slice(3)
|
|
180
|
+
const find = (node: TreeNode): TreeNode | undefined =>
|
|
181
|
+
node.id === id ? node : node.children.map(find).find(Boolean)
|
|
182
|
+
return find(root)
|
|
183
|
+
}
|
|
184
|
+
let node: TreeNode | undefined = from
|
|
185
|
+
for (const component of value.split('/')) {
|
|
186
|
+
if (!node) return undefined
|
|
187
|
+
node =
|
|
188
|
+
component === '.'
|
|
189
|
+
? node
|
|
190
|
+
: component === '..'
|
|
191
|
+
? (node.parent ?? undefined)
|
|
192
|
+
: node.children.find((child) => child.name === component)
|
|
193
|
+
}
|
|
194
|
+
return node
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// configurations: each carries the level's settings, conditions intact,
|
|
198
|
+
// and its xcconfig as the base configuration reference
|
|
199
|
+
const configurations = items(json.configurations).flatMap((entry) => {
|
|
200
|
+
const name = isObject(entry) ? text(entry.name) : text(entry)
|
|
201
|
+
return name ? [{ name, file: isObject(entry) ? entry.file : undefined }] : []
|
|
202
|
+
})
|
|
203
|
+
const settingsOf = (value: Json | undefined): PlistDict =>
|
|
204
|
+
Object.fromEntries(
|
|
205
|
+
Object.entries(isObject(value) ? value : {}).flatMap(
|
|
206
|
+
([key, setting]): [string, PlistValue][] =>
|
|
207
|
+
typeof setting === 'string'
|
|
208
|
+
? [[key, setting]]
|
|
209
|
+
: Array.isArray(setting)
|
|
210
|
+
? [
|
|
211
|
+
[
|
|
212
|
+
key,
|
|
213
|
+
setting.filter((item): item is string => typeof item === 'string'),
|
|
214
|
+
],
|
|
215
|
+
]
|
|
216
|
+
: [],
|
|
217
|
+
),
|
|
218
|
+
)
|
|
219
|
+
const configurationList = (
|
|
220
|
+
settings: PlistDict,
|
|
221
|
+
specialized: Map<string, Json | undefined>,
|
|
222
|
+
): string =>
|
|
223
|
+
add({
|
|
224
|
+
isa: 'XCConfigurationList',
|
|
225
|
+
defaultConfigurationName: text(json['default-configuration']) ?? 'Debug',
|
|
226
|
+
buildConfigurations: configurations.map(({ name, file }) => {
|
|
227
|
+
const base = lookup(specialized.has(name) ? specialized.get(name) : file)
|
|
228
|
+
return add({
|
|
229
|
+
isa: 'XCBuildConfiguration',
|
|
230
|
+
name,
|
|
231
|
+
buildSettings: settings,
|
|
232
|
+
...(base ? { baseConfigurationReference: base } : {}),
|
|
233
|
+
})
|
|
234
|
+
}),
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
// packages, keyed by swiftpm identity: the url's or the package directory's
|
|
238
|
+
// last component, lowercased
|
|
239
|
+
const packageIds = new Map<string, string>()
|
|
240
|
+
for (const entry of items(json.packages)) {
|
|
241
|
+
if (!isObject(entry)) continue
|
|
242
|
+
const repository = text(entry.repository)
|
|
243
|
+
const local = text(entry.path)
|
|
244
|
+
const name =
|
|
245
|
+
local !== undefined
|
|
246
|
+
? path.basename(path.resolve(path.dirname(xcodeproj), local))
|
|
247
|
+
: path.basename(repository ?? '').replace(/\.git$/, '')
|
|
248
|
+
const id =
|
|
249
|
+
text(entry.kind) === 'local' && local !== undefined
|
|
250
|
+
? add({ isa: 'XCLocalSwiftPackageReference', relativePath: local })
|
|
251
|
+
: add({ isa: 'XCRemoteSwiftPackageReference', repositoryURL: repository ?? '' })
|
|
252
|
+
packageIds.set(name.toLowerCase(), id)
|
|
253
|
+
}
|
|
254
|
+
const productDependency = (entry: JsonObject): string =>
|
|
255
|
+
add({
|
|
256
|
+
isa: 'XCSwiftPackageProductDependency',
|
|
257
|
+
productName: text(entry['product-name']) ?? '',
|
|
258
|
+
// xcode finds a product by name across packages when none is named
|
|
259
|
+
...(packageIds.has(text(entry.package)?.toLowerCase() ?? '')
|
|
260
|
+
? { package: packageIds.get(text(entry.package)!.toLowerCase()) }
|
|
261
|
+
: {}),
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
// a container proxy into another project's target or product
|
|
265
|
+
const proxy = (
|
|
266
|
+
entry: JsonObject,
|
|
267
|
+
remote: string | undefined,
|
|
268
|
+
proxyType: string,
|
|
269
|
+
): string =>
|
|
270
|
+
add({
|
|
271
|
+
isa: 'PBXContainerItemProxy',
|
|
272
|
+
containerPortal: lookup(entry.project) ?? '',
|
|
273
|
+
proxyType,
|
|
274
|
+
remoteGlobalIDString: remote ?? '',
|
|
275
|
+
remoteInfo: text(entry.target) ?? '',
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
// targets and their phases, keyed by `Target/kind[/name]` for memberships
|
|
279
|
+
const phases = new Map<string, string>()
|
|
280
|
+
const targetIds = new Map<string, string>()
|
|
281
|
+
const targets: { id: string; target: PlistDict; entry: JsonObject }[] = []
|
|
282
|
+
for (const entry of items(json.targets)) {
|
|
283
|
+
if (!isObject(entry)) continue
|
|
284
|
+
const name = text(entry.name) ?? ''
|
|
285
|
+
const productType = text(entry['product-type'])
|
|
286
|
+
const target: PlistDict = {
|
|
287
|
+
isa: text(entry.kind) === 'aggregate' ? 'PBXAggregateTarget' : 'PBXNativeTarget',
|
|
288
|
+
name,
|
|
289
|
+
productName: name,
|
|
290
|
+
productType: productType
|
|
291
|
+
? `com.apple.product-type.${productType}`
|
|
292
|
+
: (text(entry['full-product-type']) ?? ''),
|
|
293
|
+
buildPhases: [],
|
|
294
|
+
dependencies: [],
|
|
295
|
+
packageProductDependencies: [],
|
|
296
|
+
fileSystemSynchronizedGroups: [],
|
|
297
|
+
}
|
|
298
|
+
const product = lookup(entry.product)
|
|
299
|
+
if (product) target.productReference = product
|
|
300
|
+
const id = add(target, text(entry.id))
|
|
301
|
+
targetIds.set(name, id)
|
|
302
|
+
targets.push({ id, target, entry })
|
|
303
|
+
for (const phase of items(entry['build-phases'])) {
|
|
304
|
+
const kind = isObject(phase) ? text(phase.kind) : text(phase)
|
|
305
|
+
const isa = kind ? PHASE_ISA[kind] : undefined
|
|
306
|
+
if (!kind || !isa) continue
|
|
307
|
+
const phaseName = isObject(phase) ? text(phase.name) : undefined
|
|
308
|
+
const phaseId = add(
|
|
309
|
+
{ isa, files: [] },
|
|
310
|
+
isObject(phase) ? text(phase.id) : undefined,
|
|
311
|
+
)
|
|
312
|
+
;(target.buildPhases as string[]).push(phaseId)
|
|
313
|
+
phases.set([name, kind, phaseName].filter(Boolean).join('/'), phaseId)
|
|
314
|
+
phases.set(`id:${phaseId}`, phaseId)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const phaseFiles = (
|
|
318
|
+
reference: Json | undefined,
|
|
319
|
+
targetName?: string,
|
|
320
|
+
): PlistValue[] | null => {
|
|
321
|
+
const value = text(reference)
|
|
322
|
+
if (value === undefined) return null
|
|
323
|
+
const key = value.startsWith('id:') || !targetName ? value : `${targetName}/${value}`
|
|
324
|
+
const phase = objects[phases.get(key) ?? '']
|
|
325
|
+
return phase &&
|
|
326
|
+
typeof phase === 'object' &&
|
|
327
|
+
!Array.isArray(phase) &&
|
|
328
|
+
Array.isArray(phase.files)
|
|
329
|
+
? phase.files
|
|
330
|
+
: null
|
|
331
|
+
}
|
|
332
|
+
for (const { refId, entry } of memberships) {
|
|
333
|
+
const files = phaseFiles(isObject(entry) ? entry['build-phase'] : entry)
|
|
334
|
+
files?.push(add({ isa: 'PBXBuildFile', fileRef: refId }))
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
for (const { target, entry } of targets) {
|
|
338
|
+
const name = text(entry.name) ?? ''
|
|
339
|
+
target.buildConfigurationList = configurationList(
|
|
340
|
+
settingsOf(entry['build-settings']),
|
|
341
|
+
new Map(
|
|
342
|
+
items(entry['specialized-configurations']).flatMap((configuration) =>
|
|
343
|
+
isObject(configuration) && text(configuration.name)
|
|
344
|
+
? [[text(configuration.name)!, configuration.file] as const]
|
|
345
|
+
: [],
|
|
346
|
+
),
|
|
347
|
+
),
|
|
348
|
+
)
|
|
349
|
+
for (const dependency of items(entry.dependencies)) {
|
|
350
|
+
const kind = isObject(dependency)
|
|
351
|
+
? (text(dependency.kind) ?? 'localTarget')
|
|
352
|
+
: 'localTarget'
|
|
353
|
+
if (kind === 'package' && isObject(dependency)) {
|
|
354
|
+
;(target.dependencies as string[]).push(
|
|
355
|
+
add({ isa: 'PBXTargetDependency', productRef: productDependency(dependency) }),
|
|
356
|
+
)
|
|
357
|
+
} else if (kind === 'remoteTarget' && isObject(dependency)) {
|
|
358
|
+
;(target.dependencies as string[]).push(
|
|
359
|
+
add({
|
|
360
|
+
isa: 'PBXTargetDependency',
|
|
361
|
+
targetProxy: proxy(dependency, text(dependency['target-id']), '1'),
|
|
362
|
+
}),
|
|
363
|
+
)
|
|
364
|
+
} else {
|
|
365
|
+
const local = isObject(dependency) ? text(dependency.target) : text(dependency)
|
|
366
|
+
const id = local ? targetIds.get(local) : undefined
|
|
367
|
+
if (id)
|
|
368
|
+
(target.dependencies as string[]).push(
|
|
369
|
+
add({ isa: 'PBXTargetDependency', target: id }),
|
|
370
|
+
)
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
for (const member of items(entry['package-product-members'])) {
|
|
374
|
+
if (!isObject(member)) continue
|
|
375
|
+
const dependency = productDependency(member)
|
|
376
|
+
;(target.packageProductDependencies as string[]).push(dependency)
|
|
377
|
+
// a target build file: {build-phase, id?, platforms?}
|
|
378
|
+
const buildFile = member['build-phase']
|
|
379
|
+
phaseFiles(isObject(buildFile) ? buildFile['build-phase'] : buildFile, name)?.push(
|
|
380
|
+
add({ isa: 'PBXBuildFile', productRef: dependency }),
|
|
381
|
+
)
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// products of other projects' targets, linked or copied into this one's phases
|
|
386
|
+
for (const imported of items(json['imported-products'])) {
|
|
387
|
+
if (!isObject(imported)) continue
|
|
388
|
+
const reference = add({
|
|
389
|
+
isa: 'PBXReferenceProxy',
|
|
390
|
+
path: text(imported.name) ?? text(imported.path) ?? '',
|
|
391
|
+
sourceTree: 'BUILT_PRODUCTS_DIR',
|
|
392
|
+
remoteRef: proxy(imported, text(imported['product-id']), '2'),
|
|
393
|
+
})
|
|
394
|
+
for (const membership of items(imported['target-membership'])) {
|
|
395
|
+
phaseFiles(isObject(membership) ? membership['build-phase'] : membership)?.push(
|
|
396
|
+
add({ isa: 'PBXBuildFile', fileRef: reference }),
|
|
397
|
+
)
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// synchronized folders: owners list the folder, and each target's exception
|
|
402
|
+
// set lists the paths whose membership differs for that target
|
|
403
|
+
for (const { id, folder } of folders) {
|
|
404
|
+
const exceptions: string[] = []
|
|
405
|
+
for (const exception of items(folder['membership-exceptions'])) {
|
|
406
|
+
if (!isObject(exception)) continue
|
|
407
|
+
const target = targetIds.get(text(exception.target) ?? '')
|
|
408
|
+
if (!target) continue
|
|
409
|
+
exceptions.push(
|
|
410
|
+
add({
|
|
411
|
+
isa: 'PBXFileSystemSynchronizedBuildFileExceptionSet',
|
|
412
|
+
target,
|
|
413
|
+
membershipExceptions: [
|
|
414
|
+
...items(exception.exclusions),
|
|
415
|
+
...items(exception.inclusions),
|
|
416
|
+
].flatMap((member) => (typeof member === 'string' ? [member] : [])),
|
|
417
|
+
}),
|
|
418
|
+
)
|
|
419
|
+
}
|
|
420
|
+
const group = objects[id]
|
|
421
|
+
if (group && typeof group === 'object' && !Array.isArray(group))
|
|
422
|
+
group.exceptions = exceptions
|
|
423
|
+
for (const owner of items(folder['target-membership'])) {
|
|
424
|
+
const target = targets.find(
|
|
425
|
+
(candidate) => candidate.id === targetIds.get(text(owner) ?? ''),
|
|
426
|
+
)
|
|
427
|
+
;(target?.target.fileSystemSynchronizedGroups as string[] | undefined)?.push(id)
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const localizations = isObject(json.localizations) ? json.localizations : {}
|
|
432
|
+
const project = add({
|
|
433
|
+
isa: 'PBXProject',
|
|
434
|
+
mainGroup,
|
|
435
|
+
projectDirPath: '',
|
|
436
|
+
developmentRegion: text(localizations.development) ?? 'en',
|
|
437
|
+
buildConfigurationList: configurationList(
|
|
438
|
+
settingsOf(json['build-settings']),
|
|
439
|
+
new Map(),
|
|
440
|
+
),
|
|
441
|
+
targets: targets.map((entry) => entry.id),
|
|
442
|
+
packageReferences: [...packageIds.values()],
|
|
443
|
+
projectReferences: projectFiles.map((ProjectRef) => ({ ProjectRef })),
|
|
444
|
+
})
|
|
445
|
+
return { objects, rootObject: project }
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function isJsonObject(value: unknown): value is JsonObject {
|
|
449
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
450
|
+
}
|
package/src/xcode-project.ts
CHANGED
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
// swift sources and resources that are members of the target, the local
|
|
3
3
|
// swift packages its products come from, the remote package products it links,
|
|
4
4
|
// and the build settings that change how its swift compiles. never runs xcode
|
|
5
|
-
// or evaluates a build phase; project
|
|
5
|
+
// or evaluates a build phase; the project file is data: project.pbxproj, or
|
|
6
|
+
// xcode 27.2's json project.xcproj, which xcode-json-project.ts reads into
|
|
7
|
+
// the same object table.
|
|
6
8
|
|
|
7
9
|
import fs from 'node:fs'
|
|
8
10
|
import path from 'node:path'
|
|
9
11
|
import plist from 'plist'
|
|
10
12
|
import { swiftManifestGraph } from './swift-package'
|
|
13
|
+
import { readXcodeJsonProject } from './xcode-json-project'
|
|
11
14
|
|
|
12
|
-
type PlistValue = string | PlistValue[] | { [key: string]: PlistValue }
|
|
13
|
-
type PlistDict = { [key: string]: PlistValue }
|
|
15
|
+
export type PlistValue = string | PlistValue[] | { [key: string]: PlistValue }
|
|
16
|
+
export type PlistDict = { [key: string]: PlistValue }
|
|
14
17
|
|
|
15
18
|
// project.pbxproj is an old-style (openstep) property list: dictionaries,
|
|
16
19
|
// arrays and strings, with c comments. node's plist package reads only xml.
|
|
@@ -139,8 +142,8 @@ export interface XcodeAppTarget extends XcodeModuleTarget {
|
|
|
139
142
|
* local package the app builds from: every compile path is relative to it.
|
|
140
143
|
*/
|
|
141
144
|
rootDir: string
|
|
142
|
-
/** every project.pbxproj the app's build reads. */
|
|
143
|
-
|
|
145
|
+
/** every project file (project.pbxproj or project.xcproj) the app's build reads. */
|
|
146
|
+
projectFiles: string[]
|
|
144
147
|
/** the target's processed launch plist, including generated build settings. */
|
|
145
148
|
infoPlist: string
|
|
146
149
|
infoPlistFile: string | null
|
|
@@ -342,7 +345,8 @@ export function findXcodeProject(input: string): string | null {
|
|
|
342
345
|
|
|
343
346
|
interface LoadedProject {
|
|
344
347
|
xcodeproj: string
|
|
345
|
-
pbxproj
|
|
348
|
+
/** project.pbxproj, or the json project.xcproj. */
|
|
349
|
+
projectFile: string
|
|
346
350
|
objects: PlistDict
|
|
347
351
|
project: PlistDict
|
|
348
352
|
/** the directory holding the .xcodeproj: every relative path starts here. */
|
|
@@ -353,15 +357,28 @@ interface LoadedProject {
|
|
|
353
357
|
|
|
354
358
|
const loaded = new Map<string, { mtimeMs: number; project: LoadedProject }>()
|
|
355
359
|
|
|
360
|
+
// a project bundle holds one project file, in either format.
|
|
361
|
+
function xcodeProjectFile(xcodeproj: string): string | null {
|
|
362
|
+
for (const name of ['project.pbxproj', 'project.xcproj']) {
|
|
363
|
+
const file = path.join(xcodeproj, name)
|
|
364
|
+
if (fs.existsSync(file)) return file
|
|
365
|
+
}
|
|
366
|
+
return null
|
|
367
|
+
}
|
|
368
|
+
|
|
356
369
|
function loadProject(xcodeproj: string): LoadedProject {
|
|
357
|
-
const
|
|
358
|
-
if (!
|
|
359
|
-
|
|
360
|
-
const
|
|
370
|
+
const projectFile = xcodeProjectFile(xcodeproj)
|
|
371
|
+
if (!projectFile)
|
|
372
|
+
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`)
|
|
373
|
+
const mtimeMs = fs.statSync(projectFile).mtimeMs
|
|
374
|
+
const cached = loaded.get(projectFile)
|
|
361
375
|
if (cached?.mtimeMs === mtimeMs) return cached.project
|
|
362
|
-
const
|
|
376
|
+
const source = fs.readFileSync(projectFile, 'utf8')
|
|
377
|
+
const root = projectFile.endsWith('.xcproj')
|
|
378
|
+
? readXcodeJsonProject(xcodeproj, source)
|
|
379
|
+
: parseOpenStepPlist(source)
|
|
363
380
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
364
|
-
throw new Error(`${
|
|
381
|
+
throw new Error(`${projectFile} has no objects table`)
|
|
365
382
|
}
|
|
366
383
|
const objects = root.objects
|
|
367
384
|
const object = (id: string | undefined): PlistDict | undefined => {
|
|
@@ -370,7 +387,7 @@ function loadProject(xcodeproj: string): LoadedProject {
|
|
|
370
387
|
}
|
|
371
388
|
const project = object(str(root.rootObject))
|
|
372
389
|
if (!project || project.isa !== 'PBXProject') {
|
|
373
|
-
throw new Error(`${
|
|
390
|
+
throw new Error(`${projectFile} has no PBXProject root`)
|
|
374
391
|
}
|
|
375
392
|
// canonical, so every member path agrees with the host's realpath checks
|
|
376
393
|
const projectDir = fs.realpathSync(
|
|
@@ -403,8 +420,16 @@ function loadProject(xcodeproj: string): LoadedProject {
|
|
|
403
420
|
resolvedPaths.set(id, result)
|
|
404
421
|
return result
|
|
405
422
|
}
|
|
406
|
-
const result = {
|
|
407
|
-
|
|
423
|
+
const result = {
|
|
424
|
+
xcodeproj,
|
|
425
|
+
projectFile,
|
|
426
|
+
objects,
|
|
427
|
+
project,
|
|
428
|
+
projectDir,
|
|
429
|
+
object,
|
|
430
|
+
resolvePath,
|
|
431
|
+
}
|
|
432
|
+
loaded.set(projectFile, { mtimeMs, project: result })
|
|
408
433
|
return result
|
|
409
434
|
}
|
|
410
435
|
|
|
@@ -630,7 +655,7 @@ function workspaceProjects(xcodeprojOrWorkspace: string): {
|
|
|
630
655
|
const addProject = (xcodeproj: string) => {
|
|
631
656
|
const key = path.resolve(xcodeproj)
|
|
632
657
|
if (projectAt.has(key) || key.split(path.sep).includes('Pods')) return
|
|
633
|
-
if (!
|
|
658
|
+
if (!xcodeProjectFile(key)) return
|
|
634
659
|
const project = loadProject(key)
|
|
635
660
|
projectAt.set(key, project)
|
|
636
661
|
projects.push(project)
|
|
@@ -651,11 +676,19 @@ function workspaceProjects(xcodeprojOrWorkspace: string): {
|
|
|
651
676
|
return { listed, projects, projectAt }
|
|
652
677
|
}
|
|
653
678
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
679
|
+
// one ref per target, so a target reached by a dependency and a link is visited once
|
|
680
|
+
const targetRefs = new WeakMap<LoadedProject, TargetRef[]>()
|
|
681
|
+
function nativeTargets(project: LoadedProject): TargetRef[] {
|
|
682
|
+
let refs = targetRefs.get(project)
|
|
683
|
+
if (!refs) {
|
|
684
|
+
refs = list(project.project.targets).flatMap((id) => {
|
|
685
|
+
const target = project.object(id)
|
|
686
|
+
return target?.isa === 'PBXNativeTarget' ? [{ project, id, target }] : []
|
|
687
|
+
})
|
|
688
|
+
targetRefs.set(project, refs)
|
|
689
|
+
}
|
|
690
|
+
return refs
|
|
691
|
+
}
|
|
659
692
|
|
|
660
693
|
/** the names of every application target a workspace or project builds. */
|
|
661
694
|
export function listXcodeAppTargets(xcodeprojOrWorkspace: string): string[] {
|
|
@@ -944,7 +977,7 @@ export function readXcodeAppTarget(
|
|
|
944
977
|
...localPackages,
|
|
945
978
|
].map((dir) => fs.realpathSync(dir)),
|
|
946
979
|
),
|
|
947
|
-
|
|
980
|
+
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
948
981
|
infoPlist: plist.build(info),
|
|
949
982
|
infoPlistFile,
|
|
950
983
|
frameworks,
|