peachsim 0.1.1667 → 0.1.1673

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 (178) hide show
  1. package/README.md +1 -1
  2. package/cli/bridge-flow-runner.ts +4 -1
  3. package/cli/commands/coverage-swift.ts +291 -0
  4. package/cli/commands/coverage.ts +168 -24
  5. package/cli/commands/diagnose.ts +1 -19
  6. package/cli/commands/react.ts +3 -18
  7. package/cli/commands/screenshot.ts +1 -1
  8. package/cli/commands/screenshots-capture.ts +1 -1
  9. package/cli/drivers/playwright-provisioning.ts +1 -4
  10. package/cli/drivers/playwright.ts +15 -1
  11. package/cli/scene-video.ts +1 -1
  12. package/cli/ui.ts +20 -0
  13. package/cli/ws-bridge.ts +7 -36
  14. package/detox/frame-identity.cjs +21 -0
  15. package/detox/frame-identity.d.cts +6 -0
  16. package/detox/index.ts +39 -33
  17. package/detox/jest-environment.cjs +4 -1
  18. package/detox/jest-setup-after-env.cjs +0 -4
  19. package/detox/navigation-lifecycle.ts +2 -2
  20. package/detox/proof-observer.ts +126 -0
  21. package/dist-lib/agent-daemon-client.cjs +29 -1
  22. package/dist-lib/agent-events.cjs +1 -1
  23. package/dist-lib/attached-projects.cjs +10 -1
  24. package/dist-lib/auth/shared-session.cjs +1 -1
  25. package/dist-lib/backend-origin.cjs +1 -1
  26. package/dist-lib/beta.cjs +1 -1
  27. package/dist-lib/beta.mjs +1 -1
  28. package/dist-lib/bridge-constants.cjs +1 -1
  29. package/dist-lib/bridge-contract-input.cjs +1 -1
  30. package/dist-lib/bridge-contract-input.mjs +1 -1
  31. package/dist-lib/bridge-contract.cjs +1 -1
  32. package/dist-lib/bridge-contract.mjs +1 -1
  33. package/dist-lib/bundle-channel.cjs +530 -154
  34. package/dist-lib/capture-contract.cjs +1 -1
  35. package/dist-lib/capture-contract.mjs +1 -1
  36. package/dist-lib/cloud-contract.cjs +1 -1
  37. package/dist-lib/cloud-contract.mjs +1 -1
  38. package/dist-lib/cloud-test-args.cjs +1 -1
  39. package/dist-lib/cloud-test-args.mjs +1 -1
  40. package/dist-lib/cloud.cjs +1 -1
  41. package/dist-lib/cloud.mjs +1 -1
  42. package/dist-lib/config.cjs +1 -1
  43. package/dist-lib/config.mjs +1 -1
  44. package/dist-lib/detox/index.cjs +5074 -7353
  45. package/dist-lib/detox/jest-environment.cjs +4 -1
  46. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  47. package/dist-lib/expo-swift-bundle.cjs +578 -151
  48. package/dist-lib/expo-swift-metadata.cjs +1 -1
  49. package/dist-lib/expo-swift-metadata.mjs +1 -1
  50. package/dist-lib/home-paths.cjs +1 -1
  51. package/dist-lib/host/bridge-host.cjs +660 -192
  52. package/dist-lib/host/fetch-proxy-handler.cjs +2 -2
  53. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  54. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  55. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  56. package/dist-lib/host/websocket-proxy.cjs +1 -1
  57. package/dist-lib/index.cjs +206 -6
  58. package/dist-lib/jump-to-source-babel.cjs +1 -1
  59. package/dist-lib/jump-to-source-native.cjs +1 -1
  60. package/dist-lib/kotlin-host.cjs +1 -1
  61. package/dist-lib/menu.cjs +1 -1
  62. package/dist-lib/menu.mjs +1 -1
  63. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  64. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  65. package/dist-lib/metro-production-bundle.cjs +10 -1
  66. package/dist-lib/metro-production-bundle.mjs +12 -1
  67. package/dist-lib/metro.cjs +155 -5
  68. package/dist-lib/native-app-identity-project.cjs +43 -5
  69. package/dist-lib/native-app-identity-project.mjs +43 -5
  70. package/dist-lib/native-app-identity.cjs +1 -1
  71. package/dist-lib/native-app-identity.mjs +1 -1
  72. package/dist-lib/native-firebase-metadata.cjs +1 -1
  73. package/dist-lib/native-firebase-metadata.mjs +1 -1
  74. package/dist-lib/plist.cjs +1 -1
  75. package/dist-lib/plist.mjs +1 -1
  76. package/dist-lib/profiles.cjs +21 -1
  77. package/dist-lib/public-brand.cjs +1 -1
  78. package/dist-lib/public-origins-lib-esm.json +73 -27
  79. package/dist-lib/public-origins-lib-static.json +1 -1
  80. package/dist-lib/public-origins-lib.json +563 -183
  81. package/dist-lib/react-native-host-modules.cjs +1 -1
  82. package/dist-lib/react-native-host-modules.mjs +1 -1
  83. package/dist-lib/reap-browser.cjs +964 -0
  84. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  85. package/dist-lib/sdk.cjs +1 -1
  86. package/dist-lib/sdk.mjs +1 -1
  87. package/dist-lib/skills.cjs +963 -521
  88. package/dist-lib/swift-compile.cjs +276 -86
  89. package/dist-lib/swift-compile.mjs +276 -86
  90. package/dist-lib/swift-package.cjs +34 -4
  91. package/dist-lib/swift-package.mjs +33 -4
  92. package/dist-lib/swift-submit.cjs +2 -2
  93. package/dist-lib/swift-submit.mjs +2 -2
  94. package/dist-lib/swift-toolchain.cjs +25 -44
  95. package/dist-lib/swift.cjs +1 -1
  96. package/dist-lib/vite-swift.cjs +579 -113
  97. package/dist-lib/vite.cjs +61 -2
  98. package/dist-lib/worklet-executable.cjs +1 -1
  99. package/dist-lib/worklet-executable.mjs +1 -1
  100. package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +7 -0
  101. package/dist-types/packages/peach-engine/src/engine/glass-material.d.ts +1 -1
  102. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +2 -0
  103. package/dist-types/packages/peach-engine/src/engine/inspect-outline.d.ts +2 -1
  104. package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +1 -0
  105. package/dist-types/packages/peach-engine/src/engine/paint-boundary.d.ts +3 -1
  106. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +7 -0
  107. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime-kind.d.ts +24 -0
  108. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +4 -2
  109. package/dist-types/packages/peach-engine/src/settings/devices.d.ts +1 -0
  110. package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +18 -0
  111. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  112. package/dist-types/packages/peach-globals/src/nodeContract.d.ts +1 -0
  113. package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
  114. package/package.json +1 -1
  115. package/runtime-companion.json +1 -1
  116. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h +2 -0
  117. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +36 -0
  118. package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCDynamicStore.h +439 -0
  119. package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCDynamicStoreCopySpecific.h +216 -0
  120. package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCDynamicStoreKey.h +267 -0
  121. package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCNetwork.h +204 -0
  122. package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCNetworkConfiguration.h +1393 -0
  123. package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCNetworkConnection.h +568 -0
  124. package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCNetworkReachability.h +369 -0
  125. package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCPreferences.h +473 -0
  126. package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCPreferencesPath.h +179 -0
  127. package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCPreferencesSetSpecific.h +95 -0
  128. package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCSchemaDefinitions.h +2395 -0
  129. package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SystemConfiguration.h +184 -0
  130. package/sdk/ios/usr/include/libkern/OSByteOrder.h +315 -0
  131. package/sdk/ios/usr/include/libkern/machine/OSByteOrder.h +147 -0
  132. package/src/bridge-contract.ts +42 -0
  133. package/src/chromium-admission.ts +196 -0
  134. package/src/host/bridge-host.ts +6 -43
  135. package/src/launch-deadline.ts +74 -0
  136. package/src/nitro-adapter.lock.json +3 -3
  137. package/src/profiles.ts +21 -0
  138. package/src/react-native-coverage/capability-reference-resolution.ts +402 -0
  139. package/src/react-native-coverage/capability-source-references.ts +1296 -0
  140. package/src/react-native-coverage/native-typescript-parser.ts +74 -0
  141. package/src/react-native-coverage/project-aliases.ts +207 -0
  142. package/src/react-native-coverage/verified-reach.ts +47 -0
  143. package/src/reap-browser.ts +1019 -0
  144. package/src/skills/builtin/a11y-review.ts +1 -1
  145. package/src/skills/builtin/perf-profile.ts +1 -1
  146. package/src/skills/builtin/screenshot-all.ts +1 -1
  147. package/src/skills/builtin/visual-diff.ts +1 -1
  148. package/src/swift-compile.ts +107 -56
  149. package/src/swift-coverage/indexdump.ts +80 -0
  150. package/src/swift-coverage/indexing.ts +147 -0
  151. package/src/swift-coverage/package.ts +230 -0
  152. package/src/swift-coverage/provenance.ts +47 -0
  153. package/src/swift-coverage/reader.ts +81 -0
  154. package/src/swift-coverage/source.ts +252 -0
  155. package/src/swift-coverage/types.ts +58 -0
  156. package/src/swift-coverage/xcode-assets.ts +175 -0
  157. package/src/swift-coverage/xcode-bridging.ts +160 -0
  158. package/src/swift-coverage/xcode-packages.ts +251 -0
  159. package/src/swift-coverage/xcode-strings.ts +78 -0
  160. package/src/swift-coverage/xcode.ts +656 -0
  161. package/src/swift-distribution.lock.json +8 -8
  162. package/src/swift-host.ts +21 -1
  163. package/src/swift-objc-import.ts +191 -27
  164. package/src/swift-objc-standin.ts +4 -2
  165. package/src/swift-package-manifest.ts +134 -13
  166. package/src/swift-package.ts +46 -4
  167. package/src/swift-submit.ts +2 -1
  168. package/src/swift-toolchain.ts +36 -61
  169. package/src/worker-system-chunks.ts +3 -10
  170. package/src/xcode-project.ts +5 -5
  171. package/detox/attempt-events.cjs +0 -914
  172. package/detox/attempt-events.d.cts +0 -113
  173. package/detox/motion-change.cjs +0 -524
  174. package/detox/motion-change.d.cts +0 -140
  175. package/detox/motion-leg-starts.cjs +0 -20
  176. package/detox/motion-leg-starts.d.cts +0 -8
  177. package/detox/proof-frame.cjs +0 -190
  178. package/detox/record-block-execution.cjs +0 -78
