peachsim 0.1.759 → 0.1.761

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.
Files changed (78) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/agent-identity.cjs +1 -1
  4. package/dist-lib/agent-sessions.cjs +1 -1
  5. package/dist-lib/attached-projects.cjs +1 -1
  6. package/dist-lib/auth/shared-session.cjs +1 -1
  7. package/dist-lib/backend-origin.cjs +1 -1
  8. package/dist-lib/beta.cjs +1 -1
  9. package/dist-lib/beta.mjs +1 -1
  10. package/dist-lib/bridge-constants.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.mjs +1 -1
  13. package/dist-lib/bridge-contract.cjs +1 -1
  14. package/dist-lib/bridge-contract.mjs +1 -1
  15. package/dist-lib/capture-contract.cjs +1 -1
  16. package/dist-lib/capture-contract.mjs +1 -1
  17. package/dist-lib/cli-constants.cjs +1 -1
  18. package/dist-lib/cloud-contract.cjs +1 -1
  19. package/dist-lib/cloud-contract.mjs +1 -1
  20. package/dist-lib/cloud-test-args.cjs +1 -1
  21. package/dist-lib/cloud-test-args.mjs +1 -1
  22. package/dist-lib/cloud.cjs +1 -1
  23. package/dist-lib/cloud.mjs +1 -1
  24. package/dist-lib/config.cjs +1 -1
  25. package/dist-lib/detox/index.cjs +1 -1
  26. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  27. package/dist-lib/home-paths.cjs +1 -1
  28. package/dist-lib/host/bridge-host.cjs +888 -735
  29. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  30. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  31. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  32. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  33. package/dist-lib/host/websocket-proxy.cjs +1 -1
  34. package/dist-lib/index.cjs +37 -220
  35. package/dist-lib/jump-to-source-babel.cjs +1 -1
  36. package/dist-lib/jump-to-source-native.cjs +1 -1
  37. package/dist-lib/kotlin-host.cjs +1 -1
  38. package/dist-lib/menu.cjs +1 -1
  39. package/dist-lib/menu.mjs +1 -1
  40. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  41. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  42. package/dist-lib/metro-production-bundle.cjs +1 -1
  43. package/dist-lib/metro-production-bundle.mjs +1 -1
  44. package/dist-lib/metro.cjs +37 -220
  45. package/dist-lib/native-app-identity.cjs +1 -1
  46. package/dist-lib/native-app-identity.mjs +1 -1
  47. package/dist-lib/native-firebase-metadata.cjs +1 -1
  48. package/dist-lib/native-firebase-metadata.mjs +1 -1
  49. package/dist-lib/plist.cjs +1 -1
  50. package/dist-lib/plist.mjs +1 -1
  51. package/dist-lib/profiles.cjs +1 -1
  52. package/dist-lib/public-brand.cjs +1 -1
  53. package/dist-lib/react-native-host-modules.cjs +1 -1
  54. package/dist-lib/react-native-host-modules.mjs +1 -1
  55. package/dist-lib/render-mode.cjs +1 -1
  56. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  57. package/dist-lib/sdk.cjs +1 -1
  58. package/dist-lib/sdk.mjs +1 -1
  59. package/dist-lib/skills.cjs +1185 -1026
  60. package/dist-lib/swift-compile.cjs +66 -8
  61. package/dist-lib/swift-compile.mjs +66 -8
  62. package/dist-lib/swift-package.cjs +1 -110
  63. package/dist-lib/swift-package.mjs +1 -109
  64. package/dist-lib/swift-submit.cjs +1 -1
  65. package/dist-lib/swift-submit.mjs +1 -1
  66. package/dist-lib/swift-toolchain.cjs +1 -1
  67. package/dist-lib/swift.cjs +1 -1
  68. package/dist-lib/vite-swift.cjs +672 -519
  69. package/dist-lib/vite.cjs +1 -1
  70. package/package.json +1 -1
  71. package/src/native-seam-manifest.ts +8 -0
  72. package/src/swift-compile.ts +102 -12
  73. package/src/swift-host.ts +64 -64
  74. package/src/swift-package-manifest.ts +307 -0
  75. package/src/swift-package.ts +2 -135
  76. package/src/swift-packages.ts +341 -0
  77. package/src/xcode-project.ts +57 -70
  78. package/src/swift-remote-packages.ts +0 -255
