peachsim 0.1.1808 → 0.1.1812

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 (236) hide show
  1. package/README.md +4 -2
  2. package/cli/app-bundle-resources.ts +15 -2
  3. package/cli/cloud-box-artifact.ts +115 -0
  4. package/cli/cloud-client.ts +148 -76
  5. package/cli/cloud-dispatch.ts +4 -4
  6. package/cli/cloud-session.ts +60 -22
  7. package/cli/commands/box.ts +8 -2
  8. package/cli/commands/compat.ts +7 -4
  9. package/cli/commands/control.ts +69 -3
  10. package/cli/commands/coverage.ts +14 -4
  11. package/cli/commands/daemon.ts +41 -0
  12. package/cli/commands/no-bridge-hint.ts +9 -0
  13. package/cli/commands/package.ts +31 -56
  14. package/cli/commands/platform.ts +71 -60
  15. package/cli/commands/preview.ts +73 -24
  16. package/cli/commands/record.ts +10 -2
  17. package/cli/commands/screenshot.ts +17 -60
  18. package/cli/commands/setup.ts +3 -1
  19. package/cli/commands/three-mode.ts +22 -12
  20. package/cli/commands/upload.ts +2 -1
  21. package/cli/desktop-companion.ts +6 -1
  22. package/cli/drivers/desktop.ts +4 -1
  23. package/cli/main.ts +12 -2
  24. package/cli/metro-bundle-assets.ts +14 -4
  25. package/cli/outbound-endpoints.ts +7 -3
  26. package/cli/output-redaction.ts +38 -0
  27. package/cli/privacy.ts +2 -2
  28. package/cli/recording-access.ts +5 -0
  29. package/cli/remote-project-bundle.ts +83 -0
  30. package/cli/shell-init.ts +7 -11
  31. package/cli/telemetry.ts +41 -4
  32. package/cli/usage-error.ts +3 -0
  33. package/cli/ws-bridge.ts +42 -6
  34. package/dist-lib/agent-daemon-client.cjs +1 -1
  35. package/dist-lib/agent-events.cjs +1 -1
  36. package/dist-lib/attached-projects.cjs +1 -1
  37. package/dist-lib/auth/shared-session.cjs +1 -1
  38. package/dist-lib/backend-origin.cjs +1 -1
  39. package/dist-lib/beta.cjs +1 -1
  40. package/dist-lib/beta.mjs +1 -1
  41. package/dist-lib/bridge-constants.cjs +1 -1
  42. package/dist-lib/bridge-contract-input.cjs +1 -1
  43. package/dist-lib/bridge-contract-input.mjs +1 -1
  44. package/dist-lib/bridge-contract.cjs +1 -1
  45. package/dist-lib/bridge-contract.mjs +1 -1
  46. package/dist-lib/bundle-channel.cjs +42897 -40755
  47. package/dist-lib/capture-contract.cjs +7 -8
  48. package/dist-lib/capture-contract.mjs +7 -8
  49. package/dist-lib/cloud-contract.cjs +1 -1
  50. package/dist-lib/cloud-contract.mjs +1 -1
  51. package/dist-lib/cloud-test-args.cjs +1 -1
  52. package/dist-lib/cloud-test-args.mjs +1 -1
  53. package/dist-lib/cloud.cjs +1 -1
  54. package/dist-lib/cloud.mjs +1 -1
  55. package/dist-lib/config.cjs +1 -1
  56. package/dist-lib/config.mjs +1 -1
  57. package/dist-lib/detox/index.cjs +13 -7
  58. package/dist-lib/dev-bundle-resolution.cjs +10 -4
  59. package/dist-lib/expo-swift-bundle.cjs +15889 -15553
  60. package/dist-lib/expo-swift-metadata.cjs +2 -1
  61. package/dist-lib/expo-swift-metadata.mjs +2 -1
  62. package/dist-lib/home-paths.cjs +2 -33
  63. package/dist-lib/host/bridge-host.cjs +20891 -18714
  64. package/dist-lib/host/fetch-proxy-handler.cjs +10 -11
  65. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  66. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  67. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  68. package/dist-lib/host/websocket-proxy.cjs +1 -1
  69. package/dist-lib/index.cjs +620 -553
  70. package/dist-lib/jump-to-source-babel.cjs +1 -1
  71. package/dist-lib/jump-to-source-native.cjs +1 -1
  72. package/dist-lib/kotlin-host.cjs +1 -1
  73. package/dist-lib/menu.cjs +1 -1
  74. package/dist-lib/menu.mjs +1 -1
  75. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  76. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  77. package/dist-lib/metro-production-bundle.cjs +1 -1
  78. package/dist-lib/metro-production-bundle.mjs +1 -1
  79. package/dist-lib/metro.cjs +57 -28
  80. package/dist-lib/native-app-identity-project.cjs +47 -14
  81. package/dist-lib/native-app-identity-project.mjs +55 -20
  82. package/dist-lib/native-app-identity.cjs +1 -1
  83. package/dist-lib/native-app-identity.mjs +1 -1
  84. package/dist-lib/native-firebase-metadata.cjs +1 -1
  85. package/dist-lib/native-firebase-metadata.mjs +1 -1
  86. package/dist-lib/pdfium-raster.cjs +1 -1
  87. package/dist-lib/pdfium-raster.mjs +1 -1
  88. package/dist-lib/plist.cjs +1 -1
  89. package/dist-lib/plist.mjs +1 -1
  90. package/dist-lib/profiles.cjs +1 -1
  91. package/dist-lib/public-brand.cjs +1 -1
  92. package/dist-lib/public-origins-lib-esm.json +27 -26
  93. package/dist-lib/public-origins-lib.json +104 -81
  94. package/dist-lib/react-native-host-modules.cjs +1 -1
  95. package/dist-lib/react-native-host-modules.mjs +1 -1
  96. package/dist-lib/reap-browser.cjs +1 -1
  97. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  98. package/dist-lib/sdk.cjs +1 -1
  99. package/dist-lib/sdk.mjs +1 -1
  100. package/dist-lib/skills.cjs +30700 -24410
  101. package/dist-lib/swift-compile.cjs +336 -222
  102. package/dist-lib/swift-compile.mjs +378 -263
  103. package/dist-lib/swift-package.cjs +19 -7
  104. package/dist-lib/swift-package.mjs +16 -6
  105. package/dist-lib/swift-submit.cjs +1 -1
  106. package/dist-lib/swift-submit.mjs +1 -1
  107. package/dist-lib/swift-toolchain.cjs +49 -1
  108. package/dist-lib/swift.cjs +1 -1
  109. package/dist-lib/vite-swift.cjs +19213 -18937
  110. package/dist-lib/vite.cjs +11 -12
  111. package/dist-lib/worklet-executable.cjs +1 -1
  112. package/dist-lib/worklet-executable.mjs +1 -1
  113. package/dist-types/packages/peach-engine/src/engine/animated.d.ts +4 -0
  114. package/dist-types/packages/peach-engine/src/engine/animation-graph.d.ts +1 -0
  115. package/dist-types/packages/peach-engine/src/engine/expo-manifest.d.ts +1 -0
  116. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +1 -1
  117. package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +1 -0
  118. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +8 -1
  119. package/dist-types/packages/peach-globals/src/electronBridgeContract.d.ts +2 -1
  120. package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
  121. package/kotlin/sdk.tar.gz +0 -0
  122. package/package.json +1 -1
  123. package/runtime-companion.json +1 -1
  124. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCall.h +1 -1
  125. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCallCenter.h +1 -1
  126. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCarrier.h +1 -1
  127. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriber.h +1 -1
  128. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriberInfo.h +1 -1
  129. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h +1 -1
  130. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSDictionary.h +1 -1
  131. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSExtensionItem.h +1 -1
  132. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVFoundation+MPNowPlayingInfoLanguageOptionAdditions.h +39 -0
  133. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVPlayerItem+MediaPlayerAdditions.h +26 -0
  134. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPContentItem.h +67 -0
  135. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPError.h +33 -0
  136. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaEntity.h +53 -0
  137. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItem.h +346 -0
  138. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItemCollection.h +42 -0
  139. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaLibrary.h +76 -0
  140. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPickerController.h +64 -0
  141. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlayback.h +47 -0
  142. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlaylist.h +82 -0
  143. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuery.h +120 -0
  144. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuerySection.h +26 -0
  145. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerController.h +444 -0
  146. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerViewController.h +43 -0
  147. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerApplicationController.h +47 -0
  148. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerController.h +147 -0
  149. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerQueueDescriptor.h +75 -0
  150. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoCenter.h +197 -0
  151. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoLanguageOption.h +107 -0
  152. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingSession.h +89 -0
  153. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDataSource.h +59 -0
  154. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDelegate.h +64 -0
  155. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManager.h +46 -0
  156. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManagerContext.h +32 -0
  157. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommand.h +143 -0
  158. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandCenter.h +66 -0
  159. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandEvent.h +128 -0
  160. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteControlTypes.h +27 -0
  161. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeSettings.h +20 -0
  162. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeView.h +82 -0
  163. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.apinotes +74 -0
  164. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.h +40 -0
  165. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayerDefines.h +84 -0
  166. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/NSUserActivity+MediaPlayerAdditions.h +20 -0
  167. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Modules/module.modulemap +5 -0
  168. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityCustomRotor.h +2 -2
  169. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAction.h +1 -1
  170. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBackgroundConfiguration.h +1 -1
  171. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIButtonConfiguration.h +1 -1
  172. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuConfiguration.h +1 -1
  173. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuInteraction.h +1 -1
  174. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDeferredMenuElement.h +1 -1
  175. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIMenu.h +1 -1
  176. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIPointerStyle.h +5 -5
  177. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISlider.h +1 -1
  178. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISplitViewController.h +12 -50
  179. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISplitViewControllerLayoutEnvironment.h +2 -8
  180. package/sdk/ios/System/Library/Frameworks/UIKitTypes.framework/Headers/UIKitTypes.h +62 -0
  181. package/sdk/ios/usr/include/dispatch.modulemap +22 -0
  182. package/sdk/ios/usr/include/module.modulemap +8 -3
  183. package/sdk/ios/usr/include/net/if.h +24 -0
  184. package/sdk/ios/usr/include/sys/time.h +1 -1
  185. package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +265 -0
  186. package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -0
  187. package/sdk/ios/wasm/include/fcntl.h +2 -0
  188. package/sdk/ios/wasm/include/pthread.h +3 -0
  189. package/sdk/ios/wasm/include/stdlib.h +2 -0
  190. package/sdk/ios/wasm/include/unistd.h +2 -2
  191. package/skills/contrast/SKILL.md +2 -2
  192. package/src/bundle-channel.mjs +9 -72
  193. package/src/capture-contract.ts +12 -9
  194. package/src/desktop-host-delivery.ts +16 -2
  195. package/src/dev-bundle-resolution.ts +12 -3
  196. package/src/expo-native-workspace.ts +113 -46
  197. package/src/expo-swift-host.ts +17 -12
  198. package/src/expo-swift-ready.ts +4 -1
  199. package/src/expoSwiftContract.ts +1 -0
  200. package/src/home-paths.ts +4 -48
  201. package/src/host/bridge-host.ts +1 -0
  202. package/src/installed-native-libraries.ts +2 -8
  203. package/src/metro-project-root.ts +2 -1
  204. package/src/native-bundles.ts +122 -0
  205. package/src/native-static-libraries.ts +65 -8
  206. package/src/nitro-adapter.lock.json +272 -272
  207. package/src/nitro-bundle.ts +2 -2
  208. package/src/nitro-compile.ts +68 -28
  209. package/src/nitro-source.ts +24 -6
  210. package/src/nitro-superset.lock.json +94 -34
  211. package/src/nitroContract.ts +3 -0
  212. package/src/podspec-sources.ts +1966 -0
  213. package/src/storageSnapshotContract.ts +40 -0
  214. package/src/swift-compile.ts +77 -26
  215. package/src/swift-design-time.ts +18 -1
  216. package/src/swift-distribution.lock.json +12 -12
  217. package/src/swift-distribution.ts +9 -6
  218. package/src/swift-host.ts +1 -2
  219. package/src/swift-link-roots.ts +13 -2
  220. package/src/swift-objc-compile.ts +12 -0
  221. package/src/swift-objc-standin.ts +321 -114
  222. package/src/swift-package-manifest.ts +4 -3
  223. package/src/swift-package.ts +31 -4
  224. package/src/swift-root-lock.ts +11 -0
  225. package/src/swift-shared-sdk.ts +10 -9
  226. package/src/swift-source-pods.ts +2 -2
  227. package/src/swift-standins.ts +40 -143
  228. package/src/swift-toolchain.ts +59 -0
  229. package/src/swift-wasm-prune.ts +53 -21
  230. package/src/turbo-bundle.ts +4 -5
  231. package/src/turbo-codegen-intake.ts +111 -108
  232. package/src/turbo-compile.ts +63 -33
  233. package/src/turbo-runtime.lock.json +22 -22
  234. package/src/turbo-source.ts +171 -76
  235. package/src/wasm-optimize.ts +31 -2
  236. package/src/xcode-project.ts +65 -15