@@ -0,0 +1,656 @@
1
+ import { createHash } from 'node:crypto'
2
+ import { existsSync, mkdtempSync, realpathSync, rmSync } from 'node:fs'
3
+ import { tmpdir } from 'node:os'
4
+ import { basename, dirname, isAbsolute, join, relative, sep } from 'node:path'
5
+ import { readPackageFile } from '../swift-source-file'
6
+ import {
7
+ isDict,
8
+ list,
9
+ parseOpenStepPlist,
10
+ readXcodeAppTarget,
11
+ str,
12
+ } from '../xcode-project'
13
+ import { xcodePathResolver } from '../xcode-target-members'
14
+ import { swiftCoverageProvenance } from './provenance'
15
+ import { indexSwiftApp } from './source'
16
+ import {
17
+ assetSymbolSettingKeys,
18
+ generateAssetSymbols,
19
+ planAssetSymbols,
20
+ } from './xcode-assets'
21
+ import { bridgingFlags, planBridgingHeader } from './xcode-bridging'
22
+ import { buildLocalPackageModules, planLocalPackages } from './xcode-packages'
23
+ import { generateStringSymbols, planStringSymbols } from './xcode-strings'
24
+ import type { SwiftPackageSourceInput, SwiftSourceInput, SwiftSourceLeg } from './types'
25
+
26
+ export interface SwiftXcodeSourceInput extends Omit<
27
+ SwiftPackageSourceInput,
28
+ 'configuration'
29
+ > {
30
+ project: string
31
+ configuration?: string
32
+ }
33
+
34
+ const sha256 = (bytes: string | Buffer) =>
35
+ createHash('sha256').update(bytes).digest('hex')
36
+
37
+ // every file the project reader consulted besides sources: the snapshot must hold them all.
38
+ export const xcodeMetadataFiles = (
39
+ app: Pick<
40
+ ReturnType<typeof readXcodeAppTarget>,
41
+ 'projectFiles' | 'packageResolved' | 'localPackageDirs'
42
+ >,
43
+ project: string,
44
+ ) => [
45
+ ...new Set([
46
+ ...app.projectFiles,
47
+ ...app.packageResolved,
48
+ ...(project.endsWith('.xcworkspace')
49
+ ? [join(project, 'contents.xcworkspacedata')]
50
+ : []),
51
+ ...app.localPackageDirs.map((dir) => join(dir, 'Package.swift')),
52
+ ]),
53
+ ]
54
+
55
+ // Xcode's Swift.xcspec maps these boolean settings to compiler features. the
56
+ // approachable ones default to SWIFT_APPROACHABLE_CONCURRENCY, and the ones
57
+ // marked language5 are inert in Swift 6 mode, where the compiler already enables them.
58
+ const swiftFeatureSettings = [
59
+ ['DISABLE_OUTWARD_ACTOR_ISOLATION', 'DisableOutwardActorInference', true, true],
60
+ ['INFER_SENDABLE_FROM_CAPTURES', 'InferSendableFromCaptures', true, true],
61
+ [
62
+ 'GLOBAL_ACTOR_ISOLATED_TYPES_USABILITY',
63
+ 'GlobalActorIsolatedTypesUsability',
64
+ true,
65
+ true,
66
+ ],
67
+ ['INFER_ISOLATED_CONFORMANCES', 'InferIsolatedConformances', true, false],
68
+ ['NONISOLATED_NONSENDING_BY_DEFAULT', 'NonisolatedNonsendingByDefault', true, false],
69
+ ['MEMBER_IMPORT_VISIBILITY', 'MemberImportVisibility', false, false],
70
+ ['EXISTENTIAL_ANY', 'ExistentialAny', false, false],
71
+ ['INTERNAL_IMPORTS_BY_DEFAULT', 'InternalImportsByDefault', false, false],
72
+ ] as const
73
+
74
+ export const swiftFeatureSettingKeys = [
75
+ 'SWIFT_APPROACHABLE_CONCURRENCY',
76
+ 'SWIFT_ENABLE_BARE_SLASH_REGEX',
77
+ 'SWIFT_EXPERIMENTAL_FEATURE_DEBUG_DESCRIPTION_MACRO',
78
+ ...swiftFeatureSettings.map(([key]) => `SWIFT_UPCOMING_FEATURE_${key}`),
79
+ ]
80
+
81
+ // the compiler flags Xcode derives from the feature settings, or the reason they
82
+ // are unknown. an unset boolean takes the xcspec default.
83
+ export function swiftFeatureFlags(
84
+ settings: Record<string, string>,
85
+ languageMode: number,
86
+ ) {
87
+ const value = (key: string) => settings[key] || undefined
88
+ const bad = (key: string) => {
89
+ const raw = value(key)
90
+ return raw !== undefined && raw !== 'YES' && raw !== 'NO'
91
+ }
92
+ const invalid = swiftFeatureSettingKeys.filter(bad)
93
+ if (invalid.length)
94
+ return {
95
+ reason: `Swift feature settings must resolve to YES or NO: ${invalid.join(', ')}`,
96
+ }
97
+ const approachable = value('SWIFT_APPROACHABLE_CONCURRENCY') === 'YES'
98
+ const flags: string[] = []
99
+ if (languageMode === 5 && value('SWIFT_ENABLE_BARE_SLASH_REGEX') !== 'NO')
100
+ flags.push('-enable-bare-slash-regex')
101
+ for (const [key, feature, followsApproachable, language5] of swiftFeatureSettings) {
102
+ const explicit = value(`SWIFT_UPCOMING_FEATURE_${key}`)
103
+ const enabled = explicit ? explicit === 'YES' : followsApproachable && approachable
104
+ if (language5 && languageMode !== 5) {
105
+ if (enabled)
106
+ return {
107
+ reason: `${feature} settings are inert in Swift ${languageMode} mode; their effect remains unknown.`,
108
+ }
109
+ continue
110
+ }
111
+ if (enabled) flags.push('-enable-upcoming-feature', feature)
112
+ }
113
+ if (languageMode !== 5 && approachable)
114
+ return {
115
+ reason: `SWIFT_APPROACHABLE_CONCURRENCY applies only in Swift 5 mode; its effect in Swift ${languageMode} remains unknown.`,
116
+ }
117
+ if (value('SWIFT_EXPERIMENTAL_FEATURE_DEBUG_DESCRIPTION_MACRO') !== 'NO')
118
+ flags.push('-enable-experimental-feature', 'DebugDescriptionMacro')
119
+ return { flags }
120
+ }
121
+
122
+ // membership and setting expansion belong to the existing project reader.
123
+ // its object readers are used only to refuse shapes the source index cannot model.
124
+ export function swiftXcodeSourceInput(request: SwiftXcodeSourceInput) {
125
+ const unknown = (reason: string) => ({ status: 'unknown' as const, reasons: [reason] })
126
+ try {
127
+ const root = realpathSync(request.root)
128
+ const project = realpathSync(request.project)
129
+ const compile = request.compile
130
+ if (compile.oneModule)
131
+ return unknown(
132
+ 'One module inputs need generated glue and implicit imports; source reach remains unknown.',
133
+ )
134
+ if (
135
+ compile.objcPeerStartup ||
136
+ compile.nativeTargets?.length ||
137
+ Object.keys(compile.libraries ?? {}).length
138
+ )
139
+ return unknown('Native peer and linked-library compile inputs are unsupported.')
140
+ const app = readXcodeAppTarget(project, request.target, request.configuration, {
141
+ prepareGeneratedSources: false,
142
+ })
143
+ if (app.frameworks.length || app.binaryFrameworks.length || app.cocoapods)
144
+ return unknown(
145
+ `Xcode dependency modules and native peers are not built: ${[
146
+ ...app.frameworks.map(({ name }) => name),
147
+ ...app.binaryFrameworks.map(({ name }) => name),
148
+ ...(app.cocoapods ? ['CocoaPods'] : []),
149
+ ].join(
150
+ ', ',
151
+ )}. One unresolved import fails the typecheck of every file in the module, so no app sources are indexed.`,
152
+ )
153
+ if (
154
+ !app.settings('SWIFT_OBJC_BRIDGING_HEADER') &&
155
+ app.allSources.some((file) => !file.endsWith('.swift'))
156
+ )
157
+ return unknown(
158
+ 'Mixed-language Xcode targets without a bridging header remain unknown.',
159
+ )
160
+ const metadata = xcodeMetadataFiles(app, project)
161
+ .sort()
162
+ .map((file) => {
163
+ const path = relative(root, file)
164
+ const bytes = readPackageFile(root, file, 4 * 1024 * 1024)
165
+ if (compile.files[path] !== bytes.toString('utf8'))
166
+ throw new Error(
167
+ `Project metadata is missing or differs from the original snapshot: ${path}`,
168
+ )
169
+ return { path, sha256: sha256(bytes) }
170
+ })
171
+ const projectFiles = app.projectFiles.filter((file) =>
172
+ /\/project\.(pbxproj|xcproj)$/.test(file),
173
+ )
174
+ if (projectFiles.length !== 1)
175
+ return unknown(
176
+ 'Source indexing needs one owning Xcode project without dependent project targets.',
177
+ )
178
+ const projectFile = projectFiles[0]!
179
+ if (projectFile.endsWith('.xcproj'))
180
+ return unknown(
181
+ 'Xcode JSON project per-file settings and platform-filter provenance remain unknown.',
182
+ )
183
+ const projectSource = compile.files[relative(root, projectFile)]!
184
+ const parsed = parseOpenStepPlist(projectSource)
185
+ if (!isDict(parsed) || !isDict(parsed.objects))
186
+ return unknown('Xcode did not supply a project object table.')
187
+ const objects = parsed.objects
188
+ const owner = objects[str(parsed.rootObject) ?? '']
189
+ const targets = Object.entries(objects).filter(
190
+ ([, value]) =>
191
+ isDict(value) &&
192
+ value.isa === 'PBXNativeTarget' &&
193
+ value.name === app.name &&
194
+ value.productType === 'com.apple.product-type.application',
195
+ )
196
+ if (!isDict(owner) || targets.length !== 1 || !isDict(targets[0]![1]))
197
+ return unknown('The selected Xcode application target is ambiguous.')
198
+ const [targetId, target] = targets[0]!
199
+ if (!isDict(target)) return unknown('Missing application target metadata.')
200
+ const resolveMember = xcodePathResolver(
201
+ objects,
202
+ realpathSync(join(dirname(dirname(projectFile)), str(owner.projectDirPath) ?? '')),
203
+ join,
204
+ )
205
+ // package products are resolved from the project's linked products below
206
+ const dependencyNames = list(target.dependencies).flatMap((id) => {
207
+ const dependency = objects[id]
208
+ if (isDict(dependency) && str(dependency.productRef)) return []
209
+ const named = isDict(dependency) ? objects[str(dependency.target) ?? ''] : undefined
210
+ return [
211
+ (isDict(named) && str(named.name)) ||
212
+ (isDict(dependency) && str(dependency.name)) ||
213
+ id,
214
+ ]
215
+ })
216
+ if (dependencyNames.length)
217
+ return unknown(
218
+ `Xcode target dependencies are not built as modules: ${dependencyNames.join(', ')}. One unresolved import fails the typecheck of every file in the module, so no app sources are indexed.`,
219
+ )
220
+ const configurations = [owner, target].map((level) => {
221
+ const configurationList = objects[str(level.buildConfigurationList) ?? '']
222
+ return list(
223
+ isDict(configurationList) ? configurationList.buildConfigurations : undefined,
224
+ ).flatMap((id) => {
225
+ const entry = objects[id]
226
+ return isDict(entry) ? (str(entry.name) ?? []) : []
227
+ })
228
+ })
229
+ if (configurations.some((names) => !names.includes(app.configuration)))
230
+ return unknown(
231
+ `The requested Xcode configuration is not declared at both project and target levels: ${app.configuration}`,
232
+ )
233
+ for (const phaseId of list(target.buildPhases)) {
234
+ const phase = objects[phaseId]
235
+ if (!isDict(phase)) return unknown('Missing Xcode build phase metadata.')
236
+ if (phase.isa === 'PBXShellScriptBuildPhase')
237
+ return unknown(
238
+ 'Generated sources and Xcode script build phases remain unknown; no scripts were executed.',
239
+ )
240
+ if (phase.isa !== 'PBXSourcesBuildPhase') {
241
+ if (
242
+ ![
243
+ 'PBXResourcesBuildPhase',
244
+ 'PBXFrameworksBuildPhase',
245
+ 'PBXHeadersBuildPhase',
246
+ 'PBXCopyFilesBuildPhase',
247
+ ].includes(str(phase.isa) ?? '')
248
+ )
249
+ return unknown('Unsupported Xcode build phase configuration.')
250
+ continue
251
+ }
252
+ if (phase.platformFilter || list(phase.platformFilters).length)
253
+ return unknown('Xcode source phase platform filters remain unknown.')
254
+ for (const id of list(phase.files)) {
255
+ const file = objects[id]
256
+ if (!isDict(file) || !str(file.fileRef))
257
+ return unknown('Unsupported Xcode source build file reference.')
258
+ const member = resolveMember(str(file.fileRef)!)
259
+ if (!member || !app.allSources.includes(member))
260
+ return unknown(
261
+ 'Xcode source references must resolve to original target members.',
262
+ )
263
+ if (
264
+ file.platformFilter ||
265
+ list(file.platformFilters).length ||
266
+ (isDict(file.settings) && Object.keys(file.settings).length)
267
+ )
268
+ return unknown(
269
+ 'Per-file Xcode compiler settings and platform filters remain unknown.',
270
+ )
271
+ }
272
+ }
273
+ if (list(target.buildRules).length)
274
+ return unknown('Xcode generated build rules remain unknown.')
275
+ if (
276
+ list(target.fileSystemSynchronizedGroups).some(
277
+ (id) =>
278
+ !isDict(objects[id]) ||
279
+ objects[id].isa !== 'PBXFileSystemSynchronizedRootGroup',
280
+ )
281
+ )
282
+ return unknown('Missing synchronized Xcode source group metadata.')
283
+ for (const [groupId, group] of Object.entries(objects)) {
284
+ if (!isDict(group) || group.isa !== 'PBXFileSystemSynchronizedRootGroup') continue
285
+ const exceptions = list(group.exceptions)
286
+ .map((id) => objects[id])
287
+ .filter(isDict)
288
+ if (
289
+ !list(target.fileSystemSynchronizedGroups).includes(groupId) &&
290
+ !exceptions.some((entry) => entry.target === targetId)
291
+ )
292
+ continue
293
+ const folder = resolveMember(groupId)
294
+ if (!folder || !existsSync(folder))
295
+ return unknown('Synchronized Xcode source folders must exist.')
296
+ if (
297
+ (isDict(group.explicitFileTypes) &&
298
+ Object.keys(group.explicitFileTypes).length) ||
299
+ list(group.explicitFolders).length
300
+ )
301
+ return unknown('Explicit synchronized source file types remain unknown.')
302
+ for (const exception of exceptions) {
303
+ if (exception.isa !== 'PBXFileSystemSynchronizedBuildFileExceptionSet')
304
+ return unknown('Synchronized build phase membership exceptions remain unknown.')
305
+ if (exception.target !== targetId) continue
306
+ if (
307
+ Object.keys(exception).some(
308
+ (key) => !['isa', 'target', 'membershipExceptions'].includes(key),
309
+ )
310
+ )
311
+ return unknown('Synchronized per-file Xcode compiler settings remain unknown.')
312
+ }
313
+ }
314
+ const settings = Object.fromEntries(
315
+ [
316
+ 'SWIFT_VERSION',
317
+ 'SWIFT_ACTIVE_COMPILATION_CONDITIONS',
318
+ 'OTHER_SWIFT_FLAGS',
319
+ 'SWIFT_DEFAULT_ACTOR_ISOLATION',
320
+ 'SWIFT_OBJC_BRIDGING_HEADER',
321
+ 'SWIFT_OBJC_INTEROP_MODE',
322
+ 'SWIFT_CXX_INTEROP_MODE',
323
+ 'GCC_PREPROCESSOR_DEFINITIONS',
324
+ 'ALWAYS_SEARCH_USER_PATHS',
325
+ 'SWIFT_ENABLE_EXPLICIT_MODULES',
326
+ 'SWIFT_STRICT_CONCURRENCY',
327
+ 'SWIFT_UPCOMING_FEATURES',
328
+ 'SWIFT_EXPERIMENTAL_FEATURES',
329
+ 'EXCLUDED_SOURCE_FILE_NAMES',
330
+ 'INCLUDED_SOURCE_FILE_NAMES',
331
+ 'SWIFT_INCLUDE_PATHS',
332
+ 'FRAMEWORK_SEARCH_PATHS',
333
+ 'HEADER_SEARCH_PATHS',
334
+ 'SYSTEM_HEADER_SEARCH_PATHS',
335
+ 'USER_HEADER_SEARCH_PATHS',
336
+ 'OTHER_LDFLAGS',
337
+ 'SDKROOT',
338
+ 'SUPPORTED_PLATFORMS',
339
+ 'ARCHS',
340
+ 'EXCLUDED_ARCHS',
341
+ 'IPHONEOS_DEPLOYMENT_TARGET',
342
+ 'PRODUCT_MODULE_NAME',
343
+ 'STRING_CATALOG_GENERATE_SYMBOLS',
344
+ 'COREML_CODEGEN_LANGUAGE',
345
+ 'VERSIONING_SYSTEM',
346
+ 'SWIFT_ENABLE_APP_EXTENSION',
347
+ 'APPLICATION_EXTENSION_API_ONLY',
348
+ ...swiftFeatureSettingKeys,
349
+ ...assetSymbolSettingKeys,
350
+ ].map((key) => [key, app.settings(key)]),
351
+ )
352
+ const packages = planLocalPackages(app, root, compile.files)
353
+ if (packages.status === 'unknown')
354
+ return unknown(
355
+ `${packages.reason} One unresolved import fails the typecheck of every file in the module, so no app sources are indexed.`,
356
+ )
357
+ const packageFiles = new Set(
358
+ packages.status === 'plan'
359
+ ? packages.plan.modules.flatMap((module) => module.files)
360
+ : [],
361
+ )
362
+ const bridging = planBridgingHeader(app, root, compile.files, settings)
363
+ if (bridging.status === 'unknown') return unknown(bridging.reason)
364
+ const unsupported = [
365
+ 'SWIFT_OBJC_INTEROP_MODE',
366
+ 'SWIFT_CXX_INTEROP_MODE',
367
+ 'SWIFT_UPCOMING_FEATURES',
368
+ 'SWIFT_EXPERIMENTAL_FEATURES',
369
+ 'EXCLUDED_SOURCE_FILE_NAMES',
370
+ 'INCLUDED_SOURCE_FILE_NAMES',
371
+ 'SWIFT_INCLUDE_PATHS',
372
+ 'FRAMEWORK_SEARCH_PATHS',
373
+ 'SYSTEM_HEADER_SEARCH_PATHS',
374
+ 'OTHER_LDFLAGS',
375
+ 'COREML_CODEGEN_LANGUAGE',
376
+ 'EXCLUDED_ARCHS',
377
+ 'SWIFT_ENABLE_APP_EXTENSION',
378
+ ].filter((key) => settings[key])
379
+ // header search settings are modeled only as the clang flags of a bridging header.
380
+ if (bridging.status === 'none')
381
+ unsupported.push(
382
+ ...['HEADER_SEARCH_PATHS', 'USER_HEADER_SEARCH_PATHS'].filter(
383
+ (key) => settings[key],
384
+ ),
385
+ )
386
+ const swiftKeys = new Set(
387
+ Object.values(objects)
388
+ .filter(isDict)
389
+ .flatMap((entry) =>
390
+ isDict(entry.buildSettings)
391
+ ? Object.keys(entry.buildSettings).map((key) => key.split('[')[0]!)
392
+ : [],
393
+ )
394
+ .filter((key) => key.startsWith('SWIFT_')),
395
+ )
396
+ // discover setting names only; the project owner still evaluates their values.
397
+ for (const { path } of metadata.filter(({ path }) => path.endsWith('.xcconfig')))
398
+ for (const [, key] of compile.files[path]!.matchAll(
399
+ /\b(SWIFT_[A-Z_0-9]+)(?:\[[^\]]*\])*\s*=/g,
400
+ ))
401
+ swiftKeys.add(key!)
402
+ const buildOnlySettings = new Set([
403
+ 'SWIFT_COMPILATION_MODE',
404
+ 'SWIFT_OPTIMIZATION_LEVEL',
405
+ 'SWIFT_EMIT_LOC_STRINGS',
406
+ 'SWIFT_INSTALL_OBJC_HEADER',
407
+ 'SWIFT_PRECOMPILE_BRIDGING_HEADER',
408
+ 'SWIFT_OBJC_INTERFACE_HEADER_NAME',
409
+ ])
410
+ for (const key of swiftKeys) {
411
+ const value = app.settings(key)
412
+ if (value && !Object.hasOwn(settings, key) && !buildOnlySettings.has(key))
413
+ unsupported.push(key)
414
+ settings[key] = value
415
+ }
416
+ if (unsupported.length)
417
+ return unknown(`Unsupported Xcode source configuration: ${unsupported.join(', ')}`)
418
+ if (!settings.SWIFT_VERSION)
419
+ return unknown('Xcode Swift language mode is unset; SWIFT_VERSION remains unknown.')
420
+ if (!/^(?:5|6)(?:\.0)?$/.test(settings.SWIFT_VERSION))
421
+ return unknown(`Unsupported Swift language mode: ${settings.SWIFT_VERSION}`)
422
+ if (
423
+ settings.SWIFT_DEFAULT_ACTOR_ISOLATION &&
424
+ settings.SWIFT_DEFAULT_ACTOR_ISOLATION !== 'MainActor' &&
425
+ settings.SWIFT_DEFAULT_ACTOR_ISOLATION !== 'nonisolated'
426
+ )
427
+ return unknown('Unsupported default actor isolation setting.')
428
+ if (
429
+ settings.APPLICATION_EXTENSION_API_ONLY === 'YES' ||
430
+ (settings.ARCHS && !settings.ARCHS.split(/\s+/).includes('arm64'))
431
+ )
432
+ return unknown('Unsupported Xcode extension or architecture configuration.')
433
+ if (
434
+ settings.SWIFT_STRICT_CONCURRENCY &&
435
+ !['minimal', 'targeted', 'complete'].includes(settings.SWIFT_STRICT_CONCURRENCY)
436
+ )
437
+ return unknown('Unsupported Xcode strict concurrency configuration.')
438
+ if (
439
+ settings.SWIFT_STRICT_CONCURRENCY &&
440
+ settings.SWIFT_STRICT_CONCURRENCY !== 'minimal'
441
+ )
442
+ return unknown('Nonminimal strict concurrency compiler flags remain unknown.')
443
+ if (
444
+ settings.OTHER_SWIFT_FLAGS!.replace(/(?:^|\s)-D\s*[A-Za-z_]\w*(?=\s|$)/g, '').trim()
445
+ )
446
+ return unknown(
447
+ 'Only compilation conditions in OTHER_SWIFT_FLAGS are supported; remaining flags are unknown.',
448
+ )
449
+ if (
450
+ (settings.SDKROOT && !['iphoneos', 'iphonesimulator'].includes(settings.SDKROOT)) ||
451
+ (settings.SUPPORTED_PLATFORMS &&
452
+ !settings.SUPPORTED_PLATFORMS.split(/\s+/).includes('iphonesimulator'))
453
+ )
454
+ return unknown(
455
+ 'Only the existing arm64 iOS simulator project configuration is supported.',
456
+ )
457
+ if (
458
+ app.resources.some((file) =>
459
+ /\.(?:xcdatamodeld|xcdatamodel|mlmodel|mlpackage|intentdefinition)(?:\/|$)/.test(
460
+ file,
461
+ ),
462
+ ) ||
463
+ settings.VERSIONING_SYSTEM === 'apple-generic'
464
+ )
465
+ return unknown('Generated model, intent and version sources remain unknown.')
466
+ const assets = planAssetSymbols(
467
+ app.resources.map((file) => relative(root, file)),
468
+ root,
469
+ settings,
470
+ )
471
+ if (assets.status === 'unknown') return unknown(assets.reason)
472
+ const strings = planStringSymbols(
473
+ app.resources.map((file) => relative(root, file)),
474
+ root,
475
+ settings,
476
+ )
477
+ if (strings.status === 'unknown') return unknown(strings.reason)
478
+ let bytes = 0
479
+ const sources = app.sources.map((file) => {
480
+ const path = relative(root, file)
481
+ if (path === '..' || path.startsWith(`..${sep}`) || isAbsolute(path))
482
+ throw new Error(`Target source escapes the selected root: ${file}`)
483
+ const content = readPackageFile(root, file, 4 * 1024 * 1024)
484
+ bytes += content.length
485
+ if (bytes > 32 * 1024 * 1024) throw new Error('Swift module exceeds 32 MiB')
486
+ if (compile.files[path] !== content.toString('utf8'))
487
+ throw new Error(
488
+ `Source is missing or differs from the original snapshot: ${path}`,
489
+ )
490
+ return path
491
+ })
492
+ if (!sources.length || sources.length > 2_000 || !sources.includes(compile.entry))
493
+ return unknown(
494
+ 'The compiler entry must belong to a target with 1 to 2000 original Swift sources.',
495
+ )
496
+ if (
497
+ Object.keys(compile.files).some(
498
+ (file) =>
499
+ file.endsWith('.swift') &&
500
+ !sources.includes(file) &&
501
+ !packageFiles.has(file) &&
502
+ basename(file) !== 'Package.swift',
503
+ )
504
+ )
505
+ return unknown(
506
+ 'The source snapshot includes Swift files outside the selected Xcode target.',
507
+ )
508
+ const features = swiftFeatureFlags(settings, app.languageMode)
509
+ if (!features.flags) return unknown(features.reason)
510
+ const flags = [
511
+ ...app.defines.flatMap((define) => ['-D', define]),
512
+ ...(app.mainActorIsolation ? ['-default-isolation', 'MainActor'] : []),
513
+ ...features.flags,
514
+ ]
515
+ const leg = (leg: SwiftSourceLeg): SwiftSourceLeg => ({
516
+ swiftc: leg.swiftc,
517
+ flags: [...leg.flags, ...flags],
518
+ })
519
+ const input: SwiftSourceInput = {
520
+ root,
521
+ moduleName: app.moduleName,
522
+ languageVersion: String(app.languageMode),
523
+ files: sources,
524
+ parseAsLibrary: !sources.some((file) => basename(file) === 'main.swift'),
525
+ ...(request.primaries ? { primaries: request.primaries } : {}),
526
+ indexdump: request.indexdump,
527
+ native: leg(request.native),
528
+ ...(request.peach ? { peach: leg(request.peach) } : {}),
529
+ }
530
+ return {
531
+ status: 'ready' as const,
532
+ input,
533
+ project: {
534
+ path: relative(root, project),
535
+ target: app.name,
536
+ targetId,
537
+ moduleName: app.moduleName,
538
+ entry: compile.entry,
539
+ configuration: app.configuration,
540
+ configurations,
541
+ sources,
542
+ allSources: app.allSources.map((file) => relative(root, file)),
543
+ settings,
544
+ defines: app.defines,
545
+ languageMode: app.languageMode,
546
+ mainActorIsolation: app.mainActorIsolation,
547
+ metadata,
548
+ assets: assets.status === 'plan' ? assets.plan : null,
549
+ strings: strings.status === 'plan' ? strings.plan : null,
550
+ bridging: bridging.status === 'plan' ? bridging.plan : null,
551
+ packages: packages.status === 'plan' ? packages.plan : null,
552
+ localPackages: app.localPackageDirs.map((dir) => relative(root, dir)),
553
+ linkedProducts: app.linkedProducts,
554
+ binaryFrameworks: app.binaryFrameworks,
555
+ owners: Object.fromEntries(
556
+ [
557
+ 'xcode-project.ts',
558
+ 'xcode-json-project.ts',
559
+ 'xcode-target-members.ts',
560
+ 'openstep-plist.ts',
561
+ 'swift-source-file.ts',
562
+ 'swift-coverage/xcode.ts',
563
+ ].map((file) => [file, swiftCoverageProvenance[file] ?? null]),
564
+ ),
565
+ },
566
+ unknowns: [
567
+ 'Membership and configuration come from the original Xcode target, using the existing arm64 iOS simulator reader. Schemes and other destinations are not evaluated.',
568
+ 'Asset symbols are generated with actool and string catalog symbols with xcstringstool. Local package products compile as modules the app imports. Bridging headers pass the target header maps, search paths and preprocessor definitions to clang. Script and build rule outputs, per-file flags, source filters, native peers and dependency modules are rejected. SDK and dependency artifact identities and native proof remain unknown.',
569
+ ],
570
+ }
571
+ } catch (error) {
572
+ return unknown(error instanceof Error ? error.message : String(error))
573
+ }
574
+ }
575
+
576
+ export async function indexSwiftXcodeApp(request: SwiftXcodeSourceInput) {
577
+ const resolution = swiftXcodeSourceInput(request)
578
+ if (resolution.status === 'unknown') return resolution
579
+ try {
580
+ const work = mkdtempSync(join(tmpdir(), 'peach-swift-assets-'))
581
+ let index
582
+ try {
583
+ const bridging = resolution.project.bridging
584
+ ? bridgingFlags(resolution.project.bridging, realpathSync(request.root), work)
585
+ : []
586
+ // package modules build with the caller's flags alone, once per compiler leg
587
+ const packageModules = (leg: SwiftSourceLeg, name: string) =>
588
+ resolution.project.packages
589
+ ? buildLocalPackageModules(
590
+ resolution.project.packages,
591
+ realpathSync(request.root),
592
+ join(work, name),
593
+ leg,
594
+ )
595
+ : []
596
+ const withExtras = (
597
+ leg: SwiftSourceLeg,
598
+ requested: SwiftSourceLeg,
599
+ name: string,
600
+ ) => ({
601
+ ...leg,
602
+ flags: [...leg.flags, ...bridging, ...packageModules(requested, name)],
603
+ })
604
+ index = await indexSwiftApp({
605
+ ...resolution.input,
606
+ native: withExtras(resolution.input.native, request.native, 'native'),
607
+ ...(resolution.input.peach && request.peach
608
+ ? { peach: withExtras(resolution.input.peach, request.peach, 'peach') }
609
+ : {}),
610
+ generated: [
611
+ ...(resolution.project.assets
612
+ ? [
613
+ generateAssetSymbols(
614
+ resolution.project.assets,
615
+ realpathSync(request.root),
616
+ work,
617
+ ),
618
+ ]
619
+ : []),
620
+ ...(resolution.project.strings
621
+ ? generateStringSymbols(
622
+ resolution.project.strings,
623
+ realpathSync(request.root),
624
+ work,
625
+ )
626
+ : []),
627
+ ],
628
+ })
629
+ } finally {
630
+ rmSync(work, { recursive: true, force: true })
631
+ }
632
+ const after = swiftXcodeSourceInput(request)
633
+ if (
634
+ after.status === 'unknown' ||
635
+ JSON.stringify([after.project, after.input.files]) !==
636
+ JSON.stringify([resolution.project, resolution.input.files])
637
+ )
638
+ return {
639
+ status: 'unknown' as const,
640
+ reasons: [
641
+ 'Xcode membership or configuration changed while indexing; refusing mixed provenance.',
642
+ ],
643
+ }
644
+ return {
645
+ status: 'indexed' as const,
646
+ project: resolution.project,
647
+ unknowns: resolution.unknowns,
648
+ index,
649
+ }
650
+ } catch (error) {
651
+ return {
652
+ status: 'unknown' as const,
653
+ reasons: [error instanceof Error ? error.message : String(error)],
654
+ }
655
+ }
656
+ }
@@ -1,10 +1,10 @@
1
1
  {
2
- "id": "ca4dfda0ca14bc49",
2
+ "id": "433f607a19978269",
3
3
  "release": "swift-6.4.0-RELEASE-custom-0d775d32d7c74eae",
4
4
  "wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-f02bd198",
5
5
  "wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-f02bd198.artifactbundle.tar.gz",
6
6
  "wasmSdkChecksum": "1e19ea768fd4e821aae34b8966c4ddcee45615c4b3cf018979b061aee2fb5504",
7
- "source": "33e8641403dd73a7ce0ca902007e3a36407e1f0b",
7
+ "source": "f52d21b43f5cba9bd52f1665697284e46d16c0d9",
8
8
  "targets": [
9
9
  "ImagePlayground",
10
10
  "QuickLookThumbnailing",
@@ -193,16 +193,16 @@
193
193
  },
194
194
  "hosts": {
195
195
  "darwin-arm64": {
196
- "sha256": "8679052c4c2b21ad748a8db40cdbc0c91ab14a29fc06bbed777efb57030c01fa",
197
- "size": 70963039
196
+ "sha256": "0b814aa2ced56e4452c82227c4251036346015ba6445e742070ee221c53fc575",
197
+ "size": 71080069
198
198
  },
199
199
  "linux-x64": {
200
- "sha256": "a1719d844e2f45e8c9a2ccb9dbe7857978918639a3933c225a328d84cae235cf",
201
- "size": 70968746
200
+ "sha256": "62e67740951c7972fde15bc074fe8838f308432a8521e93691035e7fc105b716",
201
+ "size": 71085950
202
202
  },
203
203
  "linux-arm64": {
204
- "sha256": "3da8f2c920e65c633b5310c778b4a5c54b0f5f8278d58fd109f3db4310794c04",
205
- "size": 70967077
204
+ "sha256": "f900ab5b6a4823966cebe291c91710e6323185df971c667c25ddcc1427935b52",
205
+ "size": 71084016
206
206
  }
207
207
  }
208
208
  }