peachsim 0.1.1880 → 0.1.1886

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 (154) hide show
  1. package/cli/commands/control.ts +11 -10
  2. package/cli/commands/reset.ts +1 -1
  3. package/cli/outbound-endpoints.ts +1 -1
  4. package/detox/index.ts +62 -1
  5. package/dist-lib/agent-daemon-client.cjs +1 -1
  6. package/dist-lib/agent-events.cjs +1 -1
  7. package/dist-lib/attached-projects.cjs +1 -1
  8. package/dist-lib/auth/shared-session.cjs +1 -1
  9. package/dist-lib/backend-origin.cjs +1 -1
  10. package/dist-lib/beta.cjs +1 -1
  11. package/dist-lib/beta.mjs +1 -1
  12. package/dist-lib/bridge-constants.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.cjs +1 -1
  14. package/dist-lib/bridge-contract-input.mjs +1 -1
  15. package/dist-lib/bridge-contract.cjs +1 -1
  16. package/dist-lib/bridge-contract.mjs +1 -1
  17. package/dist-lib/bundle-channel.cjs +8980 -4279
  18. package/dist-lib/capture-contract.cjs +1 -1
  19. package/dist-lib/capture-contract.mjs +1 -1
  20. package/dist-lib/cloud-contract.cjs +1 -1
  21. package/dist-lib/cloud-contract.mjs +1 -1
  22. package/dist-lib/cloud-test-args.cjs +1 -1
  23. package/dist-lib/cloud-test-args.mjs +1 -1
  24. package/dist-lib/cloud.cjs +1 -1
  25. package/dist-lib/cloud.mjs +1 -1
  26. package/dist-lib/config.cjs +1 -1
  27. package/dist-lib/config.mjs +1 -1
  28. package/dist-lib/detox/index.cjs +35 -2
  29. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  30. package/dist-lib/expo-swift-bundle.cjs +8500 -3912
  31. package/dist-lib/expo-swift-metadata.cjs +5 -1
  32. package/dist-lib/expo-swift-metadata.mjs +5 -1
  33. package/dist-lib/home-paths.cjs +1 -1
  34. package/dist-lib/host/bridge-host.cjs +9744 -5071
  35. package/dist-lib/host/fetch-proxy-handler.cjs +93 -13
  36. package/dist-lib/host/fetch-proxy-overrides.cjs +10 -2
  37. package/dist-lib/host/fetch-proxy-overrides.mjs +8 -2
  38. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  39. package/dist-lib/host/websocket-proxy.cjs +1 -1
  40. package/dist-lib/index.cjs +525 -120
  41. package/dist-lib/jump-to-source-babel.cjs +1 -1
  42. package/dist-lib/jump-to-source-native.cjs +1 -1
  43. package/dist-lib/kotlin-host.cjs +1 -1
  44. package/dist-lib/menu.cjs +1 -1
  45. package/dist-lib/menu.mjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  47. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  48. package/dist-lib/metro-production-bundle.cjs +1 -1
  49. package/dist-lib/metro-production-bundle.mjs +1 -1
  50. package/dist-lib/metro.cjs +523 -118
  51. package/dist-lib/native-app-identity-project.cjs +395 -72
  52. package/dist-lib/native-app-identity-project.mjs +723 -375
  53. package/dist-lib/native-app-identity.cjs +37 -1
  54. package/dist-lib/native-app-identity.mjs +36 -1
  55. package/dist-lib/native-firebase-metadata.cjs +1 -1
  56. package/dist-lib/native-firebase-metadata.mjs +1 -1
  57. package/dist-lib/pdfium-raster.cjs +1 -1
  58. package/dist-lib/pdfium-raster.mjs +1 -1
  59. package/dist-lib/plist.cjs +1 -1
  60. package/dist-lib/plist.mjs +1 -1
  61. package/dist-lib/profiles.cjs +1 -1
  62. package/dist-lib/public-brand.cjs +1 -1
  63. package/dist-lib/public-origins-lib-esm.json +58 -28
  64. package/dist-lib/public-origins-lib.json +233 -92
  65. package/dist-lib/react-native-host-modules.cjs +1 -1
  66. package/dist-lib/react-native-host-modules.mjs +1 -1
  67. package/dist-lib/reap-browser.cjs +1 -1
  68. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  69. package/dist-lib/sdk.cjs +1 -1
  70. package/dist-lib/sdk.mjs +1 -1
  71. package/dist-lib/skills.cjs +30639 -25833
  72. package/dist-lib/swift-compile.cjs +6823 -2525
  73. package/dist-lib/swift-compile.mjs +6809 -2509
  74. package/dist-lib/swift-package.cjs +20 -3
  75. package/dist-lib/swift-package.mjs +20 -3
  76. package/dist-lib/swift-submit.cjs +2 -2
  77. package/dist-lib/swift-submit.mjs +2 -2
  78. package/dist-lib/swift-toolchain.cjs +19 -1
  79. package/dist-lib/swift.cjs +1 -1
  80. package/dist-lib/vite-swift.cjs +8704 -4124
  81. package/dist-lib/vite.cjs +93 -13
  82. package/dist-lib/worklet-executable.cjs +1 -1
  83. package/dist-lib/worklet-executable.mjs +1 -1
  84. package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -1
  85. package/dist-types/packages/peach-engine/src/engine/fontDataContract.d.ts +2 -0
  86. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
  87. package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +1 -0
  88. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +11 -1
  89. package/dist-types/packages/peach-engine/src/render-worker/shell-tree-wire.d.ts +2 -1
  90. package/dist-types/packages/peach-globals/src/nodeContract.d.ts +1 -0
  91. package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +10 -1
  92. package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
  93. package/dist-types/packages/peach-kit/src/ui/popover-placement.d.ts +1 -1
  94. package/dist-types/packages/sootsim-swift/src/securityHostContract.d.ts +10 -0
  95. package/package.json +1 -1
  96. package/runtime-companion.json +1 -1
  97. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHost.h +555 -0
  98. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +1 -0
  99. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +6 -0
  100. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSURLProtocol.h +0 -1
  101. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Modules/module.modulemap +6 -0
  102. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBarButtonItemBadge.h +1 -1
  103. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBarMinimization.h +1 -1
  104. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIScrollView.h +1 -1
  105. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISearchTab.h +1 -1
  106. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITab.h +1 -1
  107. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITabAccessory.h +2 -2
  108. package/sdk/ios/usr/include/os/activity.h +534 -0
  109. package/sdk/ios/usr/include/os.modulemap +15 -0
  110. package/sdk/ios/wasm/include/fcntl.h +16 -0
  111. package/sdk/ios/wasm/include/string.h +5 -0
  112. package/sdk/native-hashes.json +1 -1
  113. package/src/dns-over-https.ts +61 -9
  114. package/src/expo-swift-host.ts +11 -3
  115. package/src/host/fetch-proxy-handler.ts +51 -2
  116. package/src/host/fetch-proxy-overrides.ts +4 -0
  117. package/src/host/hostname-resolver.ts +9 -5
  118. package/src/native-app-identity-project.ts +13 -2
  119. package/src/native-app-identity.ts +47 -0
  120. package/src/nitro-adapter.lock.json +260 -260
  121. package/src/nitro-superset.lock.json +4 -4
  122. package/src/storageSnapshotContract.ts +20 -1
  123. package/src/swift-compile.ts +534 -136
  124. package/src/swift-compiler-digest.ts +15 -0
  125. package/src/swift-coverage/xcode-packages.ts +3 -2
  126. package/src/swift-distribution.lock.json +12 -12
  127. package/src/swift-guest-archive.ts +153 -0
  128. package/src/swift-guest-compile.ts +449 -0
  129. package/src/swift-guest-image-ledger.ts +656 -0
  130. package/src/swift-guest-link-plan.ts +52 -0
  131. package/src/swift-guest-link.ts +1414 -0
  132. package/src/swift-guest-linked-spans.ts +338 -0
  133. package/src/swift-guest-manifest.ts +141 -0
  134. package/src/swift-guest-projection-storage.ts +310 -0
  135. package/src/swift-guest-projection.ts +252 -0
  136. package/src/swift-guest-runtime-plan.ts +834 -0
  137. package/src/swift-guest-source-inputs.ts +427 -0
  138. package/src/swift-guest-source-plan.ts +279 -0
  139. package/src/swift-host.ts +125 -17
  140. package/src/swift-link-roots.ts +27 -50
  141. package/src/swift-package-manifest.ts +34 -18
  142. package/src/swift-package.ts +32 -2
  143. package/src/swift-packages.ts +138 -17
  144. package/src/swift-runtime-products.ts +73 -0
  145. package/src/swift-shared-sdk.ts +1 -1
  146. package/src/swift-submit.ts +13 -3
  147. package/src/swift-toolchain.ts +18 -0
  148. package/src/swift-wasm-prune.ts +313 -14
  149. package/src/swiftContract.ts +83 -0
  150. package/src/swiftRuntimeProductContract.ts +85 -45
  151. package/src/turbo-runtime.lock.json +23 -23
  152. package/src/turbo-source.ts +4 -1
  153. package/src/wasm-optimize.ts +16 -4
  154. package/src/xcode-project.ts +142 -14