@@ -18,11 +18,12 @@ import { execFileSync, spawnSync } from 'node:child_process'
18
18
  import { createHash } from 'node:crypto'
19
19
  import fs from 'node:fs'
20
20
  import path from 'node:path'
21
+ import { isRecord } from './is-record'
21
22
  import { swiftObjCPlatformFlags } from './swift-objc-platform'
22
23
  import { IOS_SDK_HEADERS, IOS_SDK_OVERLAYS, IOS_SDK_TARGET } from './swift-objc-sdk'
23
24
  import { clangImportNames, moduleMapTokens } from './swift-package'
25
+ import { objcProtocolsInSwiftSignatures, type SymbolGraph } from './swift-standin-emit'
24
26
  import { swiftEnvironment } from './swift-toolchain'
25
- import type { SymbolGraph } from './swift-standin-emit'
26
27
 
27
28
  /** a module map and the headers it reaches: a framework's, or a library
28
29
  * slice's headers directory. */
@@ -33,12 +34,17 @@ export interface ObjcSurface {
33
34
  dependencies?: { module: string; headers: string }[]
34
35
  /** clang `-fmodule-map-file` flags this import's modules need. */
35
36
  moduleMapFlags?: readonly string[]
37
+ /** a mixed framework's swift interface, read over its own headers. */
38
+ interface?: string
36
39
  }