@@ -0,0 +1,341 @@
1
+ // the swift packages an app links, local and remote, compiled from source.
2
+ // each linked product resolves through swiftpm's own reading of its package
3
+ // (swift-package-manifest.ts) to the source targets that build it; remote
4
+ // packages are fetched at the revision the app's Package.resolved pins, into
5
+ // .build/peach/checkouts under the app's root. peach compiles swift source
6
+ // only, so a product reaching a binary or c-family target stays missing,
7
+ // with the reason, and so does every module such a package declares.
8
+
9
+ import { execFileSync } from 'node:child_process'
10
+ import fs from 'node:fs'
11
+ import path from 'node:path'
12
+ import {
13
+ swiftImplicitResourcePaths,
14
+ swiftPackageIdentity,
15
+ type SwiftPackageTarget,
16
+ } from './swift-package'
17
+ import {
18
+ swiftPackageManifest,
19
+ swiftTargetFiles,
20
+ type SwiftPackageManifest,
21
+ } from './swift-package-manifest'
22
+
23
+ /** where a linked product comes from, as the project names it. */
24
+ export type SwiftPackageSource =
25
+ | { kind: 'local'; dir: string }
26
+ | { kind: 'remote'; url: string }
27
+ /** a product xcode finds by name among the local packages the workspace references. */
28
+ | { kind: 'unnamed' }
29
+
30
+ export interface SwiftLinkedProduct {
31
+ product: string
32
+ source: SwiftPackageSource
33
+ }
34
+
35
+ /** a source target that compiles, its directory and files absolute. */
36
+ export interface SwiftPackageSourceTarget extends SwiftPackageTarget {
37
+ dir: string
38
+ files: string[]
39
+ /** the package directory, so a manifest edit reaches the compile. */
40
+ packageDir: string
41
+ remote: boolean
42
+ }
43
+
44
+ /** why a product or module does not compile, and where it comes from. */
45
+ export interface SwiftPackageGap {
46
+ source: string
47
+ reason: string
48
+ }
49
+
50
+ export interface SwiftPackages {
51
+ targets: SwiftPackageSourceTarget[]
52
+ /** linked products peach cannot compile. */
53
+ unavailable: Map<string, SwiftPackageGap>
54
+ /** every module a reached package declares that does not compile. */
55
+ modules: Map<string, SwiftPackageGap>
56
+ }
57
+
58
+ /** where checkouts live, relative to the app's root. */
59
+ export const REMOTE_CHECKOUTS = path.join('.build', 'peach', 'checkouts')
60
+
61
+ // sources the swift compile cannot build: c, c++, objective-c and assembly.
62
+ const C_FAMILY = /\.(c|cc|cpp|cxx|m|mm|s|S)$/
63
+
64
+ interface Pin {
65
+ location: string
66
+ revision: string
67
+ }
68
+
69
+ function readPins(resolved: string): Map<string, Pin> {
70
+ const data: unknown = JSON.parse(fs.readFileSync(resolved, 'utf8'))
71
+ const pins =
72
+ data && typeof data === 'object' && 'pins' in data && Array.isArray(data.pins)
73
+ ? data.pins
74
+ : null
75
+ if (!pins)
76
+ throw new Error(`${resolved} has no pins; resolve packages in a current Xcode`)
77
+ const out = new Map<string, Pin>()
78
+ for (const pin of pins) {
79
+ const identity = pin?.identity
80
+ const location = pin?.location
81
+ const revision = pin?.state?.revision
82
+ if (
83
+ typeof identity === 'string' &&
84
+ typeof location === 'string' &&
85
+ typeof revision === 'string'
86
+ )
87
+ out.set(identity, { location, revision })
88
+ }
89
+ return out
90
+ }
91
+
92
+ const verified = new Set<string>()
93
+
94
+ // a shallow checkout of exactly the pinned revision, reused while HEAD is it.
95
+ function checkout(checkouts: string, identity: string, pin: Pin): string {
96
+ const dir = path.join(checkouts, identity)
97
+ const key = `${dir}\0${pin.revision}`
98
+ if (verified.has(key)) return dir
99
+ const git = (...args: string[]) =>
100
+ execFileSync('git', ['-C', dir, ...args], {
101
+ encoding: 'utf8',
102
+ stdio: ['ignore', 'pipe', 'pipe'],
103
+ }).trim()
104
+ const current = fs.existsSync(path.join(dir, '.git')) ? git('rev-parse', 'HEAD') : ''
105
+ if (current !== pin.revision) {
106
+ fs.rmSync(dir, { recursive: true, force: true })
107
+ fs.mkdirSync(dir, { recursive: true })
108
+ try {
109
+ git('init', '-q')
110
+ git('fetch', '-q', '--depth', '1', pin.location, pin.revision)
111
+ git('checkout', '-q', 'FETCH_HEAD')
112
+ } catch (error) {
113
+ fs.rmSync(dir, { recursive: true, force: true })
114
+ const stderr =
115
+ error instanceof Error && 'stderr' in error ? String(error.stderr).trim() : ''
116
+ throw new Error(
117
+ `could not fetch ${pin.location} at ${pin.revision}${stderr ? `: ${stderr}` : ''}`,
118
+ )
119
+ }
120
+ }
121
+ verified.add(key)
122
+ return dir
123
+ }
124
+
125
+ interface LoadedPackage {
126
+ /** the url, or the local directory. */
127
+ source: string
128
+ remote: boolean
129
+ manifest: SwiftPackageManifest
130
+ }
131
+
132
+ /**
133
+ * resolves `products` to the source targets that build them. products named
134
+ * in `provided` are peach modules and link as those instead. without
135
+ * `provided` (a hosted compile has no local module list) remote products
136
+ * stay unresolved and only local packages compile.
137
+ */
138
+ export function resolveSwiftPackages(options: {
139
+ rootDir: string
140
+ /** the Package.resolved pinning remote revisions, when the app has one. */
141
+ resolved: string | null
142
+ products: readonly SwiftLinkedProduct[]
143
+ /** local package directories the workspace or a project references. */
144
+ localDirs: readonly string[]
145
+ provided: ReadonlySet<string> | null
146
+ }): SwiftPackages {
147
+ const { rootDir, resolved, products, localDirs } = options
148
+ const provided = options.provided ?? new Set<string>()
149
+ const result: SwiftPackages = {
150
+ targets: [],
151
+ unavailable: new Map(),
152
+ modules: new Map(),
153
+ }
154
+ const pins = resolved ? readPins(resolved) : null
155
+ const checkouts = path.join(rootDir, REMOTE_CHECKOUTS)
156
+
157
+ const packages = new Map<string, LoadedPackage | string>()
158
+ // a package by local directory or remote url, or why it cannot load
159
+ const load = (source: SwiftPackageSource & { kind: 'local' | 'remote' }) => {
160
+ const key = source.kind === 'local' ? path.resolve(source.dir) : source.url
161
+ const cached = packages.get(key)
162
+ if (cached !== undefined) return cached
163
+ let loaded: LoadedPackage | string
164
+ if (source.kind === 'local') {
165
+ loaded = { source: key, remote: false, manifest: swiftPackageManifest(key) }
166
+ } else {
167
+ const identity = swiftPackageIdentity(source.url)
168
+ const pin = pins?.get(identity)
169
+ if (!pin) {
170
+ loaded = pins
171
+ ? `package ${identity} is not pinned in Package.resolved`
172
+ : 'no Package.resolved pins it; resolve packages in Xcode once'
173
+ } else {
174
+ fs.mkdirSync(checkouts, { recursive: true })
175
+ // fetched sources never show up as changes in the app's repository
176
+ fs.writeFileSync(path.join(path.dirname(checkouts), '.gitignore'), '*\n')
177
+ loaded = {
178
+ source: source.url,
179
+ remote: true,
180
+ manifest: swiftPackageManifest(checkout(checkouts, identity, pin)),
181
+ }
182
+ }
183
+ }
184
+ packages.set(key, loaded)
185
+ return loaded
186
+ }
187
+
188
+ const targets = new Map<string, SwiftPackageSourceTarget>()
189
+ // why each target of each package cannot compile, or null once it can
190
+ const targetOutcomes = new Map<string, string | null>()
191
+ const resolveTarget = (pkg: LoadedPackage, name: string): string | null => {
192
+ const key = `${pkg.manifest.dir}\0${name}`
193
+ if (targetOutcomes.has(key)) return targetOutcomes.get(key)!
194
+ // a dependency cycle resolves as compiling; swiftpm rejects real cycles
195
+ targetOutcomes.set(key, null)
196
+ const outcome = ((): string | null => {
197
+ if (provided.has(name)) return null
198
+ const target = pkg.manifest.targets.get(name)
199
+ if (!target) return `${path.basename(pkg.manifest.dir)} declares no target ${name}`
200
+ if (target.type === 'binary') return `${name} is a binary framework`
201
+ if (target.type === 'system') return `${name} is a system C library`
202
+ if (target.type !== 'regular') return `${name} is a ${target.type} target`
203
+ const files = swiftTargetFiles(pkg.manifest, target)
204
+ if (files.some((file) => C_FAMILY.test(file)))
205
+ return `${name} is a C or Objective-C target`
206
+ for (const dependency of target.dependencies) {
207
+ if (dependency.kind === 'target') {
208
+ const nested = resolveTarget(pkg, dependency.name)
209
+ if (nested) return nested
210
+ continue
211
+ }
212
+ const nested = resolveDependencyProduct(pkg, dependency.package, dependency.name)
213
+ if (nested) return `${dependency.name}: ${nested}`
214
+ }
215
+ const relative = files.map((file) => path.relative(target.dir, file))
216
+ targets.set(`${pkg.manifest.dir}\0${name}`, {
217
+ name,
218
+ path: '',
219
+ dir: target.dir,
220
+ files,
221
+ packageDir: pkg.manifest.dir,
222
+ remote: pkg.remote,
223
+ executable: false,
224
+ languageMode: target.languageMode,
225
+ mainActorIsolation: target.mainActorIsolation,
226
+ resources:
227
+ target.declaresResources || swiftImplicitResourcePaths(relative).length > 0,
228
+ })
229
+ return null
230
+ })()
231
+ targetOutcomes.set(key, outcome)
232
+ return outcome
233
+ }
234
+ const resolveProduct = (pkg: LoadedPackage, product: string): string | null => {
235
+ if (provided.has(product)) return null
236
+ const roots = pkg.manifest.products.get(product)
237
+ if (!roots) return `${path.basename(pkg.manifest.dir)} has no library ${product}`
238
+ for (const name of roots) {
239
+ const reason = resolveTarget(pkg, name)
240
+ if (reason) return reason
241
+ }
242
+ return null
243
+ }
244
+ // a `.product(package:)` names a dependency by identity or by its `name:`
245
+ const resolveDependencyProduct = (
246
+ pkg: LoadedPackage,
247
+ packageName: string,
248
+ product: string,
249
+ ): string | null => {
250
+ if (provided.has(product)) return null
251
+ const dependency = pkg.manifest.packages.get(packageName)
252
+ if (!dependency)
253
+ return `${path.basename(pkg.manifest.dir)} names no package ${packageName}`
254
+ if ('dir' in dependency) {
255
+ const loaded = load({ kind: 'local', dir: dependency.dir })
256
+ return typeof loaded === 'string' ? loaded : resolveProduct(loaded, product)
257
+ }
258
+ if (!options.provided) return null
259
+ const loaded = load({ kind: 'remote', url: dependency.url })
260
+ return typeof loaded === 'string' ? loaded : resolveProduct(loaded, product)
261
+ }
262
+
263
+ const unnamed = () =>
264
+ localDirs
265
+ .map((dir) => load({ kind: 'local', dir }))
266
+ .filter((pkg) => typeof pkg !== 'string')
267
+ for (const { product, source } of products) {
268
+ if (provided.has(product)) continue
269
+ if (source.kind === 'remote' && !options.provided) continue
270
+ const pkg =
271
+ source.kind === 'unnamed'
272
+ ? unnamed().find((candidate) => candidate.manifest.products.has(product))
273
+ : load(source)
274
+ const reason =
275
+ pkg === undefined
276
+ ? 'no package the workspace references vends it'
277
+ : typeof pkg === 'string'
278
+ ? pkg
279
+ : resolveProduct(pkg, product)
280
+ if (reason)
281
+ result.unavailable.set(product, {
282
+ source:
283
+ source.kind === 'remote'
284
+ ? source.url
285
+ : typeof pkg === 'object'
286
+ ? pkg.source
287
+ : source.kind === 'local'
288
+ ? source.dir
289
+ : 'the workspace',
290
+ reason,
291
+ })
292
+ }
293
+
294
+ // every module a reached package declares, so an import of one that does
295
+ // not compile says why even when the app links it through another product
296
+ for (const pkg of packages.values()) {
297
+ if (typeof pkg === 'string') continue
298
+ for (const [name, target] of pkg.manifest.targets) {
299
+ if (target.type === 'test' || target.type === 'plugin' || target.type === 'macro')
300
+ continue
301
+ if (target.type === 'executable') continue
302
+ const reason = resolveTarget(pkg, name)
303
+ if (reason && !result.modules.has(name))
304
+ result.modules.set(name, { source: pkg.source, reason })
305
+ }
306
+ }
307
+ // only targets a linked product reaches compile; the module sweep above
308
+ // resolved the rest to learn their reasons
309
+ const reached = new Set<string>()
310
+ const reach = (pkg: LoadedPackage, name: string) => {
311
+ const key = `${pkg.manifest.dir}\0${name}`
312
+ if (reached.has(key) || !targets.has(key)) return
313
+ reached.add(key)
314
+ for (const dependency of pkg.manifest.targets.get(name)?.dependencies ?? []) {
315
+ if (dependency.kind === 'target') reach(pkg, dependency.name)
316
+ else {
317
+ const source = pkg.manifest.packages.get(dependency.package)
318
+ const nested =
319
+ source &&
320
+ ('dir' in source
321
+ ? packages.get(path.resolve(source.dir))
322
+ : packages.get(source.url))
323
+ if (nested && typeof nested !== 'string')
324
+ for (const root of nested.manifest.products.get(dependency.name) ?? [])
325
+ reach(nested, root)
326
+ }
327
+ }
328
+ }
329
+ for (const { product, source } of products) {
330
+ const pkg =
331
+ source.kind === 'unnamed'
332
+ ? unnamed().find((candidate) => candidate.manifest.products.has(product))
333
+ : packages.get(source.kind === 'local' ? path.resolve(source.dir) : source.url)
334
+ if (!pkg || typeof pkg === 'string' || result.unavailable.has(product)) continue
335
+ for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root)
336
+ }
337
+ result.targets = [...targets.entries()]
338
+ .filter(([key]) => reached.has(key))
339
+ .map(([, target]) => target)
340
+ return result
341
+ }
@@ -9,8 +9,8 @@
9
9
  import fs from 'node:fs'
