peachsim 0.1.1716 → 0.1.1728

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 (234) hide show
  1. package/README.md +21 -3
  2. package/cli/app-bundle-resources.ts +2 -1
  3. package/cli/app-fonts.ts +4 -4
  4. package/cli/app-splash.ts +4 -4
  5. package/cli/app-stubs.ts +17 -0
  6. package/cli/command-registry.ts +1 -0
  7. package/cli/commands/control.ts +82 -822
  8. package/cli/commands/daemon.ts +8 -0
  9. package/cli/commands/detox.ts +3 -0
  10. package/cli/commands/doctor.ts +19 -2
  11. package/cli/commands/inspect/actions.ts +74 -14
  12. package/cli/commands/inspect/core.ts +5 -1
  13. package/cli/commands/inspect/settling.ts +5 -2
  14. package/cli/commands/inspect/wait-ready.ts +6 -0
  15. package/cli/commands/inspect.ts +48 -45
  16. package/cli/commands/kotlin.ts +12 -2
  17. package/cli/commands/package.ts +750 -0
  18. package/cli/commands/serve.ts +6 -0
  19. package/cli/commands/shell-url.ts +834 -0
  20. package/cli/commands/swift.ts +42 -102
  21. package/cli/commands/test.ts +20 -0
  22. package/cli/commands/upload.ts +1 -1
  23. package/cli/device-option.ts +1 -1
  24. package/cli/main.ts +13 -1
  25. package/cli/native-input.ts +199 -0
  26. package/cli/outbound-endpoints.ts +26 -1
  27. package/cli/packaged-app-launcher.ts +95 -0
  28. package/cli/scene-video.ts +13 -6
  29. package/detox/index.ts +187 -23
  30. package/dist-lib/agent-daemon-client.cjs +1 -1
  31. package/dist-lib/agent-events.cjs +1 -1
  32. package/dist-lib/attached-projects.cjs +1 -1
  33. package/dist-lib/auth/shared-session.cjs +1 -1
  34. package/dist-lib/backend-origin.cjs +1 -1
  35. package/dist-lib/beta.cjs +1 -1
  36. package/dist-lib/beta.mjs +1 -1
  37. package/dist-lib/bridge-constants.cjs +1 -1
  38. package/dist-lib/bridge-contract-input.cjs +1 -1
  39. package/dist-lib/bridge-contract-input.mjs +1 -1
  40. package/dist-lib/bridge-contract.cjs +1 -1
  41. package/dist-lib/bridge-contract.mjs +1 -1
  42. package/dist-lib/bundle-channel.cjs +38000 -31658
  43. package/dist-lib/capture-contract.cjs +1 -1
  44. package/dist-lib/capture-contract.mjs +1 -1
  45. package/dist-lib/cloud-contract.cjs +1 -1
  46. package/dist-lib/cloud-contract.mjs +1 -1
  47. package/dist-lib/cloud-test-args.cjs +1 -1
  48. package/dist-lib/cloud-test-args.mjs +1 -1
  49. package/dist-lib/cloud.cjs +1 -1
  50. package/dist-lib/cloud.mjs +1 -1
  51. package/dist-lib/config.cjs +1 -1
  52. package/dist-lib/config.mjs +1 -1
  53. package/dist-lib/detox/index.cjs +184 -60
  54. package/dist-lib/dev-bundle-resolution.cjs +14 -13
  55. package/dist-lib/expo-swift-bundle.cjs +18199 -11834
  56. package/dist-lib/expo-swift-metadata.cjs +4 -1
  57. package/dist-lib/expo-swift-metadata.mjs +3 -1
  58. package/dist-lib/home-paths.cjs +21 -2
  59. package/dist-lib/host/bridge-host.cjs +26509 -23850
  60. package/dist-lib/host/fetch-proxy-handler.cjs +221 -222
  61. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  62. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  63. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  64. package/dist-lib/host/websocket-proxy.cjs +1 -1
  65. package/dist-lib/index.cjs +876 -389
  66. package/dist-lib/jump-to-source-babel.cjs +1 -1
  67. package/dist-lib/jump-to-source-native.cjs +1 -1
  68. package/dist-lib/kotlin-host.cjs +127 -16
  69. package/dist-lib/menu.cjs +7 -1
  70. package/dist-lib/menu.mjs +7 -1
  71. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  72. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  73. package/dist-lib/metro-production-bundle.cjs +1 -1
  74. package/dist-lib/metro-production-bundle.mjs +1 -1
  75. package/dist-lib/metro.cjs +883 -404
  76. package/dist-lib/native-app-identity-project.cjs +694 -280
  77. package/dist-lib/native-app-identity-project.mjs +490 -83
  78. package/dist-lib/native-app-identity.cjs +13 -2
  79. package/dist-lib/native-app-identity.mjs +13 -2
  80. package/dist-lib/native-firebase-metadata.cjs +1 -1
  81. package/dist-lib/native-firebase-metadata.mjs +1 -1
  82. package/dist-lib/plist.cjs +1 -1
  83. package/dist-lib/plist.mjs +1 -1
  84. package/dist-lib/profiles.cjs +1 -1
  85. package/dist-lib/public-brand.cjs +1 -1
  86. package/dist-lib/public-origins-lib-esm.json +28 -23
  87. package/dist-lib/public-origins-lib.json +392 -224
  88. package/dist-lib/react-native-host-modules.cjs +32 -2
  89. package/dist-lib/react-native-host-modules.mjs +32 -2
  90. package/dist-lib/reap-browser.cjs +12 -4
  91. package/dist-lib/scripts/dev-server-scanner.cjs +15 -8
  92. package/dist-lib/sdk.cjs +17 -7
  93. package/dist-lib/sdk.mjs +16 -7
  94. package/dist-lib/skills.cjs +61838 -47851
  95. package/dist-lib/swift-compile.cjs +583 -360
  96. package/dist-lib/swift-compile.mjs +496 -275
  97. package/dist-lib/swift-package.cjs +1 -1
  98. package/dist-lib/swift-package.mjs +1 -1
  99. package/dist-lib/swift-submit.cjs +2 -2
  100. package/dist-lib/swift-submit.mjs +2 -2
  101. package/dist-lib/swift-toolchain.cjs +105 -17
  102. package/dist-lib/swift.cjs +1 -1
  103. package/dist-lib/vite-swift.cjs +4453 -2231
  104. package/dist-lib/vite.cjs +230 -228
  105. package/dist-lib/worklet-executable.cjs +1 -1
  106. package/dist-lib/worklet-executable.mjs +1 -1
  107. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +17 -8
  108. package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +1 -0
  109. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +7 -5
  110. package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +3 -1
  111. package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -11
  112. package/dist-types/packages/peach-engine/src/engine/types.d.ts +3 -0
  113. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +9 -0
  114. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
  115. package/dist-types/packages/peach-engine/src/render-worker/native-ui-commandContract.d.ts +1 -1
  116. package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +4 -0
  117. package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +1 -1
  118. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +23 -1
  119. package/dist-types/packages/peach-engine/src/shell-events.d.ts +1 -0
  120. package/dist-types/packages/peach-globals/src/audioBridgeContract.d.ts +5 -0
  121. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  122. package/dist-types/packages/peach-globals/src/keyboardBridgeContract.d.ts +11 -0
  123. package/dist-types/packages/peach-globals/src/shellBridgeContract.d.ts +1 -0
  124. package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +9 -2
  125. package/package.json +1 -1
  126. package/runtime-companion.json +1 -1
  127. package/scripts/dev-server-scanner.ts +12 -25
  128. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASFoundation.h +52 -0
  129. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSession.h +128 -0
  130. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSessionCallback.h +35 -0
  131. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/AuthenticationServices.h +3 -0
  132. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Modules/module.modulemap +5 -0
  133. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHTTPMessage.h +724 -0
  134. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +4 -0
  135. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkDefs.h +27 -0
  136. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Modules/module.modulemap +5 -0
  137. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h +1301 -0
  138. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +2 -0
  139. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +21 -50
  140. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +6 -6
  141. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +75 -9
  142. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +12 -0
  143. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIInterface.h +23 -0
  144. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +7 -9
  145. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIOrientation.h +14 -0
  146. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIStringDrawing.h +12 -0
  147. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIView.h +14 -0
  148. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewAnimating.h +12 -0
  149. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewController.h +16 -0
  150. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIWindow.h +2 -0
  151. package/sdk/ios/usr/include/ConditionalMacros.h +619 -0
  152. package/sdk/ios/usr/include/module.modulemap +1 -0
  153. package/sdk/ios/usr/include/objc/objc-sync.h +59 -0
  154. package/sdk/ios/usr/include/os.modulemap +5 -0
  155. package/sdk/ios/usr/include/sys/cdefs.h +5 -0
  156. package/sdk/ios/usr/include/sys/ioccom.h +99 -0
  157. package/sdk/ios/usr/include/sys/syslog.h +236 -0
  158. package/sdk/ios/usr/include/syslog.h +24 -0
  159. package/sdk/ios/wasm/include/fcntl.h +4 -2
  160. package/sdk/ios/wasm/include/stdio.h +24 -0
  161. package/sdk/ios/wasm/include/stdlib.h +32 -7
  162. package/sdk/ios/wasm/include/sys/file.h +7 -0
  163. package/sdk/ios/wasm/include/sys/ioctl.h +6 -0
  164. package/sdk/ios/wasm/include/sys/syscall.h +9 -0
  165. package/sdk/ios/wasm/include/sys/time.h +10 -0
  166. package/sdk/ios/wasm/include/unistd.h +12 -3
  167. package/sdk/native-hashes.json +1 -0
  168. package/skills/contrast/SKILL.md +2 -1
  169. package/skills/peach-test/SKILL.md +7 -3
  170. package/src/admitted-mac-build.ts +3 -0
  171. package/src/android-app-identity.ts +18 -0
  172. package/src/android-root-module.ts +9 -9
  173. package/src/appPackageContract.ts +81 -0
  174. package/src/bridge-contract.ts +50 -0
  175. package/src/bundle-channel.mjs +21 -4
  176. package/src/dev-bundle-resolution.ts +7 -27
  177. package/src/dom-source-reference.ts +15 -0
  178. package/src/expo-discovery-cache.ts +127 -23
  179. package/src/expo-manifest-body.ts +33 -0
  180. package/src/expo-native-workspace.ts +38 -13
  181. package/src/expo-swift-host.ts +264 -62
  182. package/src/expoSwiftContract.ts +3 -0
  183. package/src/generated/swift-c-predefines.json +1 -1
  184. package/src/home-paths.ts +35 -1
  185. package/src/host/app-package-handler.ts +47 -0
  186. package/src/host/bridge-host.ts +3 -0
  187. package/src/host/staged-host-files.ts +18 -0
  188. package/src/index.ts +3 -0
  189. package/src/kotlin-host.ts +21 -18
  190. package/src/kotlin-instance-source.ts +126 -0
  191. package/src/menu.ts +7 -0
  192. package/src/native-app-identity-project.ts +7 -2
  193. package/src/native-app-identity.ts +11 -0
  194. package/src/native-firebase-config.ts +24 -1
  195. package/src/nitro-adapter.lock.json +268 -268
  196. package/src/nitro-bundle.ts +8 -0
  197. package/src/nitro-compile.ts +35 -9
  198. package/src/nitro-dependencies.ts +21 -19
  199. package/src/nitro-source.ts +4 -0
  200. package/src/nitroContract.ts +7 -0
  201. package/src/react-native-bridge-modules.ts +68 -42
  202. package/src/react-native-host-modules.ts +31 -1
  203. package/src/reactNativeConfigurationContract.ts +14 -0
  204. package/src/reap-browser.ts +15 -3
  205. package/src/sdk.ts +5 -0
  206. package/src/settingsContract.ts +27 -1
  207. package/src/sim-client.ts +4 -1
  208. package/src/storageSnapshotContract.ts +3 -0
  209. package/src/swift-compile.ts +221 -41
  210. package/src/swift-coverage/provenance.ts +1 -0
  211. package/src/swift-coverage/xcode-asset-symbols.ts +922 -0
  212. package/src/swift-coverage/xcode-assets.ts +89 -131
  213. package/src/swift-coverage/xcode.ts +1 -1
  214. package/src/swift-cxx-reachable.ts +2 -1
  215. package/src/swift-distribution.lock.json +14 -13
  216. package/src/swift-host.ts +95 -22
  217. package/src/swift-icu.ts +1 -1
  218. package/src/swift-link-roots.ts +118 -0
  219. package/src/swift-objc-compile.ts +144 -22
  220. package/src/swift-objc-import.ts +6 -0
  221. package/src/swift-objc-standin.ts +2 -14
  222. package/src/swift-package-manifest.ts +14 -6
  223. package/src/swift-packages.ts +75 -11
  224. package/src/swift-pdf-raster.ts +1 -0
  225. package/src/swift-root-lock.ts +17 -1
  226. package/src/swift-source-pods.ts +2 -10
  227. package/src/swift-standin-emit.ts +592 -57
  228. package/src/swift-standins.ts +430 -49
  229. package/src/swift-submit.ts +3 -1
  230. package/src/swift-toolchain.ts +140 -17
  231. package/src/turbo-codegen-intake.ts +91 -0
  232. package/src/vite-plugin-one.ts +13 -9
  233. package/src/vite-plugin.ts +28 -15
  234. package/src/xcode-project.ts +223 -22