37
40
 
38
41
  export interface ObjcView {
39
42
  graphs: SymbolGraph[]
40
- /** external superclass conformances read from the same native SDK. */
43
+ /** external superclass conformances read from the same sdk. */
41
44
  inheritedConformances?: ReadonlyMap<string, ReadonlySet<string>>
45
+ /** a mixed framework's objc protocol properties by symbol id: symbol
46
+ * graphs omit custom accessor selectors, which clang reads from the headers. */
47
+ protocolProperties?: Map<string, { getter: string; setter?: string }>
42
48
  /** present for original implementations, read without repairing declarations. */
43
49
  clangAST?: unknown
44
50
  /** precise enum case and option ids → their header values. */
@@ -65,7 +71,7 @@ const NATIVE_GRAPH_INPUTS = {
65
71
  compiler: 'Apple Swift version 6.4 (swiftlang-6.4.0.34.1 clang-2100.3.34.1)',
66
72
  target: IOS_SDK_TARGET,
67
73
  }
68
- export const NATIVE_GRAPH_ID = createHash('sha256')
74
+ const NATIVE_GRAPH_ID = createHash('sha256')
69
75
  .update(JSON.stringify(NATIVE_GRAPH_INPUTS))
70
76
  .digest('hex')
71
77
 
@@ -169,7 +175,7 @@ function nativeGraphMismatches(read: {
169
175
  ]
170
176
  }
171
177
 
172
- function pinnedNativeSdk(): PinnedNativeSdk {
178
+ export function pinnedNativeSdk(): PinnedNativeSdk {
173
179
  if (resolvedPinnedSdk) return resolvedPinnedSdk
174
180
  let mismatches: string[] | undefined
175
181
  for (const developerDir of developerDirs()) {
@@ -200,98 +206,6 @@ function pinnedNativeSdk(): PinnedNativeSdk {
200
206
  throw new Error(`native declaration SDK ${NATIVE_GRAPH_SDK_VERSION} is not installed`)
201
207
  }
202
208
 
203
- /** true when this machine can extract against the pinned sdk. a mismatch or
204
- * an older selected xcode is not usable. */
205
- export function pinnedNativeSdkReady(): boolean {
206
- try {
207
- pinnedNativeSdk()
208
- return true
209
- } catch (error) {
210
- if (error instanceof Error && error.message.startsWith('native declaration SDK'))
211
- return false
212
- throw error
213
- }
214
- }
215
-
216
- /** a mixed framework's swift overlay and underlying clang module load together. */
217
- export function nativeInterfaceView(
218
- surface: ObjcSurface,
219
- frameworks: readonly string[],
220
- work: string,
221
- ): ObjcView {
222
- if (process.platform !== 'darwin')
223
- throw new Error('mixed framework declarations require the pinned native iOS SDK')
224
- const { sdkPath: sdk, compiler } = pinnedNativeSdk()
225
- const toolchainBin = path.dirname(compiler)
226
- const search = ['-sdk', sdk, ...frameworks.flatMap((dir) => ['-F', dir])]
227
- const extract = (module: string, out: string): SymbolGraph[] => {
228
- fs.mkdirSync(out, { recursive: true })
229
- const run = spawnSync(
230
- path.join(toolchainBin, 'swift-symbolgraph-extract'),
231
- [
232
- '-module-name',
233
- module,
234
- '-target',
235
- IOS_SDK_TARGET,
236
- ...search,
237
- // at public the graph hides underscored public names other public
238
- // declarations use; the emitter keeps only public and open symbols
239
- '-minimum-access-level',
240
- 'internal',
241
- '-include-spi-symbols',
242
- '-skip-synthesized-members',
243
- '-omit-extension-block-symbols',
244
- '-output-dir',
245
- out,
246
- ],
247
- { encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 },
248
- )
249
- if (run.error) throw run.error
250
- if (run.status !== 0)
251
- throw new Error(
252
- `native interface extraction ${run.signal ?? `exit ${run.status}`}: ${run.stderr.trim().slice(-4000)}`,
253
- )
254
- const graphs = fs
255
- .readdirSync(out)
256
- .filter((file) => file.endsWith('.symbols.json'))
257
- .sort()
258
- .map(
259
- (file): SymbolGraph => JSON.parse(fs.readFileSync(path.join(out, file), 'utf8')),
260
- )
261
- if (graphs.length === 0)
262
- throw new Error('native interface extraction returned no graphs')
263
- return graphs
264
- }
265
- const graphs = extract(surface.module, path.join(work, 'native-graphs'))
266
- const own = new Set(
267
- graphs.flatMap((graph) => graph.symbols.map((symbol) => symbol.identifier.precise)),
268
- )
269
- const parents = new Map<string, Set<string>>()
270
- for (const graph of graphs)
271
- for (const edge of graph.relationships)
272
- if (edge.kind === 'inheritsFrom' && !own.has(edge.target) && edge.targetFallback) {
273
- const module = edge.targetFallback.split('.')[0]!
274
- const ids = parents.get(module) ?? new Set<string>()
275
- ids.add(edge.target)
276
- parents.set(module, ids)
277
- }
278
- const inheritedConformances = new Map<string, Set<string>>()
279
- for (const [module, ids] of parents)
280
- for (const graph of extract(module, path.join(work, 'native-parents', module)))
281
- for (const edge of graph.relationships)
282
- if (edge.kind === 'conformsTo' && ids.has(edge.source)) {
283
- const protocols = inheritedConformances.get(edge.source) ?? new Set<string>()
284
- protocols.add(edge.target)
285
- inheritedConformances.set(edge.source, protocols)
286
- }
287
- return {
288
- graphs,
289
- inheritedConformances,
290
- values: enumValues(graphs, surface, true, toolchainBin, search, work),
291
- imports: [],
292
- }
293
- }
294
-
295
209
  // the opaque declarations a failed import asks for, by name.
296
210
  type Missing = Map<string, 'class' | 'protocol' | 'struct' | 'macro'>
297
211
 
@@ -367,9 +281,12 @@ export function objcSdkIntakeFlags(
367
281
  ): string[] {
368
282
  return [
369
283
  ...swiftObjCPlatformFlags(toolchainBin, minimum),
370
- // AvailabilityInternal.h derives this through __is_target_os(ios), which
371
- // is false for wasm32.
284
+ // AvailabilityInternal.h derives these through __is_target_os(ios), which
285
+ // is false for wasm32. the maximum is the sdk the headers come from, as
286
+ // xcode defines it, so `#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_26_0`
287
+ // sources see the members the sdk declares instead of a 17.0 default.
372
288
  `-D__IPHONE_OS_VERSION_MIN_REQUIRED=${minimum}`,
289
+ `-D__IPHONE_OS_VERSION_MAX_ALLOWED=__IPHONE_${NATIVE_GRAPH_SDK_VERSION.replace('.', '_')}`,
373
290
  // apple's build setting for a 32-bit target to keep NSInteger and
374
291
  // NSUInteger long, the nominal types they have on arm64.
375
292
  '-DNS_BUILD_32_LIKE_64=1',
@@ -528,6 +445,7 @@ export function objcView(
528
445
  cacheDir: string,
529
446
  work: string,
530
447
  original?: { flags: readonly string[]; target: string },
448
+ vendorFrameworks: readonly string[] = [],
531
449
  ): ObjcView {
532
450
  if (!fs.existsSync(stdlib))
533
451
  throw new Error(
@@ -565,6 +483,29 @@ export function objcView(
565
483
  surface.modulemap,
566
484
  path.join(frameworks, `${surface.module}.framework`, 'Modules', 'module.modulemap'),
567
485
  )
486
+ // a mixed framework's swift overlay loads over the same learned headers.
487
+ // the intake reads CoreFoundation's headers textually, so a type the
488
+ // interface qualifies with CoreFoundation lives in CoreGraphics (CGSize,
489
+ // CGFloat) or Foundation.
490
+ if (surface.interface) {
491
+ const from = path.dirname(surface.interface)
492
+ const to = path.join(
493
+ frameworks,
494
+ `${surface.module}.framework`,
495
+ 'Modules',
496
+ path.basename(from),
497
+ )
498
+ fs.mkdirSync(to, { recursive: true })
499
+ for (const name of fs.readdirSync(from))
500
+ if (name.endsWith('.swiftinterface'))
501
+ fs.writeFileSync(
502
+ path.join(to, name),
503
+ fs
504
+ .readFileSync(path.join(from, name), 'utf8')
505
+ .replace(/\bCoreFoundation\.(?=CG)/g, 'CoreGraphics.')
506
+ .replace(/\bCoreFoundation\.(?=\w)/g, 'Foundation.'),
507
+ )
508
+ }
568
509
  } else {
569
510
  fs.copyFileSync(surface.modulemap, path.join(headersDir, 'module.modulemap'))
570
511
  }
@@ -622,6 +563,7 @@ export function objcView(
622
563
  stubs,
623
564
  '-I',
624
565
  stubIncludes,
566
+ ...vendorFrameworks.flatMap((dir) => ['-F', dir]),
625
567
  ]
626
568
  const missing: Missing = new Map()
627
569
  const stubbed = new Set<string>()
@@ -630,11 +572,12 @@ export function objcView(
630
572
  const out = path.join(work, 'graphs')
631
573
  // a framework the headers import and the sdk lacks: an empty framework
632
574
  // module with the asked-for header, which reaches the opaque declarations.
633
- const stub = (include: string): boolean => {
575
+ // a module import names its framework whatever its case (zlib).
576
+ const stub = (include: string, module = false): boolean => {
634
577
  if (stubbed.has(include)) return false
635
578
  stubbed.add(include)
636
579
  const slash = include.indexOf('/')
637
- if (slash > 0 && /^[A-Z]/.test(include)) {
580
+ if (slash > 0 && (module || /^[A-Z]/.test(include))) {
638
581
  const name = include.slice(0, slash)
639
582
  const umbrella = `${name}/${name}.h`
640
583
  if (
@@ -668,6 +611,31 @@ export function objcView(
668
611
  }
669
612
  return true
670
613
  }
614
+ // an sdk framework the intake reads textually (CoreFoundation) still
615
+ // answers a module import, as a module that re-exports Foundation. a swift
616
+ // module the toolchain lacks (the standard library's _StringProcessing off
617
+ // a Mac) declares nothing: whatever it re-exported would answer qualified
618
+ // standard library names, since `Swift.Duration` also searches it.
619
+ const stubModule = (name: string, swift: boolean): boolean => {
620
+ const sdk = Object.hasOwn(
621
+ IOS_SDK_HEADERS,
622
+ `System/Library/Frameworks/${name}.framework/Headers/${name}.h`,
623
+ )
624
+ if (!sdk && !swift) return stub(`${name}/${name}.h`, true)
625
+ if (stubbed.has(name)) return false
626
+ stubbed.add(name)
627
+ const dir = path.join(stubIncludes, name)
628
+ fs.mkdirSync(dir, { recursive: true })
629
+ fs.writeFileSync(
630
+ path.join(dir, 'PeachModule.h'),
631
+ sdk ? '#import <Foundation/Foundation.h>\n' : '',
632
+ )
633
+ fs.writeFileSync(
634
+ path.join(dir, 'module.modulemap'),
635
+ `module ${name} [system] {\n header "PeachModule.h"\n export *\n}\n`,
636
+ )
637
+ return true
638
+ }
671
639
  // the opaque declarations, plus the sdk modules that own a named type.
672
640
  const writeHeaders = () => {
673
641
  if (missing.size > 0) {
@@ -726,8 +694,10 @@ export function objcView(
726
694
  path.join(cacheDir, 'ios-module-cache'),
727
695
  '-minimum-access-level',
728
696
  // symbol graphs hide public underscored names at the public threshold.
729
- // original clang headers remain the declaration boundary.
730
- original ? 'internal' : 'public',
697
+ // original clang headers remain the declaration boundary, and a swift
698
+ // overlay names its underscored and spi declarations.
699
+ original || surface.interface ? 'internal' : 'public',
700
+ ...(surface.interface ? ['-include-spi-symbols'] : []),
731
701
  '-skip-synthesized-members',
732
702
  '-omit-extension-block-symbols',
733
703
  '-output-dir',
@@ -766,9 +736,11 @@ export function objcView(
766
736
  if (stub(found[1]!)) progress = true
767
737
  continue
768
738
  }
739
+ // clang's module import, or a swift interface's
769
740
  const module = /^module '(\w+)' not found$/.exec(message!)
770
- if (module) {
771
- if (stub(`${module[1]}/${module[1]}.h`)) progress = true
741
+ const swiftModule = /^no such module '(\w+)[\w.]*'$/.exec(message!)
742
+ if (module || swiftModule) {
743
+ if (stubModule((module ?? swiftModule)![1]!, !module)) progress = true
772
744
  continue
773
745
  }
774
746
  const protocol =
@@ -815,11 +787,111 @@ export function objcView(
815
787
  )
816
788
  writeHeaders()
817
789
  }
790
+ // a header-scoped declaration belongs to the module only when one of its
791
+ // own headers makes it. the intake's textual headers otherwise hand it
792
+ // clang's builtin typedefs (stddef's size_t), which an apple sdk keeps in
793
+ // their own builtin modules.
794
+ const ownHeaders = new Set(headerFiles(headersDir).map((name) => path.basename(name)))
818
795
  const graphs = fs
819
796
  .readdirSync(out)
820
797
  .filter((name) => name.endsWith('.symbols.json'))
821
798
  .sort()
822
- .map((name): SymbolGraph => JSON.parse(fs.readFileSync(path.join(out, name), 'utf8')))
799
+ .map((name): SymbolGraph => {
800
+ const graph: SymbolGraph = JSON.parse(fs.readFileSync(path.join(out, name), 'utf8'))
801
+ return {
802
+ ...graph,
803
+ symbols: graph.symbols.filter((symbol) => {
804
+ const header = /^c:([^@]+\.h)@/.exec(symbol.identifier.precise)?.[1]
805
+ return !header || ownHeaders.has(header)
806
+ }),
807
+ }
808
+ })
809
+ // a swift class whose superclass another module declares must not restate
810
+ // a conformance that superclass already brings, through its ancestors,
811
+ // categories, protocol parents or a swift overlay. the swift compiler
812
+ // answers from the same sdk: restating one is a redundant conformance, and
813
+ // an inherited unchecked Sendable asks to be restated as such.
814
+ const inheritedConformances = new Map<string, Set<string>>()
815
+ if (surface.interface) {
816
+ const own = new Set(
817
+ graphs.flatMap((graph) => graph.symbols.map((symbol) => symbol.identifier.precise)),
818
+ )
819
+ const superclasses = new Map<string, string>()
820
+ const subclasses = new Set<string>()
821
+ for (const graph of graphs)
822
+ for (const edge of graph.relationships)
823
+ if (
824
+ edge.kind === 'inheritsFrom' &&
825
+ !own.has(edge.target) &&
826
+ edge.targetFallback
827
+ ) {
828
+ superclasses.set(edge.target, edge.targetFallback)
829
+ subclasses.add(edge.source)
830
+ }
831
+ const protocols = new Map<string, string>()
832
+ for (const graph of graphs)
833
+ for (const edge of graph.relationships)
834
+ if (
835
+ edge.kind === 'conformsTo' &&
836
+ subclasses.has(edge.source) &&
837
+ !own.has(edge.target) &&
838
+ edge.targetFallback
839
+ )
840
+ protocols.set(edge.target, edge.targetFallback)
841
+ const pairs = [...superclasses].flatMap((superclass) =>
842
+ [...protocols].map((protocol) => ({ superclass, protocol })),
843
+ )
844
+ if (pairs.length > 0) {
845
+ const probe = path.join(work, 'inherited-conformances.swift')
846
+ fs.writeFileSync(
847
+ probe,
848
+ [
849
+ ...new Set(
850
+ [...superclasses.values(), ...protocols.values()].map(
851
+ (name) => `import ${name.split('.')[0]}`,
852
+ ),
853
+ ),
854
+ ...pairs.map(
855
+ ({ superclass, protocol }, index) =>
856
+ `class PeachConforms${index}: ${superclass[1]}, ${protocol[1]} {}`,
857
+ ),
858
+ ].join('\n'),
859
+ )
860
+ const run = spawnSync(
861
+ path.join(toolchainBin, 'swift-frontend'),
862
+ [
863
+ '-typecheck',
864
+ '-target',
865
+ IOS_SDK_TARGET,
866
+ ...search,
867
+ ...(surface.moduleMapFlags ?? []).flatMap((flag) => ['-Xcc', flag]),
868
+ '-module-cache-path',
869
+ path.join(cacheDir, 'ios-module-cache'),
870
+ probe,
871
+ ],
872
+ { encoding: 'utf8', env: swiftEnvironment() },
873
+ )
874
+ if (run.error) throw run.error
875
+ const unknown = /error: (?:no such module|cannot find type) .*/.exec(run.stderr)
876
+ if (unknown)
877
+ throw new Error(`superclass conformances do not typecheck: ${unknown[0]}`)
878
+ const inherit = (superclass: string, protocol: string) => {
879
+ const inherited = inheritedConformances.get(superclass) ?? new Set<string>()
880
+ inherited.add(protocol)
881
+ inheritedConformances.set(superclass, inherited)
882
+ }
883
+ for (const match of run.stderr.matchAll(
884
+ /error: redundant conformance of 'PeachConforms(\d+)'/g,
885
+ )) {
886
+ const { superclass, protocol } = pairs[Number(match[1])]!
887
+ inherit(superclass[0], protocol[0])
888
+ }
889
+ for (const match of run.stderr.matchAll(
890
+ /warning: class 'PeachConforms(\d+)' must restate inherited '@unchecked Sendable'/g,
891
+ ))
892
+ inherit(pairs[Number(match[1])]!.superclass[0], 's:s8SendableP')
893
+ }
894
+ }
823
895
  const imports = new Set<string>(['Foundation', 'UIKit'])
824
896
  for (const text of originals.values())
825
897
  for (const name of clangImportNames(text)) imports.add(name)
@@ -827,6 +899,19 @@ export function objcView(
827
899
  imports.delete(surface.module)
828
900
  return {
829
901
  graphs,
902
+ ...(surface.interface
903
+ ? {
904
+ inheritedConformances,
905
+ protocolProperties: protocolProperties(
906
+ surface,
907
+ headersDir,
908
+ graphs,
909
+ toolchainBin,
910
+ search,
911
+ work,
912
+ ),
913
+ }
914
+ : {}),
830
915
  ...(original
831
916
  ? {
832
917
  clangAST: objcDeclarationAST(
@@ -845,6 +930,126 @@ export function objcView(
845
930
  }
846
931
  }
847
932
 
933
+ /** the swift search flags as clang spells them. */
934
+ function clangSearchFlags(search: readonly string[]): string[] {
935
+ const flags: string[] = []
936
+ for (let index = 0; index < search.length; index += 2) {
937
+ const [flag, value] = [search[index]!, search[index + 1]!]
938
+ // the swift resource directory contains swift overlays, not clang builtins.
939
+ if (flag === '-resource-dir') continue
940
+ flags.push(flag === '-sdk' ? '-isysroot' : flag, value)
941
+ }
942
+ return flags
943
+ }
944
+
945
+ // clang reads the custom accessors of each objc protocol a swift signature
946
+ // names from the same learned headers the graphs came from.
947
+ function protocolProperties(
948
+ surface: ObjcSurface,
949
+ headersDir: string,
950
+ graphs: SymbolGraph[],
951
+ toolchainBin: string,
952
+ search: string[],
953
+ work: string,
954
+ ): Map<string, { getter: string; setter?: string }> {
955
+ const properties = new Map<string, { getter: string; setter?: string }>()
956
+ const protocols = objcProtocolsInSwiftSignatures(graphs)
957
+ if (protocols.size === 0) return properties
958
+ const headers = headerFiles(headersDir).map((name) => ({
959
+ file: path.join(headersDir, name),
960
+ text: fs.readFileSync(path.join(headersDir, name), 'utf8'),
961
+ }))
962
+ const flags = clangSearchFlags(search)
963
+ for (const id of protocols) {
964
+ const name = /^c:objc\(pl\)(\w+)$/.exec(id)?.[1]
965
+ if (!name) throw new Error(`unknown Objective-C protocol identity ${id}`)
966
+ const pattern = new RegExp(`@protocol\\s+${name}\\b(?!\\s*;)`)
967
+ const candidates = headers.filter((header) => pattern.test(header.text))
968
+ if (candidates.length === 0)
969
+ throw new Error(`its headers have no definition of Objective-C protocol ${name}`)
970
+ const probe = path.join(work, 'objc-protocol-properties.m')
971
+ fs.writeFileSync(
972
+ probe,
973
+ // the module's own roots first: a defining header may rely on the
974
+ // declarations its umbrella imports before it, as NS_ENUM does
975
+ [
976
+ ...moduleMapHeaders(surface.modulemap).map((file) => path.join(headersDir, file)),
977
+ ...candidates.map(({ file }) => file),
978
+ ]
979
+ .map((file) => `#import ${JSON.stringify(file)}\n`)
980
+ .join(''),
981
+ )
982
+ const run = spawnSync(
983
+ path.join(toolchainBin, 'clang'),
984
+ [
985
+ '-x',
986
+ 'objective-c',
987
+ '-fobjc-arc',
988
+ '-fblocks',
989
+ '-fmodules',
990
+ `-fmodule-name=${surface.module}`,
991
+ '-fsyntax-only',
992
+ '-target',
993
+ IOS_SDK_TARGET,
994
+ ...flags,
995
+ ...(surface.moduleMapFlags ?? []),
996
+ '-I',
997
+ headersDir,
998
+ '-Xclang',
999
+ '-ast-dump-all=json',
1000
+ '-Xclang',
1001
+ '-ast-dump-filter',
1002
+ '-Xclang',
1003
+ name,
1004
+ probe,
1005
+ ],
1006
+ {
1007
+ encoding: 'utf8',
1008
+ env: swiftEnvironment(),
1009
+ maxBuffer: 256 * 1024 * 1024,
1010
+ },
1011
+ )
1012
+ if (run.error) throw run.error
1013
+ if (run.status !== 0)
1014
+ throw new Error(`Objective-C protocol ${name} does not parse: ${run.stderr.trim()}`)
1015
+ let found = false
1016
+ for (const chunk of run.stdout.split(/\n(?=\{\n)/).filter((part) => part.trim())) {
1017
+ const declaration: unknown = JSON.parse(chunk)
1018
+ if (
1019
+ !isRecord(declaration) ||
1020
+ declaration.kind !== 'ObjCProtocolDecl' ||
1021
+ declaration.name !== name ||
1022
+ !Array.isArray(declaration.inner)
1023
+ )
1024
+ continue
1025
+ found = true
1026
+ for (const child of declaration.inner) {
1027
+ if (
1028
+ !isRecord(child) ||
1029
+ child.kind !== 'ObjCPropertyDecl' ||
1030
+ typeof child.name !== 'string'
1031
+ )
1032
+ continue
1033
+ const getter =
1034
+ isRecord(child.getter) && typeof child.getter.name === 'string'
1035
+ ? child.getter.name
1036
+ : child.name
1037
+ const setter =
1038
+ isRecord(child.setter) && typeof child.setter.name === 'string'
1039
+ ? child.setter.name
1040
+ : `set${child.name[0]?.toUpperCase() ?? ''}${child.name.slice(1)}:`
1041
+ properties.set(`${id}(py)${child.name}`, {
1042
+ getter,
1043
+ ...(child.readonly === true ? {} : { setter }),
1044
+ })
1045
+ }
1046
+ }
1047
+ if (!found)
1048
+ throw new Error(`clang found no definition of Objective-C protocol ${name}`)
1049
+ }
1050
+ return properties
1051
+ }
1052
+
848
1053
  function objcDeclarationAST(
849
1054
  surface: ObjcSurface,
850
1055
  framework: boolean,
@@ -864,13 +1069,7 @@ function objcDeclarationAST(
864
1069
  )
865
1070
  .join(''),
866
1071
  )
867
- const flags: string[] = []
868
- for (let index = 0; index < search.length; index += 2) {
869
- const [flag, value] = [search[index]!, search[index + 1]!]
870
- // the swift resource directory contains swift overlays, not clang builtins.
871
- if (flag === '-resource-dir') continue
872
- flags.push(flag === '-sdk' ? '-isysroot' : flag, value)
873
- }
1072
+ const flags = clangSearchFlags(search)
874
1073
  const args = [
875
1074
  '-x',
876
1075
  'objective-c',
@@ -894,7 +1093,11 @@ function objcDeclarationAST(
894
1093
  ...(filter ? ['-Xclang', '-ast-dump-filter', '-Xclang', filter] : []),
895
1094
  probe,
896
1095
  ],
897
- { encoding: 'utf8', env: swiftEnvironment(), maxBuffer: 256 * 1024 * 1024 },
1096
+ {
1097
+ encoding: 'utf8',
1098
+ env: swiftEnvironment(),
1099
+ maxBuffer: 256 * 1024 * 1024,
1100
+ },
898
1101
  )
899
1102
  if (run.error) throw run.error
900
1103
  if (run.status !== 0)
@@ -1015,7 +1218,11 @@ function enumValues(
1015
1218
  '-ast-dump=json',
1016
1219
  probe,
1017
1220
  ],
1018
- { encoding: 'utf8', env: swiftEnvironment(), maxBuffer: 1024 * 1024 * 1024 },
1221
+ {
1222
+ encoding: 'utf8',
1223
+ env: swiftEnvironment(),
1224
+ maxBuffer: 1024 * 1024 * 1024,
1225
+ },
1019
1226
  )
1020
1227
  if (run.status !== 0)
1021
1228
  throw new Error(
@@ -16,8 +16,8 @@ import fs from 'node:fs'
16
16
  import os from 'node:os'
17
17
  import path from 'node:path'
18
18
  import { promisify } from 'node:util'
19
- import { cacheDir as peachCacheDir, swiftPackageCacheOptions } from './home-paths'
20
- import { ensureSwiftToolchain, swiftModuleToolchain } from './swift-distribution'
19
+ import { cacheDir as peachCacheDir } from './home-paths'
20
+ import { ensureSwiftToolchain, swiftModuleCompiler } from './swift-distribution'
21
21
  import lock from './swift-distribution.lock.json' with { type: 'json' }
22
22
  import {
23
23
  isSwiftNativeTranslationUnit,
@@ -27,6 +27,7 @@ import {
27
27
  import {
28
28
  privateSwiftDistributionRoot,
29
29
  swiftEnvironment,
30
+ swiftPackageCacheOptions,
30
31
  swiftToolchainBin,
31
32
  } from './swift-toolchain'
32
33
 
@@ -167,7 +168,7 @@ const string = (value: Json | undefined): string | undefined =>
167
168
  function swiftCommand(): string {
168
169
  const privateRoot = privateSwiftDistributionRoot()
169
170
  if (privateRoot)
170
- return path.join(swiftModuleToolchain(privateRoot).toolchainBin, 'swift')
171
+ return path.join(swiftModuleCompiler(privateRoot).toolchainBin, 'swift')
171
172
  return path.join(swiftToolchainBin(lock.release), 'swift')
172
173
  }
173
174
 
@@ -282,10 +282,17 @@ export function swiftNativeSupportFiles(
282
282
  }
283
283
 
284
284
  /** the modules a c-family source imports framework-style or with @import. */
285
- export function clangImportNames(text: string): string[] {
285
+ export function clangImportNames(
286
+ text: string,
287
+ isLocalHeader?: (header: string) => boolean,
288
+ ): string[] {
286
289
  return [
287
- ...text.matchAll(/^\s*(?:#\s*(?:import|include)\s*<(\w+)\/|@import\s+(\w+))/gm),
288
- ].map((match) => (match[1] ?? match[2])!)
290
+ ...text.matchAll(
291
+ /^\s*(?:#\s*(?:import|include)\s*<((\w+)\/[^>]+)>|@import\s+(\w+))/gm,
292
+ ),
293
+ ].flatMap((match) =>
294
+ match[1] && isLocalHeader?.(match[1]) ? [] : [(match[2] ?? match[3])!],
295
+ )
289
296
  }
290
297
 
291
298
  /**
@@ -343,6 +350,26 @@ export type SwiftClangSetting = { tool: 'c' | 'cxx' } & (
343
350
  | { flags: string[] }
344
351
  )
345
352
 
353
+ // glog 0.3.5 includes glog/log_severity.h inside namespace google; this clang
354
+ // imports the cocoapods glog module map into c++ units despite
355
+ // -fno-cxx-modules and fails with "import of module appears within namespace".
356
+ // apple clang leaves the map inert there, and swiftpm hands c settings to c++
357
+ // units too, so no clang settings carry it.
358
+ // this clang's default constant evaluator rejects fmt 11's checked format
359
+ // strings at c++20 ("consteval ... not a constant expression"); the new
360
+ // interpreter accepts them as apple clang does, but it crashes clang on other
361
+ // sources (jsi.cpp), so only units that see fmt headers take it.
362
+ export const fmtConstantInterpreterFlags = (flags: readonly string[]): string[] =>
363
+ flags.some((flag) => flag.includes('/fmt/'))
364
+ ? ['-fexperimental-new-constant-interpreter']
365
+ : []
366
+
367
+ export const withoutGlogModuleMap = (flags: readonly string[]): string[] =>
368
+ flags.filter(
369
+ (flag) =>
370
+ !(flag.startsWith('-fmodule-map-file=') && flag.endsWith('/glog.modulemap')),
371
+ )
372
+
346
373
  /** the PackageDescription entries of a target's declared c or c++ settings. */
347
374
  export function clangSettingEntries(
348
375
  settings: readonly SwiftClangSetting[] | undefined,
@@ -353,7 +380,7 @@ export function clangSettingEntries(
353
380
  ? []
354
381
  : 'headerSearchPath' in setting
355
382
  ? [`.headerSearchPath(${JSON.stringify(setting.headerSearchPath)})`]
356
- : [`.unsafeFlags(${JSON.stringify(setting.flags)})`],
383
+ : [`.unsafeFlags(${JSON.stringify(withoutGlogModuleMap(setting.flags))})`],
357
384
  )
358
385
  }
359
386
 
@@ -13,6 +13,7 @@ import {
13
13
  rmSync,
14
14
  writeFileSync,
15
15
  } from 'node:fs'
16
+ import { homedir } from 'node:os'
16
17
  import path from 'node:path'
17
18
  import { rnxHomeDir } from './home-paths'
18
19
  import { terminateProcessGroup } from './process-group'
@@ -152,6 +153,16 @@ export interface SwiftRootLease {
152
153
  register(child: ChildProcess): void
153
154
  }
154
155
 
156
+ /** CocoaPods keeps one download cache per user and rewrites a pod's cache
157
+ * entry with rsync --delete, so two installs fetching the same pod tear each
158
+ * other's tree. installs on one Mac take turns on that cache. */
159
+ export function withCocoaPodsCacheLock<T>(work: () => Promise<T>): Promise<T> {
160
+ return withSwiftRootLock(
161
+ process.env.CP_CACHE_DIR || path.join(homedir(), 'Library/Caches/CocoaPods'),
162
+ work,
163
+ )
164
+ }
165
+
155
166
  /** runs `work` as the only process using a swift build root. the in-process
156
167
  * queue orders one process's requests; two processes sharing a root each
157
168
  * rewrite its sources and manifest, and swiftpm's own build lock only orders