@@ -12,6 +12,19 @@ export const swiftFrameworkProductSchema = v.object({
12
12
  linkage: v.picklist(['static', 'dynamic', 'automatic']),
13
13
  targets: v.array(v.string()),
14
14
  }),
15
+ // framework names are distinct from SDK library linkNames. they identify
16
+ // the packaged owner, not an observed native image dependency.
17
+ frameworkAliases: v.array(
18
+ v.object({
19
+ kind: v.literal('framework'),
20
+ name: v.string(),
21
+ targets: v.array(v.string()),
22
+ moduleMap: v.string(),
23
+ moduleMapSha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
24
+ wasmSdkId: v.string(),
25
+ wasmSdkChecksum: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
26
+ }),
27
+ ),
15
28
  targets: v.array(
16
29
  v.object({
17
30
  name: v.string(),
@@ -29,60 +42,78 @@ export type SwiftFrameworkProduct = v.InferOutput<typeof swiftFrameworkProductSc
29
42
  export const SWIFT_SDK_PRODUCT_FILE = 'runtime-products.json'
30
43
 
31
44
  /** producer facts; the consuming compiler resolves guest image scopes and build versions. */
32
- export const swiftSdkProductSchema = v.object({
33
- id: v.string(),
34
- installName: v.string(),
35
- target: v.literal('wasm32-unknown-wasip1'),
36
- linkNames: v.array(v.string()),
37
- buildDependencies: v.array(v.string()),
38
- linkDependencies: v.nullable(v.array(v.string())),
39
- autolink: v.array(v.string()),
40
- sources: v.array(
41
- v.object({
42
- path: v.string(),
43
- sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
44
- }),
45
- ),
46
- artifacts: v.array(
47
- v.variant('kind', [
45
+ export const swiftSdkProductSchema = v.pipe(
46
+ v.object({
47
+ id: v.string(),
48
+ installName: v.string(),
49
+ target: v.literal('wasm32-unknown-wasip1'),
50
+ linkNames: v.array(v.string()),
51
+ // absent records declare no framework namespace, even when a library name matches.
52
+ frameworkAliases: v.optional(
53
+ v.array(
54
+ v.object({
55
+ name: v.string(),
56
+ moduleMap: v.string(),
57
+ moduleMapSha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
58
+ }),
59
+ ),
60
+ [],
61
+ ),
62
+ buildDependencies: v.array(v.string()),
63
+ linkOwnership: v.picklist(['image', 'containing-image']),
64
+ linkDependencies: v.nullable(v.array(v.string())),
65
+ autolink: v.array(v.string()),
66
+ sources: v.array(
48
67
  v.object({
49
- kind: v.literal('archive'),
50
68
  path: v.string(),
51
69
  sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
52
- members: v.array(
53
- v.object({
54
- name: v.string(),
55
- ordinal: v.pipe(v.number(), v.integer(), v.minValue(1)),
56
- sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
57
- sources: v.array(v.string()),
58
- }),
59
- ),
60
70
  }),
61
- v.object({
62
- kind: v.literal('object'),
63
- path: v.string(),
64
- sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
65
- sources: v.array(v.string()),
66
- input: v.optional(
67
- v.object({
68
- product: v.string(),
69
- artifact: v.object({
70
- path: v.string(),
71
+ ),
72
+ artifacts: v.array(
73
+ v.variant('kind', [
74
+ v.object({
75
+ kind: v.literal('archive'),
76
+ path: v.string(),
77
+ sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
78
+ members: v.array(
79
+ v.object({
80
+ name: v.string(),
81
+ ordinal: v.pipe(v.number(), v.integer(), v.minValue(1)),
71
82
  sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
83
+ sources: v.array(v.string()),
72
84
  }),
73
- member: v.optional(
74
- v.object({
75
- name: v.string(),
76
- ordinal: v.pipe(v.number(), v.integer(), v.minValue(1)),
85
+ ),
86
+ }),
87
+ v.object({
88
+ kind: v.literal('object'),
89
+ path: v.string(),
90
+ sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
91
+ sources: v.array(v.string()),
92
+ input: v.optional(
93
+ v.object({
94
+ product: v.string(),
95
+ artifact: v.object({
96
+ path: v.string(),
77
97
  sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
78
98
  }),
79
- ),
80
- }),
81
- ),
82
- }),
83
- ]),
99
+ member: v.optional(
100
+ v.object({
101
+ name: v.string(),
102
+ ordinal: v.pipe(v.number(), v.integer(), v.minValue(1)),
103
+ sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
104
+ }),
105
+ ),
106
+ }),
107
+ ),
108
+ }),
109
+ ]),
110
+ ),
111
+ }),
112
+ v.check(
113
+ (product) => product.linkOwnership === 'image' || product.linkDependencies === null,
114
+ 'containing-image products cannot declare an image scope',
84
115
  ),
85
- })
116
+ )
86
117
 
87
118
  export const swiftSdkProductsSchema = v.object({
88
119
  version: v.literal(1),
@@ -90,3 +121,12 @@ export const swiftSdkProductsSchema = v.object({
90
121
  })
91
122
 
92
123
  export type SwiftSdkProduct = v.InferOutput<typeof swiftSdkProductSchema>
124
+
125
+ export type GuestFrameworkProvider =
126
+ | { readonly kind: 'package'; readonly targets: readonly string[] }
127
+ | { readonly kind: 'sdk'; readonly product: string }
128
+
129
+ export interface GuestFrameworkRequest {
130
+ readonly object: string | null
131
+ readonly provider: GuestFrameworkProvider
132
+ }
@@ -8,11 +8,11 @@
8
8
  },
9
9
  "compiler": "swift-6.4.0-RELEASE-custom-a560ff35bf882b5c",
10
10
  "sdk": {
11
- "id": "swift-6.4.0-RELEASE_wasm-peach-e210d44b",
12
- "checksum": "02a87a688b4644f23c470433356f23ce90a3e6c95507a787a11d2cd671152c0c"
11
+ "id": "swift-6.4.0-RELEASE_wasm-peach-3b3aa5c2",
12
+ "checksum": "49fcbdbcb340a7ca89db0b8965bea0b1aced4a3f767a86a70b9db00ec55e067b"
13
13
  },
14
14
  "framework": {
15
- "distribution": "70d4c94be0146f9e",
15
+ "distribution": "254fdeb7cac228a5",
16
16
  "wireAbi": "246b8412514b644113e6a26252c8ebd6de49ab4156ac5f5c98bb9e4c2ff2568b"
17
17
  },
18
18
  "archives": [
@@ -20,71 +20,71 @@
20
20
  "headers": {
21
21
  "reactNativeJsi": "0f8c2defbca69a27a848a81ae72363073bf9602fd316e57a75811be1a0528358"
22
22
  },
23
- "sha256": "fa21253dcca4c622d6bc1f5391d85b3cd709ec7370f55643cef0bfee497287bb",
24
- "size": 25390
23
+ "sha256": "3f2bcbcc27b4a1b23dc8f11d5c130e4e314411dc8e4ac217c156c3ae17791886",
24
+ "size": 25401
25
25
  },
26
26
  {
27
27
  "headers": {
28
28
  "reactNativeJsi": "21a624ea24fd17d56bf26832d496fc1177067f89640414c20e6486c7984dfb0a"
29
29
  },
30
- "sha256": "dfa6e7cdb33e5ed08f55e41f6fb2087b5ea3be6012f3745ac6c93c422c1062fc",
31
- "size": 26136
30
+ "sha256": "cdc67be63dfc69343d32a765db173ef2e462e0900ee69177bc4e21e77b94db95",
31
+ "size": 26139
32
32
  },
33
33
  {
34
34
  "headers": {
35
35
  "reactNativeJsi": "324aefd8591d9ce688bce7589c4c2b516cd33ecb95d35c47239a87a8fcf6a8da"
36
36
  },
37
- "sha256": "abbcf4b98778e11fe1fa2b6c0518598e6451dfa790115575043e4ad6ea7857d1",
38
- "size": 25386
37
+ "sha256": "829742f50895fb04aa251d95571be83d6539f732e50cdb165ec538b7b188dc59",
38
+ "size": 25396
39
39
  },
40
40
  {
41
41
  "headers": {
42
42
  "reactNativeJsi": "33596664ee7d7a6623f0796a6feb429543316c3a41b211150acda6e1d835286c"
43
43
  },
44
- "sha256": "25607a392966346080e0051ae7bc469759c543460b2202fac94a4174c65b7308",
45
- "size": 25157
44
+ "sha256": "7891b70a9a80acf9287f8059f42a335c7836ec3e7c29187f4866184f4614354a",
45
+ "size": 25167
46
46
  },
47
47
  {
48
48
  "headers": {
49
49
  "reactNativeJsi": "66b2cd5a38511195207f6c8a76aba735f9b9cc66a52a0d00780ffe5d331623f7"
50
50
  },
51
- "sha256": "edafa2130cca3278594a6fd8e6f6c7a866427442df8c66f6f90a94df6ce565b7",
52
- "size": 25390
51
+ "sha256": "dd475d73cc366f913546f894a56070ceb8f9e451a6a36e0a11422f802e03d946",
52
+ "size": 25400
53
53
  },
54
54
  {
55
55
  "headers": {
56
56
  "reactNativeJsi": "96db4e758dd53e9320cef7cad485e00aa06e7a982cefd920f17007de8a5bd9f9"
57
57
  },
58
- "sha256": "1b5e488f623261cd662a6d97b2071045c747d108cb82f79ace8642cde67b92fa",
59
- "size": 26137
58
+ "sha256": "103ceb90327f7f8ea058756f4dbdb0a022a0d61d5076fea65c487e54b293ec87",
59
+ "size": 26140
60
60
  },
61
61
  {
62
62
  "headers": {
63
63
  "reactNativeJsi": "aeab590ddd1218df963462242d3954ce467b0fa88f70e91429e4ffc74d230893"
64
64
  },
65
- "sha256": "c296909ad8b8492a3652d5897a44651ed9f05d4c048dc29f60d060865cb8ff61",
66
- "size": 26135
65
+ "sha256": "9f5268e469a336e50191d8b2485243ec1ff4bd83157ed12d107fa8f3dc597ae5",
66
+ "size": 26139
67
67
  },
68
68
  {
69
69
  "headers": {
70
70
  "reactNativeJsi": "b5fb260522384dd7ab07d740cdc534b529922446fcec798341c7817d9eaa49f4"
71
71
  },
72
- "sha256": "1619009fd794c373314abb47289ad4995c5e2adac1ef2ea6e125efb968b51649",
73
- "size": 25260
72
+ "sha256": "1c9d8178cfc9f187122ca52dba7ba9a4af531ca09fdde1616d1a3f6b12c01853",
73
+ "size": 25268
74
74
  },
75
75
  {
76
76
  "headers": {
77
77
  "reactNativeJsi": "c6b391a1e870ccf7cdd534be63582862840f8245b99ebd253317deece1e6ffd5"
78
78
  },
79
- "sha256": "a9f4777b1ba8b7724b88d91b66ece10718666e110944fd45ed85bb4a19408e8e",
80
- "size": 26139
79
+ "sha256": "27bf8f75332c3e77cce60eacc9a9aa5ecc8c807ff88829f8f78e1af3282f9fea",
80
+ "size": 26144
81
81
  },
82
82
  {
83
83
  "headers": {
84
84
  "reactNativeJsi": "c8270f1315745ecc204c4209a4f50f58ff6f14b4a385ad6820a69800270b53c6"
85
85
  },
86
- "sha256": "9588c7d3a06cfc4316b6501d8adc1ec104e524c46bbc72544c57a725e6a88277",
87
- "size": 25102
86
+ "sha256": "bc1bd88b6ff5bd7557b66d09825bb90f86a19724caec5264746d7464a5f6c51d",
87
+ "size": 25106
88
88
  }
89
89
  ]
90
90
  }
@@ -995,7 +995,10 @@ function readFollyConfig(reactNativeRoot: string) {
995
995
  path.join(reactNativeRoot, 'scripts/cocoapods/helpers.rb'),
996
996
  'utf8',
997
997
  )
998
- const config = /@@folly_config\s*=\s*\{([\s\S]*?)\n\s*\}/.exec(helpers)?.[1]
998
+ const config =
999
+ /(?:@@folly_config\s*=|def self\.folly_config\s+return)\s*\{([\s\S]*?)\n\s*\}/.exec(
1000
+ helpers,
1001
+ )?.[1]
999
1002
  const flags = config && /:compiler_flags\s*=>\s*'([^']*)'/.exec(config)?.[1]
1000
1003
  const lines = config && /:config_file\s*=>\s*\[([\s\S]*?)\]/.exec(config)?.[1]
1001
1004
  if (!flags) throw new Error(`${reactNativeRoot}: helpers.rb has no folly config`)
@@ -22,9 +22,17 @@ const FEATURES = [
22
22
  /** feeds the artifact hash: a new optimizer or flag set is a new artifact. */
23
23
  export const WASM_OPTIMIZE_IDENTITY = `wasm-opt ${BINARYEN_VERSION} -Oz ${FEATURES.join(',')}`
24
24
 
25
- async function runWasmOpt(file: string, output: string): Promise<void> {
25
+ // skipPasses names Binaryen passes to leave out. a guest link with several images
26
+ // skips duplicate-function-elimination, which would merge identical functions
27
+ // that different images must keep separate.
28
+ async function runWasmOpt(
29
+ file: string,
30
+ output: string,
31
+ skipPasses: readonly string[],
32
+ ): Promise<void> {
26
33
  const result = await wasmOpt([
27
34
  '-Oz',
35
+ ...skipPasses.flatMap((pass) => ['--skip-pass', pass]),
28
36
  ...FEATURES.map((feature) => `--enable-${feature}`),
29
37
  file,
30
38
  '-o',
@@ -52,12 +60,16 @@ function installWasmOpt(): void {
52
60
  }
53
61
  }
54
62
 
55
- export async function optimizeWasm(file: string, output: string): Promise<void> {
63
+ export async function optimizeWasm(
64
+ file: string,
65
+ output: string,
66
+ skipPasses: readonly string[] = [],
67
+ ): Promise<void> {
56
68
  try {
57
- await runWasmOpt(file, output)
69
+ await runWasmOpt(file, output, skipPasses)
58
70
  } catch (error) {
59
71
  if (!(error instanceof BinaryNotFoundError)) throw error
60
72
  installWasmOpt()
61
- await runWasmOpt(file, output)
73
+ await runWasmOpt(file, output, skipPasses)
62
74
  }
63
75
  }
@@ -13,6 +13,7 @@ import fs from 'node:fs'
13
13
  import path from 'node:path'
14
14
  import plist from 'plist'
15
15
  import { isRecord } from './is-record'
16
+ import { readKeychainAccessGroups } from './native-app-identity'
16
17
  import { preparedXcodePhase } from './prepared-xcode-phases'
17
18
  import { localSwiftBinaryModules } from './swift-binary-modules'
18
19
  import { assetSymbolSettingKeys } from './swift-coverage/xcode-assets'
@@ -28,7 +29,7 @@ import {
28
29
  xcodePathResolver,
29
30
  } from './xcode-target-members'
30
31
  import type { SwiftLinkedProduct } from './swift-packages'
31
- import type { SwiftNativeHeaderMap } from './swiftContract'
32
+ import type { SwiftNativeHeaderMap, SwiftSourceLinkGraph } from './swiftContract'
32
33
 
33
34
  export {
34
35
  parseOpenStepPlist,
@@ -75,6 +76,8 @@ const PRE_CXX20_STANDARDS = new Set([
75
76
  ])
76
77
 
77
78
  export interface XcodeModuleTarget {
79
+ /** original project and PBX target identity, independent of module aliases. */
80
+ id: string
78
81
  name: string
79
82
  /** the original project and PBX target identifier, shared by dependency edges. */
80
83
  targetIdentity: string
@@ -151,6 +154,8 @@ export interface XcodeModuleTarget {
151
154
 
152
155
  /** an application target, resolved to files on disk with everything it builds. */
153
156
  export interface XcodeAppTarget extends XcodeModuleTarget {
157
+ /** source products and direct links; IDs are local absolute project identities. */
158
+ sourceLinkGraph: SwiftSourceLinkGraph
154
159
  /** original Clang maps behind CocoaPods' generated compatibility products. */
155
160
  moduleMapSources?: Record<string, string>
156
161
  /**
@@ -165,6 +170,7 @@ export interface XcodeAppTarget extends XcodeModuleTarget {
165
170
  /** the target's processed launch plist, including generated build settings. */
166
171
  infoPlist: string | null
167
172
  infoPlistFile: string | null
173
+ keychainAccessGroups?: readonly string[]
168
174
  /** trailing run scripts which consume the packaged application bundle. */
169
175
  postBundleScripts: {
170
176
  name: string
@@ -215,6 +221,18 @@ export interface XcodeAppTarget extends XcodeModuleTarget {
215
221
 
216
222
  const APPLICATION = 'com.apple.product-type.application'
217
223
  const RESOURCE_BUNDLE = 'com.apple.product-type.bundle'
224
+ // the MACH_O_TYPE each product type builds with when no setting names one, from
225
+ // the product type specifications in Xcode's CoreBuildSystem plugin.
226
+ const PRODUCT_MACH_O_TYPES: Record<string, string> = {
227
+ 'com.apple.product-type.application': 'mh_execute',
228
+ 'com.apple.product-type.app-extension': 'mh_execute',
229
+ 'com.apple.product-type.tool': 'mh_execute',
230
+ 'com.apple.product-type.framework': 'mh_dylib',
231
+ 'com.apple.product-type.framework.static': 'staticlib',
232
+ 'com.apple.product-type.library.dynamic': 'mh_dylib',
233
+ 'com.apple.product-type.library.static': 'staticlib',
234
+ 'com.apple.product-type.bundle': 'mh_bundle',
235
+ }
218
236
  // product types xcode builds as a .framework bundle with Headers and Modules.
219
237
  const FRAMEWORK_PRODUCTS = new Set([
220
238
  'com.apple.product-type.framework',
@@ -735,6 +753,17 @@ function targetSettings(
735
753
  PRODUCT_NAME: () => get('TARGET_NAME'),
736
754
  PRODUCT_MODULE_NAME: () => applyOperator(get('PRODUCT_NAME'), 'c99extidentifier'),
737
755
  EXECUTABLE_NAME: () => get('PRODUCT_NAME'),
756
+ MACH_O_TYPE: () => PRODUCT_MACH_O_TYPES[str(target.productType) ?? ''] ?? '',
757
+ // the native defaults of CoreBuildSystem.xcspec for a dynamic framework
758
+ EXECUTABLE_PATH: () =>
759
+ FRAMEWORK_PRODUCTS.has(str(target.productType) ?? '')
760
+ ? `${get('PRODUCT_NAME')}.framework/${get('EXECUTABLE_NAME')}`
761
+ : get('EXECUTABLE_NAME'),
762
+ DYLIB_INSTALL_NAME_BASE: () => '/Library/Frameworks',
763
+ LD_DYLIB_INSTALL_NAME: () =>
764
+ get('MACH_O_TYPE') === 'mh_dylib'
765
+ ? `${get('DYLIB_INSTALL_NAME_BASE')}/${get('EXECUTABLE_PATH')}`
766
+ : '',
738
767
  // the native default of CoreBuildSystem.xcspec
739
768
  EXCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES: () =>
740
769
  '*.nib *.lproj *.framework *.gch *.xcode* *.xcassets *.icon (*) .DS_Store CVS .svn .git .hg *.pbproj *.pbxproj',
@@ -1778,18 +1807,11 @@ export function readXcodeAppTarget(
1778
1807
  (ref) => ref.id === remote || str(ref.target.productReference) === remote,
1779
1808
  )
1780
1809
  }
1781
- const dependenciesOf = (ref: TargetRef): TargetRef[] => {
1810
+ const linkedTargets = (
1811
+ ref: TargetRef,
1812
+ ): { target: TargetRef; attributes: string[] }[] => {
1782
1813
  const { project, target } = ref
1783
- const found: TargetRef[] = []
1784
- for (const dependencyId of list(target.dependencies)) {
1785
- const dependency = project.object(dependencyId)
1786
- if (!dependency || !xcodeBuildFileBuildsForIos(dependency)) continue
1787
- const direct = str(dependency.target)
1788
- const resolved = direct
1789
- ? projectTargets(project).find((candidate) => candidate.id === direct)
1790
- : proxied(project, str(dependency.targetProxy))
1791
- if (resolved) found.push(resolved)
1792
- }
1814
+ const found: { target: TargetRef; attributes: string[] }[] = []
1793
1815
  for (const phaseId of list(target.buildPhases)) {
1794
1816
  const phase = project.object(phaseId)
1795
1817
  if (phase?.isa !== 'PBXFrameworksBuildPhase') continue
@@ -1803,10 +1825,47 @@ export function readXcodeAppTarget(
1803
1825
  : file && str(file.sourceTree) === 'BUILT_PRODUCTS_DIR'
1804
1826
  ? byProduct.get(path.basename(str(file.path) ?? ''))
1805
1827
  : undefined
1806
- if (resolved) found.push(resolved)
1828
+ if (resolved)
1829
+ found.push({
1830
+ target: resolved,
1831
+ attributes: list(
1832
+ isDict(buildFile.settings) ? buildFile.settings.ATTRIBUTES : undefined,
1833
+ ),
1834
+ })
1807
1835
  }
1808
1836
  }
1809
- return found.filter(
1837
+ return found
1838
+ }
1839
+ // a plain `-framework Name` in the linker flags (CocoaPods writes them into
1840
+ // the app's xcconfig) links the framework target that builds Name.framework,
1841
+ // as a framework build phase entry does. a name no target builds is a prebuilt
1842
+ // or system framework.
1843
+ const frameworkFlagLinks = (
1844
+ ref: TargetRef,
1845
+ flags: string,
1846
+ ): { target: TargetRef; attributes: string[] }[] => {
1847
+ const words = settingList(flags)
1848
+ const linked = new Set<TargetRef>(linkedTargets(ref).map((link) => link.target))
1849
+ return words.flatMap((word, index) => {
1850
+ const target =
1851
+ words[index - 1] === '-framework' ? byProduct.get(`${word}.framework`) : undefined
1852
+ if (!target || target === ref || linked.has(target)) return []
1853
+ linked.add(target)
1854
+ return [{ target, attributes: [] }]
1855
+ })
1856
+ }
1857
+ const dependenciesOf = (ref: TargetRef): TargetRef[] => {
1858
+ const { project, target } = ref
1859
+ const found = list(target.dependencies).flatMap((dependencyId) => {
1860
+ const dependency = project.object(dependencyId)
1861
+ if (!dependency || !xcodeBuildFileBuildsForIos(dependency)) return []
1862
+ const direct = str(dependency.target)
1863
+ const resolved = direct
1864
+ ? projectTargets(project).find((candidate) => candidate.id === direct)
1865
+ : proxied(project, str(dependency.targetProxy))
1866
+ return resolved ? [resolved] : []
1867
+ })
1868
+ return [...found, ...linkedTargets(ref).map((link) => link.target)].filter(
1810
1869
  (candidate) =>
1811
1870
  candidate.target.isa === 'PBXAggregateTarget' ||
1812
1871
  candidate.target.productType === RESOURCE_BUNDLE ||
@@ -2215,6 +2274,7 @@ export function readXcodeAppTarget(
2215
2274
  settings,
2216
2275
  keys,
2217
2276
  module: {
2277
+ id: `${ref.project.projectFile}#${ref.id}`,
2218
2278
  name,
2219
2279
  targetIdentity: JSON.stringify([ref.project.xcodeproj, ref.id]),
2220
2280
  targetDependencies: Array<string>(),
@@ -2565,6 +2625,20 @@ export function readXcodeAppTarget(
2565
2625
  const infoPlistFile = settings('INFOPLIST_FILE')
2566
2626
  ? path.resolve(app.project.projectDir, settings('INFOPLIST_FILE'))
2567
2627
  : null
2628
+ const entitlementsFile = settings('CODE_SIGN_ENTITLEMENTS')
2629
+ ? path.resolve(app.project.projectDir, settings('CODE_SIGN_ENTITLEMENTS'))
2630
+ : null
2631
+ const keychainAccessGroups = entitlementsFile
2632
+ ? readKeychainAccessGroups(
2633
+ plist.parse(fs.readFileSync(entitlementsFile, 'utf8')),
2634
+ (value) =>
2635
+ expand(value, (key) => {
2636
+ const resolved = settings(key)
2637
+ if (!resolved) throw new Error(`missing signing build setting ${key}`)
2638
+ return resolved
2639
+ }),
2640
+ )
2641
+ : undefined
2568
2642
  // a generated plist is read only once its phase has run
2569
2643
  const infoPlistPending = module.generatedInfoPlist && !options.prepareGeneratedSources
2570
2644
  const sourceInfo =
@@ -2772,6 +2846,20 @@ export function readXcodeAppTarget(
2772
2846
  productPlatforms.set(ref, productPlatforms.get(ref) === true || builds)
2773
2847
  return builds ? [ref] : []
2774
2848
  }
2849
+ const productAttributes = new Map<string, string[]>()
2850
+ for (const phaseId of list(target.buildPhases)) {
2851
+ const phase = project.object(phaseId)
2852
+ if (phase?.isa !== 'PBXFrameworksBuildPhase') continue
2853
+ for (const id of list(phase.files)) {
2854
+ const file = project.object(id)
2855
+ const product = str(file?.productRef)
2856
+ if (file && product && xcodeBuildFileBuildsForIos(file))
2857
+ productAttributes.set(
2858
+ product,
2859
+ list(isDict(file.settings) ? file.settings.ATTRIBUTES : undefined),
2860
+ )
2861
+ }
2862
+ }
2775
2863
  const referencedProducts = [
2776
2864
  ...list(target.dependencies).flatMap(productRef),
2777
2865
  ...list(target.buildPhases).flatMap((id) => {
@@ -2784,6 +2872,7 @@ export function readXcodeAppTarget(
2784
2872
  // the target lists every package product, including products linked only
2785
2873
  // on another platform. an inactive link must not reenter through that list.
2786
2874
  const productDependencies = [
2875
+ ...productAttributes.keys(),
2787
2876
  ...list(target.packageProductDependencies).filter(
2788
2877
  (id) => productPlatforms.get(id) !== false,
2789
2878
  ),
@@ -2801,6 +2890,9 @@ export function readXcodeAppTarget(
2801
2890
  const reference = project.object(str(dependency.package))
2802
2891
  const linked: SwiftLinkedProduct = {
2803
2892
  product,
2893
+ ...(productAttributes.get(dependencyId)?.length
2894
+ ? { attributes: productAttributes.get(dependencyId)! }
2895
+ : {}),
2804
2896
  source:
2805
2897
  reference?.isa === 'XCRemoteSwiftPackageReference'
2806
2898
  ? { kind: 'remote', url: str(reference.repositoryURL) ?? '' }
@@ -2916,6 +3008,40 @@ export function readXcodeAppTarget(
2916
3008
  const used = order.map((ref) => ref.project)
2917
3009
  return {
2918
3010
  ...module,
3011
+ sourceLinkGraph: {
3012
+ entry: module.id,
3013
+ targets: builtTargets
3014
+ .filter(
3015
+ ({ ref }) =>
3016
+ ref === app || MODULE_PRODUCTS.has(str(ref.target.productType) ?? ''),
3017
+ )
3018
+ .map(({ ref, module, settings }) => ({
3019
+ id: module.id,
3020
+ sourceTarget: module.allSources.length > 0 ? module.moduleName : null,
3021
+ productName:
3022
+ settings('FULL_PRODUCT_NAME') ||
3023
+ str(ref.project.object(str(ref.target.productReference))?.path) ||
3024
+ settings('PRODUCT_NAME'),
3025
+ productType: str(ref.target.productType)!,
3026
+ installName: settings('LD_DYLIB_INSTALL_NAME') || null,
3027
+ buildVersion: {
3028
+ platform: settings('PLATFORM_NAME') || null,
3029
+ minimumOS: settings('IPHONEOS_DEPLOYMENT_TARGET') || null,
3030
+ sdk: settings('SDK_VERSION') || null,
3031
+ },
3032
+ machOType: settings('MACH_O_TYPE') || null,
3033
+ linkerFlags: settingList(settings('OTHER_LDFLAGS')),
3034
+ dependencies: linkedTargets(ref)
3035
+ .concat(frameworkFlagLinks(ref, settings('OTHER_LDFLAGS')))
3036
+ .filter((dependency) =>
3037
+ MODULE_PRODUCTS.has(str(dependency.target.target.productType) ?? ''),
3038
+ )
3039
+ .map(({ target, attributes }) => ({
3040
+ target: `${target.project.projectFile}#${target.id}`,
3041
+ attributes,
3042
+ })),
3043
+ })),
3044
+ },
2919
3045
  moduleMapSources: Object.fromEntries(
2920
3046
  builtTargets.flatMap(({ module }) => {
2921
3047
  const compatibility = module.swift?.compatibility
@@ -2948,6 +3074,7 @@ export function readXcodeAppTarget(
2948
3074
  ...new Set([
2949
3075
  ...used.map((project) => project.projectFile),
2950
3076
  ...xcconfigs,
3077
+ ...(entitlementsFile ? [entitlementsFile] : []),
2951
3078
  ...(cocoapods
2952
3079
  ? [cocoapods.podfileLock, cocoapods.manifestLock, ...cocoapods.localPodspecs]
2953
3080
  : []),
@@ -2957,6 +3084,7 @@ export function readXcodeAppTarget(
2957
3084
  appIconName: settings('ASSETCATALOG_COMPILER_APPICON_NAME'),
2958
3085
  infoPlist: infoPlistPending ? null : plist.build(info),
2959
3086
  infoPlistFile,
3087
+ ...(keychainAccessGroups === undefined ? {} : { keychainAccessGroups }),
2960
3088
  postBundleScripts,
2961
3089
  developmentRegion: str(app.project.project.developmentRegion) ?? 'en',
2962
3090
  frameworks,