10
10
  import path from 'node:path'
11
11
  import plist from 'plist'
12
- import { swiftManifestGraph } from './swift-package'
13
12
  import { readXcodeJsonProject } from './xcode-json-project'
13
+ import type { SwiftLinkedProduct } from './swift-packages'
14
14
 
15
15
  export type PlistValue = string | PlistValue[] | { [key: string]: PlistValue }
16
16
  export type PlistDict = { [key: string]: PlistValue }
@@ -116,12 +116,6 @@ const list = (value: PlistValue | undefined): string[] =>
116
116
  ? value.filter((item): item is string => typeof item === 'string')
117
117
  : []
118
118
 
119
- /** a remote package product the target links, as the project names it. */
120
- export interface XcodeRemoteProduct {
121
- product: string
122
- repositoryURL: string
123
- }
124
-
125
119
  /** a target whose swift compiles as one module: the app, or a framework it builds. */
126
120
  export interface XcodeModuleTarget {
127
121
  name: string
@@ -155,13 +149,14 @@ export interface XcodeAppTarget extends XcodeModuleTarget {
155
149
  * products directory, so every one is importable from every other.
156
150
  */
157
151
  frameworks: XcodeModuleTarget[]
158
- /** directories of the local swift packages whose products the build links. */
159
- localPackages: string[]
160
- remoteProducts: XcodeRemoteProduct[]
152
+ /** package products the app and its frameworks link, with the package each names. */
153
+ linkedProducts: SwiftLinkedProduct[]
154
+ /** local package directories the workspace or a project references. */
155
+ localPackageDirs: string[]
156
+ /** prebuilt frameworks and xcframeworks the projects vendor and link, by name. */
157
+ binaryFrameworks: string[]
161
158
  /** the Package.resolved pinning the remote packages' revisions, when resolved. */
162
159
  packageResolved: string | null
163
- /** linked product names no local or remote package reference supplies. */
164
- unresolvedProducts: string[]
165
160
  /** every application target in the workspace, for a chooser. */
166
161
  appTargets: string[]
167
162
  }
@@ -888,25 +883,8 @@ export function readXcodeAppTarget(
888
883
  }),