@@ -4,6 +4,7 @@ import fs from 'node:fs'
4
4
  import path from 'node:path'
5
5
  import { cacheDir } from './home-paths'
6
6
  import { isRecord } from './is-record'
7
+ import { DOUBLE_CONVERSION_WASM32_BACKPORT } from './nitro-dependencies'
7
8
  import {
8
9
  swiftSdkPaths,
9
10
  swiftModuleSdk,
@@ -11,6 +12,7 @@ import {
11
12
  swiftPeachModules,
12
13
  } from './swift-compile'
13
14
  import { swiftModuleToolchain } from './swift-distribution'
15
+ import { swiftClangImporterFlags } from './swift-objc-import'
14
16
  import { swiftObjCRuntimeFlags } from './swift-objc-runtime'
15
17
  import { iosDeploymentMinimum, objcSdkIntakeFlags } from './swift-objc-standin'
16
18
  import {
@@ -109,6 +111,8 @@ export function xcodeObjCInputs(
109
111
  ) {
110
112
  const sources = new Map<string, Buffer>()
111
113
  const links: Record<string, string> = {}
114
+ const derivations: Record<string, { upstreamCommit: string; originalSha256: string }> =
115
+ {}
112
116
  const checkouts = remoteSwiftCheckouts(app.rootDir)
113
117
  const generated = new Map(
114
118
  products?.files.map(({ path: declared, file }) => [declared, file]),
@@ -135,14 +139,31 @@ export function xcodeObjCInputs(
135
139
  if (sources.has(file)) return
136
140
  const resolved = header ? fs.realpathSync.native(file) : file
137
141
  if (resolved !== file) links[file] = resolved
138
- sources.set(
139
- file,
140
- readPackageFile(
141
- file.startsWith(`${checkouts}${path.sep}`) ? checkouts : app.rootDir,
142
- resolved,
143
- Infinity,
144
- ),
142
+ const bytes = readPackageFile(
143
+ file.startsWith(`${checkouts}${path.sep}`) ? checkouts : app.rootDir,
144
+ resolved,
145
+ Infinity,
146
+ )
147
+ // the pod's own double-conversion utils.h takes the approved backport by
148
+ // its exact original bytes; the file on disk stays unchanged.
149
+ const backport = DOUBLE_CONVERSION_WASM32_BACKPORT
150
+ if (
151
+ path.basename(file) !== 'utils.h' ||
152
+ createHash('sha256').update(bytes).digest('hex') !== backport.originalSha256
153
+ ) {
154
+ sources.set(file, bytes)
155
+ return
156
+ }
157
+ const derived = Buffer.from(
158
+ bytes.toString('utf8').replace(backport.before, backport.after),
145
159
  )
160
+ if (createHash('sha256').update(derived).digest('hex') !== backport.derivedSha256)
161
+ throw new Error(`DoubleConversion backport derived source differs: ${file}`)
162
+ sources.set(file, derived)
163
+ derivations[file] = {
164
+ upstreamCommit: backport.upstreamCommit,
165
+ originalSha256: backport.originalSha256,
166
+ }
146
167
  }
147
168
  const walked = new Map<string, boolean>()
148
169
  const ancestors = new Set<string>()
@@ -271,7 +292,12 @@ export function xcodeObjCInputs(
271
292
  }
272
293
  // xcode searches the frameworks of the package binary targets the app links
273
294
  const binarySearch = binaries
274
- .filter((binary) => binary.reached && binary.publicHeaders === undefined)
295
+ .filter(
296
+ (binary) =>
297
+ binary.reached &&
298
+ binary.publicHeaders === undefined &&
299
+ binary.placeholder === undefined,
300
+ )
275
301
  .map((binary) => binaryHeaderSearchPaths(binary, checkouts))
276
302
  const binaryFrameworks = binarySearch.flatMap((search) => search.frameworks)
277
303
  const binaryHeaders = binarySearch.flatMap((search) => search.headers)
@@ -287,6 +313,40 @@ export function xcodeObjCInputs(
287
313
  add(file, !file.endsWith('.swift'))
288
314
  }
289
315
  if (!target.objc) continue
316
+ // a framework consumer resolves its dependency's module through the
317
+ // published framework layout, so the overlay publishes the extended
318
+ // compatibility map and the generated interface header instead of the
319
+ // unextended originals: with the originals the Swift submodule never
320
+ // attaches and the consumer fails on undeclared identifiers.
321
+ const compatibility = target.swift?.compatibility
322
+ let productHeaders = target.objc.productHeaders
323
+ if (
324
+ compatibility?.framework &&
325
+ generated.has(compatibility.outputModuleMap) &&
326
+ generated.has(compatibility.outputHeader)
327
+ ) {
328
+ let umbrellaDir: string | undefined
329
+ let frameworkDir: string | undefined
330
+ const rewritten: Record<string, string> = {}
331
+ for (const [product, file] of Object.entries(productHeaders)) {
332
+ if (
333
+ file === compatibility.moduleMap &&
334
+ product.endsWith(`${path.sep}Modules${path.sep}module.modulemap`)
335
+ ) {
336
+ rewritten[product] = compatibility.outputModuleMap
337
+ frameworkDir ??= path.dirname(path.dirname(product))
338
+ } else {
339
+ rewritten[product] = file
340
+ if (file === compatibility.umbrella) umbrellaDir ??= path.dirname(product)
341
+ }
342
+ }
343
+ const headersDir =
344
+ umbrellaDir ?? (frameworkDir ? path.join(frameworkDir, 'Headers') : undefined)
345
+ if (headersDir)
346
+ rewritten[path.join(headersDir, path.basename(compatibility.outputHeader))] =
347
+ compatibility.outputHeader
348
+ productHeaders = rewritten
349
+ }
290
350
  const frameworkSearchPaths = [
291
351
  ...target.objc.frameworkSearchPaths,
292
352
  ...binaryFrameworks,
@@ -300,7 +360,7 @@ export function xcodeObjCInputs(
300
360
  ...[target.objc.prefixHeader, target.objc.bridgingHeader].filter(
301
361
  (file): file is string => file !== null,
302
362
  ),
303
- ...Object.values(target.objc.productHeaders),
363
+ ...Object.values(productHeaders),
304
364
  ...target.objc.headerMaps.flatMap((map) =>
305
365
  map.entries.flatMap(([, file]) =>
306
366
  path.isAbsolute(file) && fs.existsSync(file) ? [file] : [],
@@ -381,12 +441,12 @@ export function xcodeObjCInputs(
381
441
  prefix: target.objc.prefixHeader,
382
442
  fileFlags: target.objc.fileFlags,
383
443
  headerMaps: target.objc.headerMaps,
384
- productHeaders: target.objc.productHeaders,
444
+ productHeaders,
385
445
  moduleMaps: linkedMaps,
386
446
  })
387
447
  }
388
448
  for (const file of generated.keys()) add(file)
389
- return { sources, links, targets }
449
+ return { sources, links, derivations, targets }
390
450
  }
391
451
 
392
452
  /** builds dependency Swift before its generated compatibility headers are consumed. */
@@ -442,7 +502,7 @@ export function prepareXcodeSwiftProducts(
442
502
  frontendFlags.push(flag === '-Xfrontend' ? options[++index]! : flag)
443
503
  }
444
504
  const identity = {
445
- version: 2,
505
+ version: 3,
446
506
  sdk: swiftModuleSdk(moduleRoot),
447
507
  distribution: swiftModuleDigest(moduleRoot).toString('hex'),
448
508
  compiler: digest(fs.readFileSync(frontend)),
@@ -578,6 +638,7 @@ export function prepareXcodeSwiftProducts(
578
638
  const compatibility = target.swift!.compatibility!
579
639
  const outputMap = local(compatibility.outputModuleMap)
580
640
  const outputHeader = local(compatibility.outputHeader)
641
+ let ownMap = local(compatibility.moduleMap)
581
642
  const outputModule = path.join(
582
643
  preparation.modules,
583
644
  `${target.moduleName}.swiftmodule`,
@@ -586,6 +647,33 @@ export function prepareXcodeSwiftProducts(
586
647
  fs.mkdirSync(path.dirname(outputHeader), { recursive: true })
587
648
  fs.copyFileSync(local(compatibility.moduleMap), outputMap)
588
649
  fs.copyFileSync(local(compatibility.umbrella), local(compatibility.outputUmbrella))
650
+ // a framework module resolves its umbrella against the framework's
651
+ // Headers/, as xcode's product layout provides; the staged original
652
+ // sits in source layout, so the own compile reads a framework-layout
653
+ // view of the same unextended bytes.
654
+ const provider = providers.get(target.moduleName)
655
+ if (compatibility.framework && !provider) {
656
+ const viewModules = path.join(
657
+ work,
658
+ 'frameworks',
659
+ `${target.moduleName}.framework`,
660
+ 'Modules',
661
+ 'module.modulemap',
662
+ )
663
+ const viewHeaders = path.join(
664
+ work,
665
+ 'frameworks',
666
+ `${target.moduleName}.framework`,
667
+ 'Headers',
668
+ path.basename(compatibility.umbrella),
669
+ )
670
+ fs.mkdirSync(path.dirname(viewModules), { recursive: true })
671
+ fs.mkdirSync(path.dirname(viewHeaders), { recursive: true })
672
+ fs.copyFileSync(ownMap, viewModules)
673
+ fs.copyFileSync(local(compatibility.umbrella), viewHeaders)
674
+ generated.push(viewModules, viewHeaders)
675
+ ownMap = viewModules
676
+ }
589
677
  const minimum = iosDeploymentMinimum(target.iosDeploymentTarget)
590
678
  if (minimum === undefined)
591
679
  throw new Error(
@@ -605,9 +693,8 @@ export function prepareXcodeSwiftProducts(
605
693
  '-F',
606
694
  remap(file),
607
695
  ]),
608
- ...(target.objc?.flags ?? []).map(remap),
696
+ ...swiftClangImporterFlags(target.objc?.flags ?? []).map(remap),
609
697
  ]
610
- const provider = providers.get(target.moduleName)
611
698
  const swiftFlags: string[] = []
612
699
  for (let index = 0; index < target.swift!.flags.length; index++) {
613
700
  const flag = target.swift!.flags[index]!
@@ -615,6 +702,18 @@ export function prepareXcodeSwiftProducts(
615
702
  remap(flag === '-Xfrontend' ? target.swift!.flags[++index]! : flag),
616
703
  )
617
704
  }
705
+ // a framework target carries no own-map flag; xcode resolves its
706
+ // underlying module through the unextended overlay instead. the staged
707
+ // original is that same unextended view, added exactly once.
708
+ const carriesOwnMap =
709
+ provider !== undefined ||
710
+ target.swift!.flags.some(
711
+ (flag) =>
712
+ flag.startsWith('-fmodule-map-file=') &&
713
+ fs.existsSync(flag.slice('-fmodule-map-file='.length)) &&
714
+ fs.realpathSync.native(flag.slice('-fmodule-map-file='.length)) ===
715
+ fs.realpathSync.native(compatibility.moduleMap),
716
+ )
618
717
  const args = [
619
718
  ...(provider
620
719
  ? ['-merge-modules', '-emit-module']
@@ -647,9 +746,12 @@ export function prepareXcodeSwiftProducts(
647
746
  ...(target.objc?.bridgingHeader
648
747
  ? ['-import-objc-header', local(target.objc.bridgingHeader)]
649
748
  : ['-import-underlying-module']),
650
- // the pod's own compile reads its genuine original map through
651
- // its remapped flags, as xcode runs it; the output copy below
652
- // serves consumers only, since two maps defining the module fail.
749
+ // the pod's own compile reads its genuine original map: static
750
+ // targets through their remapped flags, framework targets
751
+ // through the staged original, which is xcode's unextended view
752
+ // without the overlay. the output copy below serves consumers
753
+ // only, since two maps defining the module fail.
754
+ ...(carriesOwnMap ? [] : ['-Xcc', `-fmodule-map-file=${ownMap}`]),
653
755
  '-emit-module-path',
654
756
  outputModule,
655
757
  ...target.sources.map(local),
@@ -684,11 +786,15 @@ export function prepareXcodeSwiftProducts(
684
786
  throw new Error(
685
787
  `${target.moduleName}: Swift compatibility product compilation failed. ${fs.readFileSync(log, 'utf8')}\nInputs: ${preparation.receipt}`,
686
788
  )
687
- // preserve CocoaPods' public map and expose only the compiler's declarations.
789
+ // preserve the public map and expose only the compiler's
790
+ // declarations: CocoaPods' script shape for libraries, xcode's appended
791
+ // stanza shape for frameworks.
688
792
  const relativeHeader = path.relative(path.dirname(outputMap), outputHeader)
689
793
  fs.appendFileSync(
690
794
  outputMap,
691
- `\n\nmodule ${target.moduleName}.Swift {\n header ${JSON.stringify(relativeHeader)}\n requires objc\n}\n`,
795
+ compatibility.framework
796
+ ? `\n\nmodule ${target.moduleName}.Swift {\n header ${JSON.stringify(path.basename(outputHeader))}\n}\n`
797
+ : `\n\nmodule ${target.moduleName}.Swift {\n header ${JSON.stringify(relativeHeader)}\n requires objc\n}\n`,
692
798
  )
693
799
  generated.push(
694
800
  outputModule,
@@ -736,7 +842,11 @@ export function prepareXcodeObjCImplementations(
736
842
  const toolchain = swiftModuleToolchain(moduleRoot)
737
843
  const sdk = swiftSdkPaths(moduleRoot, toolchain.toolchainBin)
738
844
  const products = prepareXcodeSwiftProducts(app, binaries, moduleRoot)
739
- const { sources, links, targets } = xcodeObjCInputs(app, binaries, products)
845
+ const { sources, links, derivations, targets } = xcodeObjCInputs(
846
+ app,
847
+ binaries,
848
+ products,
849
+ )
740
850
  const checkouts = remoteSwiftCheckouts(app.rootDir)
741
851
  const digest = (bytes: Buffer | string) =>
742
852
  createHash('sha256').update(bytes).digest('hex')
@@ -748,7 +858,7 @@ export function prepareXcodeObjCImplementations(
748
858
  // records as a marker here; minimumFor still owns the failure below.
749
859
  const headers = path.join(sdk.sysroot, 'darwin')
750
860
  const identity = {
751
- version: 22,
861
+ version: 23,
752
862
  importer: STANDIN_SOURCE_DIGEST,
753
863
  intake: targets.map((target) => {
754
864
  const minimum = iosDeploymentMinimum(target.deploymentTarget)
@@ -762,6 +872,7 @@ export function prepareXcodeObjCImplementations(
762
872
  targets,
763
873
  inputs,
764
874
  links,
875
+ derivations,
765
876
  swiftProducts: products?.receipt,
766
877
  }
767
878
  const parent = path.join(cacheDir(), 'swift-objc-implementations')
@@ -1013,11 +1124,22 @@ export function prepareXcodeObjCImplementations(
1013
1124
  return `-fmodule-map-file=${staged(flag.slice('-fmodule-map-file='.length))}`
1014
1125
  return include ? `${include[1]}${staged(include[2]!)}` : flag
1015
1126
  })
1127
+ // xcode passes the cache path with -fmodules, and apple clang claims it
1128
+ // in a c++ unit whose modules are off; this clang reports it unused,
1129
+ // which -Werror turns into a failure.
1130
+ const modules =
1131
+ flags.includes('-fmodules') &&
1132
+ (!cxx ||
1133
+ flags.lastIndexOf('-fno-cxx-modules') <= flags.lastIndexOf('-fcxx-modules'))
1016
1134
  const args = [
1017
1135
  '--target=wasm32-unknown-wasip1',
1018
1136
  `--sysroot=${sdk.sysroot}`,
1019
1137
  '-fwasm-exceptions',
1020
1138
  '-fexceptions',
1139
+ // the backend lowers direct setjmp-family calls; -lsetjmp is already
1140
+ // linked. no-op for units without setjmp calls (byte-identical).
1141
+ '-mllvm',
1142
+ '-wasm-enable-sjlj',
1021
1143
  ...(objc ? [...swiftObjCRuntimeFlags, '-fobjc-exceptions'] : []),
1022
1144
  ...objcSdkIntakeFlags(headers, toolchain.toolchainBin, minimum),
1023
1145
  ...headerSearch.flags[index]!,
@@ -1025,7 +1147,7 @@ export function prepareXcodeObjCImplementations(
1025
1147
  ...target.frameworks.flatMap((framework) => ['-F', staged(framework)]),
1026
1148
  ...moduleMaps[index]!,
1027
1149
  `-fmodule-name=${swiftTargetModuleName(target.name)}`,
1028
- `-fmodules-cache-path=${path.join(work, 'module-cache')}`,
1150
+ ...(modules ? [`-fmodules-cache-path=${path.join(work, 'module-cache')}`] : []),
1029
1151
  ...flags,
1030
1152
  ...(target.prefix ? ['-include', staged(target.prefix)] : []),
1031
1153
  '-Os',
@@ -11,6 +11,12 @@ export const SWIFT_OBJC_INTEROP_FLAGS = [
11
11
  '-fblocks',
12
12
  ]
13
13
 
14
+ // swift's clang importer reads objective-c only under arc, as xcode's swift
15
+ // compile does; a target's CLANG_ENABLE_OBJC_ARC governs its own units only.
16
+ export function swiftClangImporterFlags(flags: readonly string[]): string[] {
17
+ return flags.filter((flag) => flag !== '-fobjc-arc' && flag !== '-fno-objc-arc')
18
+ }
19
+
14
20
  // swiftpm synthesizes a module map for public headers when the package provides
15
21
  // none. original xcode and package module maps retain their own contents.
16
22
  export function swiftObjCModuleMap(module: string, headers: readonly string[]): string {
@@ -273,20 +273,8 @@ function iosSdkEntries(): (readonly [string, string])[] {
273
273
  `// swift-interface-format-version: 1.0\n// swift-module-flags: -target ${IOS_SDK_TARGET} -enable-objc-interop -enable-library-evolution -module-name ${module}\n${text}`,
274
274
  ] as const,
275
275
  )
276
- // a headerless import dir carrying only the sdk's os module map, so an
277
- // explicit clang submodule a vendor interface names (such as os.log)
278
- // resolves the way the ios sdk resolves it. it holds no headers, so no
279
- // sdk header can shadow the sysroot, and a swift module of the same name
280
- // still answers a plain import. emitted here so the one atomic rename
281
- // owns everything under the sdk id.
282
- const osMap = IOS_SDK_HEADERS['usr/include/os.modulemap']
283
- if (osMap === undefined)
284
- throw new Error('sdk intake has no usr/include/os.modulemap for clang-import')
285
- const clangImport: (readonly [string, string])[] = [
286
- ['clang-import/module.modulemap', osMap],
287
- ]
288
- return [...Object.entries(IOS_SDK_HEADERS), ...overlays, ...clangImport].sort(
289
- ([a], [b]) => (a < b ? -1 : 1),
276
+ return [...Object.entries(IOS_SDK_HEADERS), ...overlays].sort(([a], [b]) =>
277
+ a < b ? -1 : 1,
290
278
  )
291
279
  }
292
280
 
@@ -158,6 +158,16 @@ function swiftCommand(): string {
158
158
  return path.join(swiftToolchainBin(lock.release), 'swift')
159
159
  }
160
160
 
161
+ function swiftPackageFailure(error: unknown): string {
162
+ if (!(error instanceof Error)) return String(error)
163
+ const stderr =
164
+ 'stderr' in error &&
165
+ (typeof error.stderr === 'string' || Buffer.isBuffer(error.stderr))
166
+ ? error.stderr.toString().trim()
167
+ : ''
168
+ return stderr || error.message
169
+ }
170
+
161
171
  const cacheDir = path.join(peachCacheDir(), 'swift-manifests')
162
172
  const evaluated = new Map<string, SwiftPackageManifest>()
163
173
 
@@ -215,10 +225,9 @@ function dump(dir: string): {
215
225
  },
216
226
  )
217
227
  } catch (error) {
218
- const stderr =
219
- error instanceof Error && 'stderr' in error ? String(error.stderr).trim() : ''
220
228
  throw new Error(
221
- `swiftpm could not evaluate ${path.join(dir, 'Package.swift')}${stderr ? `: ${stderr}` : ''}`,
229
+ `swiftpm could not evaluate ${path.join(dir, 'Package.swift')}: ${swiftPackageFailure(error)}`,
230
+ { cause: error },
222
231
  )
223
232
  }
224
233
  fs.mkdirSync(cacheDir, { recursive: true })
@@ -693,10 +702,9 @@ let package = Package(
693
702
  },
694
703
  )
695
704
  } catch (error) {
696
- const stderr =
697
- error instanceof Error && 'stderr' in error ? String(error.stderr).trim() : ''
698
705
  throw new Error(
699
- `swiftpm could not resolve ${clauses.length} package requirements${stderr ? `: ${stderr}` : ''}`,
706
+ `swiftpm could not resolve ${clauses.length} package requirements (${clauses.join(', ')}): ${swiftPackageFailure(error)}`,
707
+ { cause: error },
700
708
  )
701
709
  }
702
710
  const resolved = path.join(dir, 'Package.resolved')
@@ -110,8 +110,26 @@ export interface SwiftPackageBinary {
110
110
  clients?: string[]
111
111
  /** simulator library headers actually included by original C++ units. */
112
112
  cxxHeaders?: { roots: string[]; reached: string[]; flags: string[]; error?: string }
113
+ /** a swift target of a placeholder package: the compiler gap that forces
114
+ * it, its sources relative to dir, and the swiftc flags its settings give
115
+ * them. it stands in from its own sources' public interface. */
116
+ placeholder?: { gap: string; sources: string[]; flags: string[] }
113
117
  }
114
118
 
119
+ // sdks that send telemetry, by package identity, that peach's swift cannot
120
+ // compile yet, each with the compiler gap that forces it. their swift targets
121
+ // stand in from their own public interface with inert bodies, so an app's
122
+ // calls compile and run and nothing is sent. an entry goes once the real sdk
123
+ // compiles.
124
+ export const SWIFT_PLACEHOLDER_PACKAGES: ReadonlyMap<string, string> = new Map([
125
+ [
126
+ 'dd-sdk-ios',
127
+ "DatadogInternal's NetworkInstrumentation names URLSessionDataDelegate, URLSessionTaskDelegate and URLSessionTaskMetrics, which FoundationNetworking and the SDK's Objective-C Foundation headers both declare",
128
+ ],
129
+ ])
130
+ const placeholderPackage = (pkg: LoadedPackage) =>
131
+ SWIFT_PLACEHOLDER_PACKAGES.get(swiftPackageIdentity(pkg.manifest.dir))
132
+
115
133
  /** dependency checkouts belong to peach, isolated by the canonical app root. */
116
134
  export function remoteSwiftCheckouts(root: string): string {
117
135
  const key = createHash('sha256')
@@ -254,9 +272,17 @@ function resolvableSubmodulePaths(
254
272
  else entry.url = match[3]
255
273
  entries.set(match[1]!, entry)
256
274
  }
257
- return [...entries.values()]
275
+ const named = [...entries.values()]
258
276
  .filter((entry) => entry.path !== undefined && entry.url !== undefined)
259
277
  .map((entry) => entry.path!)
278
+ if (named.length === 0) return []
279
+ const gitlinks = new Set(
280
+ git(dir, 'ls-files', '--stage', '--', ...named)
281
+ .split('\n')
282
+ .filter((line) => line.startsWith('160000 '))
283
+ .map((line) => line.slice(line.indexOf('\t') + 1)),
284
+ )
285
+ return named.filter((submodule) => gitlinks.has(submodule))
260
286
  }
261
287
 
262
288
  // a shallow checkout of exactly the pinned revision, reused while HEAD is it.
@@ -334,10 +360,11 @@ function checkout(checkouts: string, identity: string, pin: Pin): string {
334
360
  // relative submodule urls resolve against origin, which a fetch-by-url
335
361
  // never configures, so the pinned location is named as origin and sync
336
362
  // repairs urls recorded against a missing origin before update checks out
337
- // the gitlink pins. only submodules naming both a path and a url resolve:
338
- // a stale gitlink without a .gitmodules entry (gifu's GifuDocs) stays an
339
- // empty dir xcode and swiftpm never initialize either, instead of failing
340
- // the whole fetch.
363
+ // the gitlink pins. only gitlinks the tree records whose .gitmodules entry
364
+ // names a url resolve, as swiftpm's bare `submodule update` selects them: a
365
+ // stale gitlink without a .gitmodules entry (gifu's GifuDocs) stays an empty
366
+ // dir, and a .gitmodules entry whose path the tree has no gitlink for
367
+ // (apollo-ios's docs/renderer) is skipped, instead of failing the fetch.
341
368
  let submoduleRelease = tryAcquireNumberedLock(`${dir}.lock`)
342
369
  while (!submoduleRelease) {
343
370
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 25)
@@ -548,14 +575,17 @@ export function resolveSwiftPackages(options: {
548
575
  const assembly = target.declaresWasiNativeSettings
549
576
  ? []
550
577
  : files.filter((file) => UNSUPPORTED_NATIVE.test(file))
578
+ const placeholder = placeholderPackage(pkg)
551
579
  const ownReason =
552
580
  target.type === 'binary'
553
581
  ? `${name} ${BINARY}${gap ? `; ${gap}` : ''}`
554
- : target.type !== 'regular' && target.type !== 'system'
555
- ? `${name} is a ${target.type} target`
556
- : assembly.length > 0
557
- ? `${name} is an assembly target with no wasm32 lowering: ${assembly.map((file) => path.relative(pkg.manifest.dir, file)).join(', ')}${gap ? `; ${gap}` : ''}`
558
- : null
582
+ : placeholder && gap
583
+ ? `${name} stands in as a placeholder (${placeholder}), and ${gap}`
584
+ : target.type !== 'regular' && target.type !== 'system'
585
+ ? `${name} is a ${target.type} target`
586
+ : assembly.length > 0
587
+ ? `${name} is an assembly target with no wasm32 lowering: ${assembly.map((file) => path.relative(pkg.manifest.dir, file)).join(', ')}${gap ? `; ${gap}` : ''}`
588
+ : null
559
589
  // every dependency resolves, so a failing one never hides the rest
560
590
  // of the closure from the compile or from the report
561
591
  const reasons = target.dependencies.map((dependency) => {
@@ -683,7 +713,39 @@ export function resolveSwiftPackages(options: {
683
713
  const objc =
684
714
  target.type === 'regular' && files.some((file) => /\.(m|mm)$/.test(file))
685
715
  const assembly = assemblySources(files, target)
686
- if (target.type === 'binary' || objc || assembly)
716
+ const gap = placeholderPackage(pkg)
717
+ const sources = files.filter((file) => file.endsWith('.swift'))
718
+ // swiftpm's release settings, as xcode builds a package for any
719
+ // configuration other than Debug
720
+ const release = (setting: SwiftManifestSetting) => setting.configuration !== 'debug'
721
+ if (gap && target.type === 'regular' && !objc && sources.length > 0)
722
+ result.binaries.push({
723
+ target: name,
724
+ source: pkg.source,
725
+ url: null,
726
+ checksum: null,
727
+ dir: pkg.manifest.dir,
728
+ reached: false,
729
+ placeholder: {
730
+ gap,
731
+ sources: sources.map((file) => path.relative(pkg.manifest.dir, file)),
732
+ flags: [
733
+ '-swift-version',
734
+ String(target.languageMode),
735
+ '-package-name',
736
+ swiftPackageIdentity(pkg.manifest.dir),
737
+ '-DSWIFT_PACKAGE',
738
+ ...target.defines.filter(release).flatMap(({ name }) => ['-D', name]),
739
+ ...target.experimentalFeatures
740
+ .filter(release)
741
+ .flatMap(({ name }) => ['-enable-experimental-feature', name]),
742
+ ...target.upcomingFeatures
743
+ .filter(release)
744
+ .flatMap(({ name }) => ['-enable-upcoming-feature', name]),
745
+ ],
746
+ },
747
+ })
748
+ else if (target.type === 'binary' || objc || assembly)
687
749
  result.binaries.push({
688
750
  target: name,
689
751
  source: pkg.source,
@@ -729,6 +791,8 @@ export function resolveSwiftPackages(options: {
729
791
  if (found.has(key)) return
730
792
  found.add(key)
731
793
  if (pkg.manifest.targets.get(name)?.type === 'macro') return
794
+ // a placeholder standing in needs none of what its sources import
795
+ if (provided.has(name) && placeholderPackage(pkg)) return
732
796
  for (const dependency of pkg.manifest.targets.get(name)?.dependencies ?? []) {
733
797
  if (dependency.kind === 'target') visit(pkg, dependency.name)
734
798
  else {
@@ -61,6 +61,7 @@ function rasterBinary(): string {
61
61
  )
62
62
  fs.writeFileSync(source, RASTER_SWIFT)
63
63
  try {
64
+ // runner-toolchain-platform: darwin
64
65
  execFileSync('xcrun', ['swiftc', '-o', binary, source], { stdio: 'pipe' })
65
66
  } finally {
66
67
  fs.rmSync(path.dirname(source), { recursive: true, force: true })
@@ -203,7 +203,21 @@ export async function withSwiftRootLock<T>(
203
203
  root: string,
204
204
  work: (lease: SwiftRootLease) => Promise<T>,
205
205
  signal?: AbortSignal,
206
- ): Promise<T> {
206
+ ): Promise<T>
207
+ /** with `wait: false` a root another process holds is skipped: `work` does not
208
+ * run and the result is undefined. */
209
+ export async function withSwiftRootLock<T>(
210
+ root: string,
211
+ work: (lease: SwiftRootLease) => Promise<T>,
212
+ signal: AbortSignal | undefined,
213
+ wait: false,
214
+ ): Promise<T | undefined>
215
+ export async function withSwiftRootLock<T>(
216
+ root: string,
217
+ work: (lease: SwiftRootLease) => Promise<T>,
218
+ signal?: AbortSignal,
219
+ wait = true,
220
+ ): Promise<T | undefined> {
207
221
  const directory = path.join(
208
222
  rnxHomeDir(),
209
223
  'cache',
@@ -223,11 +237,13 @@ export async function withSwiftRootLock<T>(
223
237
  if (current && !current.released) {
224
238
  const table = processTable()
225
239
  if (table.some((row) => !row.zombie && sameProcess(row, current.holder))) {
240
+ if (!wait) return undefined
226
241
  await pause(POLL_MS, signal)
227
242
  continue
228
243
  }
229
244
  const children = readChildren(directory, newest)
230
245
  if (children.some((child) => groupAlive(table, child))) {
246
+ if (!wait) return undefined
231
247
  await pause(POLL_MS, signal)
232
248
  continue
233
249
  }
@@ -341,16 +341,8 @@ export async function collectSwiftSourcePods(
341
341
  const root = openXcodeProject(workspace, APP, moduleRoot, 'Release')
342
342
  try {
343
343
  const input = compileInput(root, 'main.swift')
344
- if (
345
- Object.keys(input.images ?? {}).length > 0 ||
346
- Object.values(input.resources ?? {}).some((encoded) => {
347
- const bytes = Buffer.from(encoded, 'base64')
348
- return !Buffer.from(bytes.toString('utf8')).equals(bytes)
349
- })
350
- )
351
- throw new Error(
352
- `${work}: binary pod resources require original binary file transport`,
353
- )
344
+ if (Object.keys(input.images ?? {}).length > 0)
345
+ throw new Error(`${work}: pod image resources require original image transport`)
354
346
  const targets = swiftManifestTargets(input.files['Package.swift']!).filter(
355
347
  (target) => !target.executable,
356
348
  )