889
884
  ),
890
885
  ]
891
- const graphs = new Map<string, ReturnType<typeof swiftManifestGraph>>()
892
- const graphOf = (dir: string) => {
893
- const cached = graphs.get(dir)
894
- if (cached) return cached
895
- const graph = swiftManifestGraph(
896
- fs.readFileSync(path.join(dir, 'Package.swift'), 'utf8'),
897
- )
898
- graphs.set(dir, graph)
899
- return graph
900
- }
901
- const localProducts = new Map<string, string>()
902
- for (const dir of localPackageDirs) {
903
- for (const product of graphOf(dir).products.keys()) {
904
- if (!localProducts.has(product)) localProducts.set(product, dir)
905
- }
906
- }
907
- const localPackages = new Set<string>()
908
- const remoteProducts: XcodeRemoteProduct[] = []
909
- const unresolvedProducts: string[] = []
886
+ const linkedProducts: SwiftLinkedProduct[] = []
887
+ const binaryFrameworks = new Set<string>()
910
888
  for (const { project, target } of order) {
911
889
  const productDependencies = [
912
890
  ...list(target.packageProductDependencies),
@@ -918,43 +896,47 @@ export function readXcodeAppTarget(
918
896
  for (const dependencyId of productDependencies) {
919
897
  const dependency = project.object(dependencyId)
920
898
  const product = str(dependency?.productName)?.replace(/^plugin:/, '')
921
- if (!dependency || !product) continue
922
- const reference = project.object(str(dependency.package))
923
- if (reference?.isa === 'XCRemoteSwiftPackageReference') {
924
- if (!remoteProducts.some((entry) => entry.product === product))
925
- remoteProducts.push({
926
- product,
927
- repositoryURL: str(reference.repositoryURL) ?? '',
928
- })
929
- } else if (reference?.isa === 'XCLocalSwiftPackageReference') {
930
- localPackages.add(
931
- path.resolve(project.projectDir, str(reference.relativePath) ?? ''),
932
- )
933
- } else if (localProducts.has(product)) {
934
- localPackages.add(localProducts.get(product)!)
935
- } else if (!unresolvedProducts.includes(product)) unresolvedProducts.push(product)
936
- }
937
- }
938
-
939
- // local packages depend on further local packages by path, and on remote
940
- // products by the package's url.
941
- const pending = [...localPackages]
942
- while (pending.length > 0) {
943
- const dir = pending.pop()!
944
- const graph = graphOf(dir)
945
- for (const relative of graph.packagePaths) {
946
- const next = path.resolve(dir, relative)
947
- if (localPackages.has(next) || !fs.existsSync(path.join(next, 'Package.swift')))
899
+ if (
900
+ !dependency ||
901
+ !product ||
902
+ linkedProducts.some((entry) => entry.product === product)
903
+ )
948
904
  continue
949
- localPackages.add(next)
950
- pending.push(next)
905
+ const reference = project.object(str(dependency.package))
906
+ linkedProducts.push({
907
+ product,
908
+ source:
909
+ reference?.isa === 'XCRemoteSwiftPackageReference'
910
+ ? { kind: 'remote', url: str(reference.repositoryURL) ?? '' }
911
+ : reference?.isa === 'XCLocalSwiftPackageReference'
912
+ ? {
913
+ kind: 'local',
914
+ dir: path.resolve(
915
+ project.projectDir,
916
+ str(reference.relativePath) ?? '',
917
+ ),
918
+ }
919
+ : { kind: 'unnamed' },
920
+ })
951
921
  }
952
- for (const dependencies of graph.dependencies.values()) {
953
- for (const dependency of dependencies) {
954
- if (dependency.kind !== 'product') continue
955
- const url = graph.packageURLs.get(dependency.package)
956
- if (url && !remoteProducts.some((entry) => entry.product === dependency.name))
957
- remoteProducts.push({ product: dependency.name, repositoryURL: url })
922
+ // prebuilt frameworks the project vendors, as opposed to built products
923
+ // and the sdk's own
924
+ for (const phaseId of list(target.buildPhases)) {
925
+ const phase = project.object(phaseId)
926
+ if (phase?.isa !== 'PBXFrameworksBuildPhase') continue
927
+ for (const buildFileId of list(phase.files)) {
928
+ const fileId = str(project.object(buildFileId)?.fileRef)
929
+ const file = project.object(fileId)
930
+ const tree = str(file?.sourceTree)
931
+ const name = /([^/]+)\.(xc)?framework$/.exec(str(file?.path) ?? '')?.[1]
932
+ if (file?.isa !== 'PBXFileReference' || !name) continue
933
+ if (
934
+ tree === 'BUILT_PRODUCTS_DIR' ||
935
+ tree === 'SDKROOT' ||
936
+ tree === 'DEVELOPER_DIR'
937
+ )
938
+ continue
939
+ binaryFrameworks.add(name)
958
940
  }
959
941
  }
960
942
  }
@@ -974,17 +956,22 @@ export function readXcodeAppTarget(
974
956
  [
975
957
  workspace ? path.dirname(workspace) : app.project.projectDir,
976
958
  ...used.map((project) => project.projectDir),
977
- ...localPackages,
959
+ ...localPackageDirs,
960
+ ...linkedProducts.flatMap(({ source }) =>
961
+ source.kind === 'local' && fs.existsSync(source.dir) ? [source.dir] : [],
962
+ ),
978
963
  ].map((dir) => fs.realpathSync(dir)),
979
964
  ),
980
965
  projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
981
966
  infoPlist: plist.build(info),
982
967
  infoPlistFile,
983
968
  frameworks,
984
- localPackages: [...localPackages].map((dir) => fs.realpathSync(dir)).sort(),
985
- remoteProducts,
969
+ linkedProducts,
970
+ localPackageDirs: [
971
+ ...new Set(localPackageDirs.map((dir) => fs.realpathSync(dir))),
972
+ ].sort(),
973
+ binaryFrameworks: [...binaryFrameworks].sort(),
986
974
  packageResolved: fs.existsSync(resolvedFile) ? resolvedFile : null,
987
- unresolvedProducts,
988
975
  appTargets: appTargetNames,
989
976
  }
990
977
  }