peachsim 0.1.1674 → 0.1.1692

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 (350) hide show
  1. package/cli/commands/control.ts +13 -1
  2. package/cli/commands/coverage-swift.ts +150 -27
  3. package/cli/commands/coverage.ts +219 -20
  4. package/cli/commands/detect.ts +10 -6
  5. package/cli/commands/inspect/actions.ts +1 -0
  6. package/cli/commands/inspect/core.ts +2 -0
  7. package/cli/commands/inspect/wait-ready.ts +7 -0
  8. package/cli/commands/screenshot.ts +12 -0
  9. package/cli/outbound-endpoints.ts +12 -0
  10. package/detox/index.ts +11 -1
  11. package/detox/jest-environment.cjs +14 -0
  12. package/dist-lib/agent-daemon-client.cjs +1 -1
  13. package/dist-lib/agent-events.cjs +1 -1
  14. package/dist-lib/attached-projects.cjs +1 -1
  15. package/dist-lib/auth/shared-session.cjs +1 -1
  16. package/dist-lib/backend-origin.cjs +1 -1
  17. package/dist-lib/beta.cjs +1 -1
  18. package/dist-lib/beta.mjs +1 -1
  19. package/dist-lib/bridge-constants.cjs +1 -1
  20. package/dist-lib/bridge-contract-input.cjs +1 -1
  21. package/dist-lib/bridge-contract-input.mjs +1 -1
  22. package/dist-lib/bridge-contract.cjs +1 -1
  23. package/dist-lib/bridge-contract.mjs +1 -1
  24. package/dist-lib/bundle-channel.cjs +4833 -2432
  25. package/dist-lib/capture-contract.cjs +1 -1
  26. package/dist-lib/capture-contract.mjs +1 -1
  27. package/dist-lib/cloud-contract.cjs +1 -1
  28. package/dist-lib/cloud-contract.mjs +1 -1
  29. package/dist-lib/cloud-test-args.cjs +1 -1
  30. package/dist-lib/cloud-test-args.mjs +1 -1
  31. package/dist-lib/cloud.cjs +1 -1
  32. package/dist-lib/cloud.mjs +1 -1
  33. package/dist-lib/config.cjs +1 -1
  34. package/dist-lib/config.mjs +1 -1
  35. package/dist-lib/detox/index.cjs +6 -4
  36. package/dist-lib/detox/jest-environment.cjs +14 -0
  37. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  38. package/dist-lib/expo-swift-bundle.cjs +3785 -1737
  39. package/dist-lib/expo-swift-metadata.cjs +1 -1
  40. package/dist-lib/expo-swift-metadata.mjs +1 -1
  41. package/dist-lib/home-paths.cjs +1 -1
  42. package/dist-lib/host/bridge-host.cjs +4253 -2205
  43. package/dist-lib/host/fetch-proxy-handler.cjs +20 -7
  44. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  45. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  46. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  47. package/dist-lib/host/websocket-proxy.cjs +1 -1
  48. package/dist-lib/index.cjs +2065 -796
  49. package/dist-lib/jump-to-source-babel.cjs +1 -1
  50. package/dist-lib/jump-to-source-native.cjs +1 -1
  51. package/dist-lib/kotlin-host.cjs +1 -1
  52. package/dist-lib/menu.cjs +1 -1
  53. package/dist-lib/menu.mjs +1 -1
  54. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  55. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  56. package/dist-lib/metro-production-bundle.cjs +1 -1
  57. package/dist-lib/metro-production-bundle.mjs +1 -1
  58. package/dist-lib/metro.cjs +6325 -4287
  59. package/dist-lib/native-app-identity-project.cjs +192 -55
  60. package/dist-lib/native-app-identity-project.mjs +235 -86
  61. package/dist-lib/native-app-identity.cjs +1 -1
  62. package/dist-lib/native-app-identity.mjs +1 -1
  63. package/dist-lib/native-firebase-metadata.cjs +1 -1
  64. package/dist-lib/native-firebase-metadata.mjs +1 -1
  65. package/dist-lib/plist.cjs +1 -1
  66. package/dist-lib/plist.mjs +1 -1
  67. package/dist-lib/profiles.cjs +1 -1
  68. package/dist-lib/public-brand.cjs +1 -1
  69. package/dist-lib/public-origins-lib-esm.json +27 -23
  70. package/dist-lib/public-origins-lib-static.json +1 -1
  71. package/dist-lib/public-origins-lib.json +156 -87
  72. package/dist-lib/react-native-host-modules.cjs +1 -1
  73. package/dist-lib/react-native-host-modules.mjs +1 -1
  74. package/dist-lib/reap-browser.cjs +2 -2
  75. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  76. package/dist-lib/sdk.cjs +3 -2
  77. package/dist-lib/sdk.mjs +3 -2
  78. package/dist-lib/skills.cjs +5036 -2833
  79. package/dist-lib/swift-compile.cjs +2937 -437
  80. package/dist-lib/swift-compile.mjs +2932 -435
  81. package/dist-lib/swift-package.cjs +137 -49
  82. package/dist-lib/swift-package.mjs +132 -49
  83. package/dist-lib/swift-submit.cjs +1 -1
  84. package/dist-lib/swift-submit.mjs +1 -1
  85. package/dist-lib/swift-toolchain.cjs +26 -11
  86. package/dist-lib/swift.cjs +1 -1
  87. package/dist-lib/vite-swift.cjs +6005 -1725
  88. package/dist-lib/vite.cjs +1911 -776
  89. package/dist-lib/worklet-executable.cjs +7 -4
  90. package/dist-lib/worklet-executable.mjs +7 -4
  91. package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -1
  92. package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +24 -2
  93. package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +11 -3
  94. package/dist-types/packages/peach-engine/src/webview-automation-host.d.ts +6 -0
  95. package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +8 -0
  96. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  97. package/dist-types/packages/peach-globals/src/nodeContract.d.ts +3 -2
  98. package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
  99. package/package.json +1 -1
  100. package/runtime-companion.json +1 -1
  101. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +60 -2
  102. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLAvailability.h +22 -0
  103. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBackgroundActivitySession.h +145 -0
  104. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBeaconIdentityCondition.h +113 -0
  105. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBeaconIdentityConstraint.h +34 -0
  106. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBeaconRegion.h +225 -0
  107. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBody.h +26 -0
  108. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLCircularGeographicCondition.h +59 -0
  109. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLCircularRegion.h +64 -0
  110. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLCondition.h +48 -0
  111. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLError.h +52 -0
  112. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLErrorDomain.h +24 -0
  113. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLGeocoder.h +55 -0
  114. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLHeading.h +117 -0
  115. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocation.h +9 -0
  116. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager+CLVisitExtensions.h +45 -0
  117. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +877 -0
  118. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManagerDelegate.h +225 -0
  119. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationPushServiceError.h +33 -0
  120. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationPushServiceExtension.h +28 -0
  121. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationUpdater.h +250 -0
  122. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLMonitor.h +140 -0
  123. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLMonitorConfiguration.h +77 -0
  124. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLMonitoringEvent.h +184 -0
  125. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLMonitoringRecord.h +57 -0
  126. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLPlacemark.h +98 -0
  127. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +123 -0
  128. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLServiceSession.h +211 -0
  129. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLVisit.h +66 -0
  130. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CoreLocation.h +46 -0
  131. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Modules/module.modulemap +7 -0
  132. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +117 -2
  133. package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceBase.h +52 -0
  134. package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceObjC.h +240 -0
  135. package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceRef.h +474 -0
  136. package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceTypes.h +66 -0
  137. package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Modules/module.modulemap +10 -0
  138. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFComposeAssistantViewController.h +29 -0
  139. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeControllerDeferredAction.h +14 -0
  140. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeViewController.h +162 -0
  141. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailDraft.h +24 -0
  142. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController+UPI.h +31 -0
  143. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController.h +169 -0
  144. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MessageUI.h +13 -0
  145. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Modules/module.modulemap +11 -0
  146. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4AccelerationStructure.h +9 -0
  147. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4Archive.h +16 -0
  148. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4ArgumentTable.h +17 -0
  149. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4BinaryFunction.h +13 -0
  150. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4BinaryFunctionDescriptor.h +14 -0
  151. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4BufferRange.h +79 -0
  152. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommandAllocator.h +15 -0
  153. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommandBuffer.h +17 -0
  154. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommandEncoder.h +16 -0
  155. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommandQueue.h +19 -0
  156. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommitFeedback.h +15 -0
  157. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4Compiler.h +13 -0
  158. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CompilerTask.h +13 -0
  159. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4ComputeCommandEncoder.h +19 -0
  160. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4ComputePipeline.h +13 -0
  161. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4Counters.h +19 -0
  162. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4FunctionDescriptor.h +13 -0
  163. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4LibraryDescriptor.h +13 -0
  164. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4LibraryFunctionDescriptor.h +13 -0
  165. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4LinkingDescriptor.h +13 -0
  166. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4MachineLearningCommandEncoder.h +17 -0
  167. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4MachineLearningPipeline.h +13 -0
  168. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4MeshRenderPipeline.h +13 -0
  169. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4PipelineDataSetSerializer.h +13 -0
  170. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4PipelineState.h +13 -0
  171. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4RenderCommandEncoder.h +17 -0
  172. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4RenderPass.h +17 -0
  173. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4RenderPipeline.h +13 -0
  174. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4SpecializedFunctionDescriptor.h +13 -0
  175. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4StitchedFunctionDescriptor.h +13 -0
  176. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4TileRenderPipeline.h +13 -0
  177. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLAccelerationStructure.h +1212 -0
  178. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLAccelerationStructureCommandEncoder.h +322 -0
  179. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLAccelerationStructureTypes.h +224 -0
  180. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLAllocation.h +22 -0
  181. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLArgument.h +279 -0
  182. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLArgumentEncoder.h +199 -0
  183. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLBinaryArchive.h +142 -0
  184. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLBlitCommandEncoder.h +266 -0
  185. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLBlitPass.h +82 -0
  186. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLBuffer.h +94 -0
  187. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCaptureManager.h +113 -0
  188. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCaptureScope.h +43 -0
  189. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCommandBuffer.h +449 -0
  190. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCommandEncoder.h +148 -0
  191. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCommandQueue.h +102 -0
  192. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLComputeCommandEncoder.h +350 -0
  193. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLComputePass.h +90 -0
  194. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLComputePipeline.h +274 -0
  195. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCounters.h +225 -0
  196. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDataType.h +232 -0
  197. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDefines.h +39 -0
  198. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDepthStencil.h +93 -0
  199. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h +1122 -0
  200. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDeviceCertification.h +29 -0
  201. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDrawable.h +36 -0
  202. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDynamicLibrary.h +81 -0
  203. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLEvent.h +79 -0
  204. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFence.h +22 -0
  205. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionConstantValues.h +30 -0
  206. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionDescriptor.h +95 -0
  207. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionHandle.h +29 -0
  208. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionLog.h +37 -0
  209. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionStitching.h +131 -0
  210. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLGPUAddress.h +19 -0
  211. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLHeap.h +284 -0
  212. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIOCommandBuffer.h +10 -0
  213. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIOCommandQueue.h +11 -0
  214. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIOCompressor.h +10 -0
  215. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIndirectCommandBuffer.h +157 -0
  216. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIndirectCommandEncoder.h +110 -0
  217. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIntersectionFunctionTable.h +186 -0
  218. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLLibrary.h +549 -0
  219. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLLinkedFunctions.h +57 -0
  220. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLLogState.h +65 -0
  221. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLParallelRenderCommandEncoder.h +77 -0
  222. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLPipeline.h +57 -0
  223. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLPixelFormat.h +342 -0
  224. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRasterizationRate.h +323 -0
  225. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRenderCommandEncoder.h +1068 -0
  226. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRenderPass.h +411 -0
  227. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRenderPipeline.h +788 -0
  228. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResidencySet.h +141 -0
  229. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResource.h +307 -0
  230. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResourceStateCommandEncoder.h +125 -0
  231. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResourceStatePass.h +85 -0
  232. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResourceViewPool.h +22 -0
  233. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLSampler.h +252 -0
  234. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLStageInputOutputDescriptor.h +158 -0
  235. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLTensor.h +17 -0
  236. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLTexture.h +460 -0
  237. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLTextureViewPool.h +18 -0
  238. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLTypes.h +125 -0
  239. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLVertexDescriptor.h +153 -0
  240. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLVisibleFunctionTable.h +45 -0
  241. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/Metal.h +94 -0
  242. package/sdk/ios/System/Library/Frameworks/Metal.framework/Modules/module.modulemap +6 -0
  243. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +10 -0
  244. package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UTDefines.h +35 -0
  245. package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UTTagClass.h +33 -0
  246. package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UTType.h +504 -0
  247. package/sdk/ios/System/Library/Frameworks/_LocationEssentials.framework/Headers/CLEssentialsAvailability.h +14 -0
  248. package/sdk/ios/System/Library/Frameworks/_LocationEssentials.framework/Headers/CLLocationEssentials.h +444 -0
  249. package/sdk/ios/System/Library/Frameworks/_LocationEssentials.framework/Headers/LocationEssentials.h +14 -0
  250. package/sdk/ios/System/Library/Frameworks/_LocationEssentials.framework/Modules/module.modulemap +14 -0
  251. package/sdk/ios/usr/include/arm/param.h +151 -0
  252. package/sdk/ios/usr/include/complex.h +167 -0
  253. package/sdk/ios/usr/include/dispatch/dispatch.h +8 -0
  254. package/sdk/ios/usr/include/dlfcn.h +1 -2
  255. package/sdk/ios/usr/include/mach/mach_types.h +1 -0
  256. package/sdk/ios/usr/include/machine/param.h +42 -0
  257. package/sdk/ios/usr/include/math.h +835 -2
  258. package/sdk/ios/usr/include/net/if.h +1 -2
  259. package/sdk/ios/usr/include/peach/pthread.h +4 -4
  260. package/sdk/ios/usr/include/pthread/qos.h +304 -0
  261. package/sdk/ios/usr/include/sys/_types/_fd_clr.h +31 -0
  262. package/sdk/ios/usr/include/sys/_types/_fd_copy.h +31 -0
  263. package/sdk/ios/usr/include/sys/_types/_fd_def.h +121 -0
  264. package/sdk/ios/usr/include/sys/_types/_fd_isset.h +31 -0
  265. package/sdk/ios/usr/include/sys/_types/_fd_set.h +31 -0
  266. package/sdk/ios/usr/include/sys/_types/_fd_setsize.h +31 -0
  267. package/sdk/ios/usr/include/sys/_types/_fd_zero.h +31 -0
  268. package/sdk/ios/usr/include/sys/cdefs.h +3 -1
  269. package/sdk/ios/usr/include/sys/param.h +235 -0
  270. package/sdk/ios/usr/include/sys/proc.h +1 -0
  271. package/sdk/ios/usr/include/sys/qos.h +151 -12
  272. package/sdk/ios/wasm/include/__typedef_sigset_t.h +7 -0
  273. package/sdk/ios/wasm/include/fcntl.h +11 -0
  274. package/sdk/ios/wasm/include/mach/machine/boolean.h +2 -0
  275. package/sdk/ios/wasm/include/mach/machine/exception.h +5 -0
  276. package/sdk/ios/wasm/include/mach/machine/kern_return.h +2 -0
  277. package/sdk/ios/wasm/include/mach/machine/processor_info.h +2 -0
  278. package/sdk/ios/wasm/include/mach/machine/rpc.h +2 -0
  279. package/sdk/ios/wasm/include/mach/machine/thread_state.h +3 -0
  280. package/sdk/ios/wasm/include/mach/machine/thread_status.h +3 -0
  281. package/sdk/ios/wasm/include/mach/machine/vm_param.h +3 -0
  282. package/sdk/ios/wasm/include/mach/machine/vm_types.h +18 -0
  283. package/sdk/ios/wasm/include/machine/_types.h +153 -0
  284. package/sdk/ios/wasm/include/machine/endian.h +2 -0
  285. package/sdk/ios/wasm/include/machine/limits.h +2 -0
  286. package/sdk/ios/wasm/include/machine/types.h +30 -0
  287. package/sdk/ios/wasm/include/poll.h +8 -0
  288. package/sdk/ios/wasm/include/pthread.h +50 -0
  289. package/sdk/ios/wasm/include/signal.h +72 -0
  290. package/sdk/ios/wasm/include/stdlib.h +3 -0
  291. package/sdk/ios/wasm/include/string.h +10 -0
  292. package/sdk/ios/wasm/include/sys/_pthread/_pthread_attr_t.h +7 -0
  293. package/sdk/ios/wasm/include/sys/_pthread/_pthread_t.h +7 -0
  294. package/sdk/ios/wasm/include/sys/mman.h +122 -0
  295. package/sdk/ios/wasm/include/sys/select.h +37 -0
  296. package/sdk/ios/wasm/include/sys/signal.h +259 -0
  297. package/sdk/ios/wasm/include/sys/socket.h +8 -0
  298. package/sdk/ios/wasm/include/sys/types.h +14 -0
  299. package/sdk/ios/wasm/include/sys/ucontext.h +1 -0
  300. package/sdk/ios/wasm/include/sys/uio.h +11 -0
  301. package/sdk/ios/wasm/include/sys/wait.h +89 -0
  302. package/sdk/ios/wasm/include/time.h +8 -0
  303. package/sdk/ios/wasm/include/unistd.h +17 -0
  304. package/src/bridge-contract.ts +2 -0
  305. package/src/chromium-admission.ts +10 -5
  306. package/src/device-catalog.ts +4 -4
  307. package/src/generated/swift-c-predefines.json +1988 -0
  308. package/src/host/fetch-proxy-handler.ts +20 -0
  309. package/src/metro-plugin.ts +5 -2
  310. package/src/nitro-adapter.lock.json +6 -6
  311. package/src/nitro-bundle.ts +1 -0
  312. package/src/nitro-compile.ts +67 -2
  313. package/src/nitroContract.ts +18 -2
  314. package/src/numbered-lock.ts +72 -0
  315. package/src/react-native-coverage/capability-reference-resolution.ts +62 -5
  316. package/src/react-native-coverage/capability-source-references.ts +50 -13
  317. package/src/react-native-coverage/native-source-credit.ts +126 -0
  318. package/src/react-native-coverage/native-source-ranges-file.ts +38 -0
  319. package/src/react-native-coverage/native-surface.ts +49 -0
  320. package/src/react-native-coverage/verified-reach.ts +22 -2
  321. package/src/runtime-assets.ts +17 -0
  322. package/src/swift-compile.ts +530 -97
  323. package/src/swift-coverage/indexing.ts +17 -1
  324. package/src/swift-coverage/package.ts +3 -1
  325. package/src/swift-coverage/sdk.ts +71 -0
  326. package/src/swift-coverage/source.ts +74 -2
  327. package/src/swift-coverage/types.ts +6 -0
  328. package/src/swift-coverage/xcode-assets.ts +62 -2
  329. package/src/swift-coverage/xcode-packages.ts +11 -6
  330. package/src/swift-distribution.lock.json +12 -12
  331. package/src/swift-host.ts +457 -62
  332. package/src/swift-objc-compile.ts +26 -26
  333. package/src/swift-objc-metadata.ts +2 -8
  334. package/src/swift-objc-platform.ts +53 -0
  335. package/src/swift-objc-standin.ts +66 -12
  336. package/src/swift-package-manifest.ts +196 -28
  337. package/src/swift-package.ts +186 -60
  338. package/src/swift-packages.ts +298 -88
  339. package/src/swift-source-file.ts +10 -15
  340. package/src/swift-source-pods.ts +288 -0
  341. package/src/swift-standins.ts +87 -13
  342. package/src/swift-submit.ts +5 -0
  343. package/src/swift-toolchain.ts +32 -10
  344. package/src/swiftContract.ts +160 -75
  345. package/src/target-matcher.ts +15 -2
  346. package/src/vite-plugin-one.ts +5 -4
  347. package/src/worker-system-chunks.ts +7 -1
  348. package/src/worklet-executable.ts +7 -3
  349. package/src/xcode-json-project.ts +14 -2
  350. package/src/xcode-project.ts +193 -69
@@ -23,6 +23,7 @@ import os from 'node:os'
23
23
  import path from 'node:path'
24
24
  import yaml from 'yaml'
25
25
  import { admittedMacBuilderSlot } from './admitted-mac-build'
26
+ import cPredefinesJson from './generated/swift-c-predefines.json' with { type: 'json' }
26
27
  import { rnxHomeDir, swiftPackageCacheOptions } from './home-paths'
27
28
  import { isRecord } from './is-record'
28
29
  import { terminateProcessGroup } from './process-group'
@@ -41,12 +42,20 @@ import {
41
42
  swiftObjCPrivateImports,
42
43
  } from './swift-objc-import'
43
44
  import { validateObjcPeerStartupLibraries } from './swift-objc-metadata'
44
- import { materializeObjcSdk, objcView, WASI_EMULATION_FLAGS } from './swift-objc-standin'
45
45
  import {
46
+ iosDeploymentMinimum,
47
+ materializeObjcSdk,
48
+ objcSdkIntakeFlags,
49
+ objcView,
50
+ } from './swift-objc-standin'
51
+ import {
52
+ isSwiftNativeTranslationUnit,
46
53
  OBJC_RESOURCE_ACCESSOR_BODY,
47
54
  OBJC_RESOURCE_ACCESSOR_HEADER,
48
55
  swiftManifestCxxLanguageStandard,
56
+ swiftManifestDeclarations,
49
57
  swiftManifestTargets,
58
+ swiftManifestPackages,
50
59
  swiftObjCResourceAccessor,
51
60
  swiftObjCResourceBundleName,
52
61
  swiftPackagePartition,
@@ -65,10 +74,13 @@ import {
65
74
  } from './swift-toolchain'
66
75
  import {
67
76
  isSwiftNativeTargets,
77
+ isSwiftPackageFiles,
68
78
  isSwiftObjCPeerStartup,
69
79
  isSwiftResourceBundles,
80
+ isSwiftResourcePath,
70
81
  SWIFT_NATIVE_INPUT_ROOT,
71
82
  SWIFT_NATIVE_SDK_INCLUDE,
83
+ type SwiftPackageFiles,
72
84
  type SwiftNativeTarget,
73
85
  type SwiftObjCPeerStartup,
74
86
  type SwiftProjectPreparation,
@@ -200,6 +212,8 @@ const BUILD_JOBS = String(
200
212
 
201
213
  export interface SwiftCompileInput {
202
214
  files: Record<string, string>
215
+ packageFiles?: SwiftPackageFiles
216
+ packageGuestImports?: string[]
203
217
  objcPeerStartup?: SwiftObjCPeerStartup
204
218
  nativeTargets?: SwiftNativeTarget[]
205
219
  metalSources?: Record<string, string>
@@ -536,7 +550,7 @@ const SWIFT_IMPORT =
536
550
  // through `!`, `&&` and `||`.
537
551
  function swiftCondition(
538
552
  text: string,
539
- available: ReadonlySet<string>,
553
+ available?: ReadonlySet<string>,
540
554
  ): boolean | undefined {
541
555
  const tokens = text.match(/\w+\s*\([^()]*\)|&&|\|\||!|\(|\)|\w+/g) ?? []
542
556
  let index = 0
@@ -557,8 +571,8 @@ function swiftCondition(
557
571
  if (!call) return undefined
558
572
  const [, name, argument] = call
559
573
  if (name === 'os') return argument === 'iOS' || argument === 'WASI'
560
- if (name === 'canImport') return available.has(argument!)
561
- if (name === 'targetEnvironment') return false
574
+ if (name === 'canImport') return available?.has(argument!)
575
+ if (name === 'targetEnvironment') return argument === 'simulator'
562
576
  if (name === 'arch') return argument === 'wasm32'
563
577
  return undefined
564
578
  }
@@ -588,24 +602,18 @@ function swiftCondition(
588
602
  return either()
589
603
  }
590
604
 
591
- /**
592
- * the modules a source imports, in order. with `available`, only imports the
593
- * wasm compile certainly reaches: those outside every `#if`, or in a branch
594
- * whose condition holds there, `os(iOS)` included since the compile rewrites
595
- * it to true. a branch the scan cannot decide may compile out, so its
596
- * imports stay out of the list.
597
- */
598
- export function swiftImportNames(
605
+ // each line's branch state under the app's wasm compilation conditions.
606
+ // directives themselves are not executable source.
607
+ function* swiftConditionalLines(
599
608
  contents: string,
600
609
  available?: ReadonlySet<string>,
601
- ): string[] {
602
- const names: string[] = []
610
+ ): Generator<{ line: string; active: boolean | undefined }> {
603
611
  // per open `#if`: whether its current branch is active, and whether an
604
612
  // earlier branch was taken (or may have been)
605
613
  const frames: { active: boolean | undefined; taken: boolean | undefined }[] = []
606
614
  for (const line of contents.split('\n')) {
607
615
  const directive = /^\s*#(if|elseif|else|endif)\b(.*)$/.exec(line)
608
- if (directive && available) {
616
+ if (directive) {
609
617
  const [, kind, rest] = directive
610
618
  const condition = (rest ?? '').replace(/\/\/.*$/, '').trim()
611
619
  if (kind === 'if') {
@@ -628,9 +636,34 @@ export function swiftImportNames(
628
636
  ? holds
629
637
  : undefined
630
638
  }
639
+ yield { line, active: false }
631
640
  continue
632
641
  }
633
- if (available && frames.some((frame) => frame.active !== true)) continue
642
+ yield {
643
+ line,
644
+ active: frames.some((frame) => frame.active === false)
645
+ ? false
646
+ : frames.every((frame) => frame.active === true)
647
+ ? true
648
+ : undefined,
649
+ }
650
+ }
651
+ }
652
+
653
+ /**
654
+ * the modules a source imports, in order. with `available`, only imports the
655
+ * wasm compile certainly reaches: those outside every `#if`, or in a branch
656
+ * whose condition holds there, `os(iOS)` included since the compile rewrites
657
+ * it to true. a branch the scan cannot decide may compile out, so its
658
+ * imports stay out of the list.
659
+ */
660
+ export function swiftImportNames(
661
+ contents: string,
662
+ available?: ReadonlySet<string>,
663
+ ): string[] {
664
+ const names: string[] = []
665
+ for (const { line, active } of swiftConditionalLines(contents, available)) {
666
+ if (available && active !== true) continue
634
667
  const name = SWIFT_IMPORT.exec(line)?.[1]
635
668
  if (name) names.push(name)
636
669
  }
@@ -645,11 +678,11 @@ export function swiftPeachModules(moduleRoot: string): string[] {
645
678
  const distribution = swiftDistributionAt(moduleRoot)
646
679
  return distribution
647
680
  ? distribution.modules
648
- : [
649
- ...readFileSync(path.join(moduleRoot, 'Package.swift'), 'utf8').matchAll(
650
- /\.(?:target|systemLibrary)\(\s*name:\s*"([^"]+)"/g,
651
- ),
652
- ].map((match) => match[1]!)
681
+ : swiftManifestDeclarations(
682
+ readFileSync(path.join(moduleRoot, 'Package.swift'), 'utf8'),
683
+ )
684
+ .filter((target) => !target.executable)
685
+ .map((target) => target.name)
653
686
  }
654
687
 
655
688
  const sdkPaths = new Map<string, { sysroot: string; resources: string }>()
@@ -723,16 +756,22 @@ export function swiftAvailableModules(
723
756
  * `available`) that nothing available provides, each with the files
724
757
  * importing it. the compiler stops at the first
725
758
  * missing module; this names all of them at once.
759
+ * `providedByFile` names the compiler modules each file's own target
760
+ * settings provide, which no sdk ships: Builtin, which the compiler
761
+ * synthesizes when the target enables the BuiltinModule feature.
726
762
  */
727
763
  export function missingSwiftModules(
728
764
  files: Record<string, string>,
729
765
  available: ReadonlySet<string>,
766
+ providedByFile: (file: string) => readonly string[] = () => [],
730
767
  ): Map<string, string[]> {
731
768
  const missing = new Map<string, string[]>()
732
769
  for (const [file, contents] of Object.entries(files)) {
733
770
  if (!file.endsWith('.swift') || file === 'Package.swift') continue
734
- for (const name of new Set(swiftImportNames(contents, available))) {
735
- if (available.has(name)) continue
771
+ const extra = providedByFile(file)
772
+ const scoped = extra.length === 0 ? available : new Set([...available, ...extra])
773
+ for (const name of new Set(swiftImportNames(contents, scoped))) {
774
+ if (scoped.has(name)) continue
736
775
  missing.set(name, [...(missing.get(name) ?? []), file])
737
776
  }
738
777
  }
@@ -825,7 +864,7 @@ const EXECUTABLE_LINK_FLAGS = ` "-Xclang-linker", "-O0",
825
864
  const REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n'
826
865
 
827
866
  /** bump with any change to the emitted multi-target manifest text. */
828
- export const MULTI_MANIFEST_VERSION = 40
867
+ export const MULTI_MANIFEST_VERSION = 43
829
868
 
830
869
  // build-cli replaces this in every bundle; source runs read the files directly.
831
870
  declare const __SWIFT_COMPILER_DIGEST__: string | undefined
@@ -882,6 +921,11 @@ export function swiftArtifactHash(
882
921
  ),
883
922
  )
884
923
  hash.update(JSON.stringify(input.nativeTargets ?? []))
924
+ hash.update(JSON.stringify(input.packageGuestImports ?? []))
925
+ for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
926
+ hash.update(`package-file\0${file}\0`)
927
+ hash.update(createHash('sha256').update(input.packageFiles![file]!).digest())
928
+ }
885
929
  hash.update(JSON.stringify(input.objcPeerStartup ?? null))
886
930
  for (const target of Object.keys(input.libraries ?? {}).sort()) {
887
931
  hash.update(`library\n${target}\n`)
@@ -929,14 +973,33 @@ interface SwiftNativeTargetPlan {
929
973
  late?: { name: string; producers: string[] }
930
974
  }
931
975
 
976
+ function swiftCrossImportFlags(moduleRoot: string, distribution: boolean): string[] {
977
+ const overlayRoot = path.join(
978
+ moduleRoot,
979
+ distribution ? 'modules' : 'cross-import-overlays',
980
+ )
981
+ return readdirSync(overlayRoot, { encoding: 'utf8', recursive: true })
982
+ .filter((file) => file.endsWith('.swiftoverlay'))
983
+ .sort((left, right) => left.localeCompare(right))
984
+ .flatMap((file) => [
985
+ '-Xfrontend',
986
+ '-swift-module-cross-import',
987
+ '-Xfrontend',
988
+ path.basename(path.dirname(file), '.swiftcrossimport'),
989
+ '-Xfrontend',
990
+ path.join(overlayRoot, file),
991
+ ])
992
+ }
993
+
932
994
  export function emitSwiftPackageManifest(args: {
933
995
  targets: SwiftPackageTarget[]
996
+ packages?: ReadonlyMap<string, string>
934
997
  cxxLanguageStandard?: string
935
998
  native?: Map<string, SwiftNativeTargetPlan>
936
999
  headerDirectory?: string
937
- objcExports?: { modules: Set<string>; flags: string[]; rootModule: string }
938
- /** the objective-c runtime and sdk flags every original native unit compiles with. */
939
- nativeFlags?: string[]
1000
+ objcExports?: { modules: Set<string>; rootModule: string }
1001
+ /** the objective-c runtime, sdk and platform flags each target's original native units compile with. */
1002
+ nativeFlags?: Map<string, string[]>
940
1003
  siblings: Map<string, string[]>
941
1004
  moduleRoot: string
942
1005
  oneModule?: boolean
@@ -985,21 +1048,7 @@ export function emitSwiftPackageManifest(args: {
985
1048
  .join('\n') + '\n',
986
1049
  )
987
1050
  }
988
- const overlayRoot = path.join(
989
- moduleRoot,
990
- distribution ? 'modules' : 'cross-import-overlays',
991
- )
992
- const overlayFlags = readdirSync(overlayRoot, { encoding: 'utf8', recursive: true })
993
- .filter((file) => file.endsWith('.swiftoverlay'))
994
- .sort((left, right) => left.localeCompare(right))
995
- .flatMap((file) => [
996
- '-Xfrontend',
997
- '-swift-module-cross-import',
998
- '-Xfrontend',
999
- path.basename(path.dirname(file), '.swiftcrossimport'),
1000
- '-Xfrontend',
1001
- path.join(overlayRoot, file),
1002
- ])
1051
+ const overlayFlags = swiftCrossImportFlags(moduleRoot, Boolean(distribution))
1003
1052
  .map((flag) => `, ${JSON.stringify(flag)}`)
1004
1053
  .join('')
1005
1054
  const executable = targets.find((target) => target.executable)
@@ -1030,6 +1079,17 @@ export function emitSwiftPackageManifest(args: {
1030
1079
  const defines = (target.defines ?? [])
1031
1080
  .map((name) => ` .define(${JSON.stringify(name)}),`)
1032
1081
  .join('')
1082
+ const features = (target.experimentalFeatures ?? [])
1083
+ .map((name) => ` .enableExperimentalFeature(${JSON.stringify(name)}),`)
1084
+ .join('')
1085
+ const upcoming = (target.upcomingFeatures ?? [])
1086
+ .map((name) => ` .enableUpcomingFeature(${JSON.stringify(name)}),`)
1087
+ .join('')
1088
+ // the manifest's own raw flags last, where swiftpm puts a target's
1089
+ // settings: after the build's defaults, so they win as they do in xcode.
1090
+ const upstream = (target.swiftFlags ?? [])
1091
+ .map((flag) => `, ${JSON.stringify(flag)}`)
1092
+ .join('')
1033
1093
  // a distribution's modules import from its modules/ directory, and its
1034
1094
  // objects link as inputs, exactly as a source build links every object it
1035
1095
  // compiled: whole, and ahead of the sdk libraries, so PeachICU's
@@ -1073,9 +1133,16 @@ export function emitSwiftPackageManifest(args: {
1073
1133
  )
1074
1134
  ? `, "-emit-objc-header-path", ${JSON.stringify(path.join(args.headerDirectory, `${target.name}-${args.objcExports?.modules.has(target.name) ? 'Cxx' : 'Swift'}.h`))}`
1075
1135
  : ''
1076
- const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${exports} .unsafeFlags(["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ''}${imports}${nativeImports}${nativeImportFlags}${header}])]`
1136
+ const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming}${exports} .unsafeFlags(["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ''}${imports}${nativeImports}${nativeImportFlags}${header}${upstream}])]`
1077
1137
  const deps = [
1078
1138
  ...new Set([
1139
+ ...(target.dependencies ?? []).flatMap((dependency) =>
1140
+ dependency.kind === 'product'
1141
+ ? [
1142
+ `.product(name: ${JSON.stringify(dependency.name)}, package: ${JSON.stringify(dependency.package)})`,
1143
+ ]
1144
+ : [],
1145
+ ),
1079
1146
  ...(target.executable
1080
1147
  ? [
1081
1148
  ...new Set([
@@ -1154,12 +1221,12 @@ export function emitSwiftPackageManifest(args: {
1154
1221
  const cxxDefines = macroSettings(target.cxxDefines)
1155
1222
  const nativeSettings = native?.clang
1156
1223
  ? [
1157
- `cSettings: [${cDefines} .unsafeFlags(${JSON.stringify([...(args.objcExports?.flags ?? args.nativeFlags ?? []), ...native.clang.flags])})]`,
1158
- `cxxSettings: [${cxxDefines} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.objcExports?.flags ?? args.nativeFlags ?? []), ...native.clang.cxxFlags])})]`,
1224
+ `cSettings: [${cDefines} .unsafeFlags(${JSON.stringify([...(args.nativeFlags?.get(target.name) ?? []), ...native.clang.flags])})]`,
1225
+ `cxxSettings: [${cxxDefines} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.nativeFlags?.get(target.name) ?? []), ...native.clang.cxxFlags])})]`,
1159
1226
  ].join(', ')
1160
1227
  : [
1161
- `cSettings: [${cDefines} .unsafeFlags(${JSON.stringify([...(args.objcExports?.flags ?? args.nativeFlags ?? []), ...(native?.flags ?? [])])})]`,
1162
- `cxxSettings: [${cxxDefines} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.objcExports?.flags ?? args.nativeFlags ?? []), ...(native?.cxxFlags ?? [])])})]`,
1228
+ `cSettings: [${cDefines} .unsafeFlags(${JSON.stringify([...(args.nativeFlags?.get(target.name) ?? []), ...(native?.flags ?? [])])})]`,
1229
+ `cxxSettings: [${cxxDefines} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.nativeFlags?.get(target.name) ?? []), ...(native?.cxxFlags ?? [])])})]`,
1163
1230
  ].join(', ')
1164
1231
  return [
1165
1232
  ` ${kind}(`,
@@ -1177,6 +1244,9 @@ export function emitSwiftPackageManifest(args: {
1177
1244
  : native?.flags
1178
1245
  ? [` sources: ${JSON.stringify(native.sources)},`]
1179
1246
  : []),
1247
+ ...(!native?.clang && target.publicHeadersPath !== undefined
1248
+ ? [` publicHeadersPath: ${JSON.stringify(target.publicHeadersPath)},`]
1249
+ : []),
1180
1250
  // the native backend supplies dependency module maps without their
1181
1251
  // compiled modules. textual c++ includes keep those dependencies usable.
1182
1252
  ` ${clang ? nativeSettings : swiftSettings}${link}`,
@@ -1193,7 +1263,13 @@ export function emitSwiftPackageManifest(args: {
1193
1263
  'let package = Package(',
1194
1264
  ' name: "app",',
1195
1265
  ` products: [.executable(name: "${executable.name}", targets: ["${executable.name}"])],`,
1196
- ` dependencies: [${distribution ? '' : `.package(path: "${moduleRoot}")`}],`,
1266
+ ` dependencies: [${[
1267
+ ...(distribution ? [] : [`.package(path: ${JSON.stringify(moduleRoot)})`]),
1268
+ ...[...(args.packages ?? [])].map(
1269
+ ([name, directory]) =>
1270
+ `.package(name: ${JSON.stringify(name)}, path: ${JSON.stringify(directory)})`,
1271
+ ),
1272
+ ].join(', ')}],`,
1197
1273
  ' targets: [',
1198
1274
  ...targets.map(stanza),
1199
1275
  ...(args.objcExports
@@ -1203,7 +1279,7 @@ export function emitSwiftPackageManifest(args: {
1203
1279
  ' path: "PeachObjCExports",',
1204
1280
  ` sources: ${JSON.stringify(['root.m', ...[...args.objcExports.modules].map((name) => `${name}.m`)])},`,
1205
1281
  ' publicHeadersPath: "include",',
1206
- ` cSettings: [.unsafeFlags(${JSON.stringify([...args.objcExports.flags.filter((flag) => flag !== '-fobjc-arc'), '-fno-objc-arc', '-Xclang', '-disable-objc-default-synthesize-properties'])})]),`,
1282
+ ` cSettings: [.unsafeFlags(${JSON.stringify([...args.nativeFlags!.get(args.objcExports.rootModule)!.filter((flag) => flag !== '-fobjc-arc'), '-fno-objc-arc', '-Xclang', '-disable-objc-default-synthesize-properties'])})]),`,
1207
1283
  ]
1208
1284
  : []),
1209
1285
  ...[...(args.native?.entries() ?? [])].flatMap(([name, native]) => {
@@ -1225,8 +1301,8 @@ export function emitSwiftPackageManifest(args: {
1225
1301
  ` path: ${JSON.stringify(native.clang ? '.' : native.path)},`,
1226
1302
  ` sources: ${JSON.stringify(native.clang ? group.sources.map((source) => path.posix.join(native.path, source)) : group.sources)},`,
1227
1303
  ` publicHeadersPath: ${JSON.stringify(native.clang ? path.posix.dirname(native.clang.modulemap) : 'include')},`,
1228
- ` cSettings: [${macroSettings(owner?.cDefines)} .unsafeFlags(${JSON.stringify([...(args.objcExports?.flags ?? args.nativeFlags ?? []), ...group.flags])})],`,
1229
- ` cxxSettings: [${macroSettings(owner?.cxxDefines)} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.objcExports?.flags ?? args.nativeFlags ?? []), '-I', native.includeDirectory, '-I', args.headerDirectory, ...group.cxxFlags])})]),`,
1304
+ ` cSettings: [${macroSettings(owner?.cDefines)} .unsafeFlags(${JSON.stringify([...(args.nativeFlags?.get(name) ?? []), ...group.flags])})],`,
1305
+ ` cxxSettings: [${macroSettings(owner?.cxxDefines)} .unsafeFlags(${JSON.stringify(['-fno-cxx-modules', ...(args.nativeFlags?.get(name) ?? []), '-I', native.includeDirectory, '-I', args.headerDirectory, ...group.cxxFlags])})]),`,
1230
1306
  ])
1231
1307
  : []
1232
1308
  }),
@@ -5722,9 +5798,12 @@ export function swiftSourceClosure(
5722
5798
  return Object.fromEntries(Object.entries(files).filter(([file]) => included.has(file)))
5723
5799
  }
5724
5800
 
5725
- /** Swift's application entry declarations, ignoring comments and strings. */
5801
+ /** application entries, excluding comments, strings and inactive branches. */
5726
5802
  export function swiftApplicationEntry(file: string, source: string): boolean {
5727
- const { tokens } = swiftCodeScan(source)
5803
+ const code = [...swiftConditionalLines(swiftCodeMask(source))]
5804
+ .map(({ line, active }) => (active === false ? ' '.repeat(line.length) : line))
5805
+ .join('\n')
5806
+ const { tokens } = swiftCodeScan(code)
5728
5807
  let depth = 0
5729
5808
  for (const at of tokens) {
5730
5809
  if (source[at] === '{') depth++
@@ -5741,6 +5820,287 @@ export function swiftApplicationEntry(file: string, source: string): boolean {
5741
5820
  return false
5742
5821
  }
5743
5822
 
5823
+ // a c-family entry: a main definition outside comments and strings. headers
5824
+ // never compile, so only sources are scanned.
5825
+ /** the macro environment a c-family entry guard evaluates against. */
5826
+ export interface SwiftCMacroEnvironment {
5827
+ /** the target's -D set, with values where given. */
5828
+ defines: ReadonlyMap<string, string | undefined>
5829
+ /** the compiler's own predefines for the unit's language. */
5830
+ predefines: ReadonlyMap<string, string | undefined>
5831
+ /** names any of the target's own sources or headers defines. */
5832
+ targetDefined: ReadonlySet<string>
5833
+ }
5834
+
5835
+ const emptyMacroEnvironment: SwiftCMacroEnvironment = {
5836
+ defines: new Map(),
5837
+ predefines: new Map(),
5838
+ targetDefined: new Set(),
5839
+ }
5840
+
5841
+ // whether the environment defines the name: -D and predefines decide,
5842
+ // a name only the target's own sources define is undecided (order and
5843
+ // conditions are not evaluated), and a name nowhere visible is absent.
5844
+ function cMacroDefined(name: string, env: SwiftCMacroEnvironment): boolean | undefined {
5845
+ if (env.defines.has(name) || env.predefines.has(name)) return true
5846
+ if (env.targetDefined.has(name)) return undefined
5847
+ return false
5848
+ }
5849
+
5850
+ function cMacroIntOrTrue(value: string | undefined): boolean | undefined {
5851
+ if (value === undefined) return true
5852
+ if (/^0[xX][0-9a-fA-F]+[uUlL]*$/.test(value) || /^\d+[uUlL]*$/.test(value))
5853
+ return Number.parseInt(value) !== 0
5854
+ return undefined
5855
+ }
5856
+
5857
+ function cMacroBareValue(name: string, env: SwiftCMacroEnvironment): boolean | undefined {
5858
+ if (env.defines.has(name)) return cMacroIntOrTrue(env.defines.get(name))
5859
+ if (env.predefines.has(name)) return cMacroIntOrTrue(env.predefines.get(name))
5860
+ if (env.targetDefined.has(name)) return undefined
5861
+ return false
5862
+ }
5863
+
5864
+ function cMacroNegated(name: string, env: SwiftCMacroEnvironment): boolean | undefined {
5865
+ const value = cMacroDefined(name, env)
5866
+ return value === undefined ? undefined : !value
5867
+ }
5868
+
5869
+ // a preprocessor condition the macro environment decides, or undefined when
5870
+ // the text needs the real preprocessor (comparisons, function-like macros,
5871
+ // __has_include and the like). only defined-ness, boolean operators and
5872
+ // integer literals evaluate; the rest is undecided.
5873
+ function cConditionValue(
5874
+ expression: string,
5875
+ env: SwiftCMacroEnvironment,
5876
+ ): boolean | undefined {
5877
+ let i = 0
5878
+ const skipSpaces = () => {
5879
+ while (i < expression.length && /\s/.test(expression[i]!)) i++
5880
+ }
5881
+ const parseOr = (): boolean | undefined => {
5882
+ let value = parseAnd()
5883
+ for (;;) {
5884
+ skipSpaces()
5885
+ if (!expression.startsWith('||', i)) return value
5886
+ i += 2
5887
+ const right = parseAnd()
5888
+ value = value === undefined || right === undefined ? undefined : value || right
5889
+ }
5890
+ }
5891
+ const parseAnd = (): boolean | undefined => {
5892
+ let value = parseUnary()
5893
+ for (;;) {
5894
+ skipSpaces()
5895
+ if (!expression.startsWith('&&', i)) return value
5896
+ i += 2
5897
+ const right = parseUnary()
5898
+ value = value === undefined || right === undefined ? undefined : value && right
5899
+ }
5900
+ }
5901
+ const parseUnary = (): boolean | undefined => {
5902
+ skipSpaces()
5903
+ if (expression[i] === '!') {
5904
+ i++
5905
+ const value = parseUnary()
5906
+ return value === undefined ? undefined : !value
5907
+ }
5908
+ if (expression[i] === '(') {
5909
+ i++
5910
+ const value = parseOr()
5911
+ skipSpaces()
5912
+ return expression[i] === ')' ? (i++, value) : undefined
5913
+ }
5914
+ const defined = /^defined\b/.exec(expression.slice(i))
5915
+ if (defined) {
5916
+ i += defined[0].length
5917
+ skipSpaces()
5918
+ const parenthesized = expression[i] === '('
5919
+ if (parenthesized) {
5920
+ i++
5921
+ skipSpaces()
5922
+ }
5923
+ const name = /^\w+/.exec(expression.slice(i))?.[0]
5924
+ if (!name) return undefined
5925
+ i += name.length
5926
+ skipSpaces()
5927
+ if (parenthesized) {
5928
+ if (expression[i] !== ')') return undefined
5929
+ i++
5930
+ }
5931
+ return cMacroDefined(name, env)
5932
+ }
5933
+ const literal = /^(0[xX][0-9a-fA-F]+|\d+)[uUlL]*/.exec(expression.slice(i))
5934
+ if (literal) {
5935
+ i += literal[0].length
5936
+ return Number(literal[1]) !== 0
5937
+ }
5938
+ const name = /^\w+/.exec(expression.slice(i))?.[0]
5939
+ if (!name) return undefined
5940
+ i += name.length
5941
+ return cMacroBareValue(name, env)
5942
+ }
5943
+ const value = parseOr()
5944
+ skipSpaces()
5945
+ return i === expression.length ? value : undefined
5946
+ }
5947
+
5948
+ // the lines xcode's preprocessor keeps: conditional directives evaluated
5949
+ // against the macro environment, with undecided branches kept, so an entry
5950
+ // guard the text cannot decide still counts.
5951
+ function cActiveCode(code: string, env: SwiftCMacroEnvironment): string {
5952
+ const kept: string[] = []
5953
+ const stack: { parent: boolean; taken: boolean }[] = []
5954
+ let active = true
5955
+ for (const line of code.replace(/\\\r?\n/g, '').split('\n')) {
5956
+ const directive =
5957
+ /^\s*#\s*(if|ifdef|ifndef|elif|elifdef|elifndef|else|endif)\b(.*)$/.exec(line)
5958
+ if (!directive) {
5959
+ if (active) kept.push(line)
5960
+ continue
5961
+ }
5962
+ const keyword = directive[1]!
5963
+ const rest = directive[2]!.trim()
5964
+ if (keyword === 'if' || keyword === 'ifdef' || keyword === 'ifndef') {
5965
+ const name = /^\w+$/.exec(rest)?.[0]
5966
+ const value =
5967
+ keyword === 'if'
5968
+ ? cConditionValue(rest, env)
5969
+ : name === undefined
5970
+ ? undefined
5971
+ : keyword === 'ifdef'
5972
+ ? cMacroDefined(name, env)
5973
+ : cMacroNegated(name, env)
5974
+ stack.push({ parent: active, taken: value === true })
5975
+ active = active && value !== false
5976
+ } else if (keyword === 'endif') {
5977
+ active = stack.pop()?.parent ?? true
5978
+ } else if (stack.length === 0) {
5979
+ continue
5980
+ } else {
5981
+ const frame = stack[stack.length - 1]!
5982
+ if (keyword === 'else') {
5983
+ active = frame.parent && !frame.taken
5984
+ frame.taken = true
5985
+ } else {
5986
+ const name = /^\w+$/.exec(rest)?.[0]
5987
+ const value =
5988
+ keyword === 'elif'
5989
+ ? cConditionValue(rest, env)
5990
+ : name === undefined
5991
+ ? undefined
5992
+ : keyword === 'elifdef'
5993
+ ? cMacroDefined(name, env)
5994
+ : cMacroNegated(name, env)
5995
+ const branch = !frame.taken && value !== false
5996
+ if (branch && value === true) frame.taken = true
5997
+ active = frame.parent && branch
5998
+ }
5999
+ }
6000
+ }
6001
+ return kept.join('\n')
6002
+ }
6003
+
6004
+ // the source with comments and string and character literals removed,
6005
+ // newlines kept so directive lines stay intact.
6006
+ function stripCCode(source: string): string {
6007
+ let code = ''
6008
+ let i = 0
6009
+ while (i < source.length) {
6010
+ if (source.startsWith('//', i)) {
6011
+ const end = source.indexOf('\n', i)
6012
+ i = end === -1 ? source.length : end
6013
+ } else if (source.startsWith('/*', i)) {
6014
+ const end = source.indexOf('*/', i + 2)
6015
+ i = end === -1 ? source.length : end + 2
6016
+ } else if (source[i] === '"' || source[i] === "'") {
6017
+ const quote = source[i]!
6018
+ i++
6019
+ while (i < source.length && source[i] !== quote) i += source[i] === '\\' ? 2 : 1
6020
+ i++
6021
+ } else {
6022
+ code += source[i]
6023
+ i++
6024
+ }
6025
+ }
6026
+ return code
6027
+ }
6028
+
6029
+ // every name the given sources define. order and conditions are not
6030
+ // evaluated: a name defined anywhere makes its guards undecided.
6031
+ export function swiftCDefinedNames(sources: Iterable<string>): Set<string> {
6032
+ const names = new Set<string>()
6033
+ for (const source of sources)
6034
+ for (const line of stripCCode(source).split('\n')) {
6035
+ const name = /^\s*#\s*define\s+([A-Za-z_]\w*)/.exec(line)?.[1]
6036
+ if (name) names.add(name)
6037
+ }
6038
+ return names
6039
+ }
6040
+
6041
+ type SwiftCPredefinesTable = {
6042
+ release: string
6043
+ languages: Record<string, Record<string, string | null>>
6044
+ }
6045
+ const cPredefineTable: SwiftCPredefinesTable = cPredefinesJson
6046
+ const cPredefineCache = new Map<string, Map<string, string | undefined>>()
6047
+
6048
+ // the compiler's own macros for the language xcode compiles the unit with:
6049
+ // the pinned toolchain clang's `-dM -E -target arm64-apple-ios` predefines,
6050
+ // committed in generated/swift-c-predefines.json and held at the pinned
6051
+ // release by scripts/check/swift-c-predefines-generated.ts. a table, not a
6052
+ // spawn, so the scan works hosted, on linux and without xcode. the triple
6053
+ // is the arm64-apple-ios device triple (TARGET_OS_SIMULATOR is 0 there; it
6054
+ // is 1 for the simulator SDK), matching the shipping configuration.
6055
+ export function swiftCPredefines(
6056
+ language: 'c' | 'c++' | 'objective-c' | 'objective-c++',
6057
+ ): Map<string, string | undefined> {
6058
+ const cached = cPredefineCache.get(language)
6059
+ if (cached) return cached
6060
+ const predefines = new Map<string, string | undefined>()
6061
+ for (const [name, value] of Object.entries(cPredefineTable.languages[language]))
6062
+ predefines.set(name, value ?? undefined)
6063
+ cPredefineCache.set(language, predefines)
6064
+ return predefines
6065
+ }
6066
+
6067
+ export function swiftCMainEntry(
6068
+ file: string,
6069
+ source: string,
6070
+ env: SwiftCMacroEnvironment = emptyMacroEnvironment,
6071
+ ): boolean {
6072
+ if (!isSwiftNativeTranslationUnit(file)) return false
6073
+ const code = cActiveCode(stripCCode(source), env)
6074
+ for (const match of code.matchAll(/^\s*(?:int\s+|void\s+)?main\s*\(/gm)) {
6075
+ // a definition opens its body after the parameter list and any
6076
+ // trailing declarators (noexcept, attributes); a declaration or a
6077
+ // call ends with a semicolon instead.
6078
+ let depth = 1
6079
+ let index = match.index + match[0].length
6080
+ for (; index < code.length && depth > 0; index++) {
6081
+ if (code[index] === '(') depth++
6082
+ else if (code[index] === ')') depth--
6083
+ }
6084
+ if (depth > 0) continue
6085
+ for (; index < code.length; index++) {
6086
+ const char = code[index]
6087
+ if (char === '{') return true
6088
+ if (char === ';' || char === '}') break
6089
+ // a trailing declarator group (noexcept(...), attributes);
6090
+ // braces inside it belong to the declarator, not a body.
6091
+ if (char === '(' || char === '[') {
6092
+ const closer = char === '(' ? ')' : ']'
6093
+ let nested = 1
6094
+ while (nested > 0 && ++index < code.length) {
6095
+ if (code[index] === char) nested++
6096
+ else if (code[index] === closer) nested--
6097
+ }
6098
+ }
6099
+ }
6100
+ }
6101
+ return false
6102
+ }
6103
+
5744
6104
  // swift's executable entry runs after the reactor's _initialize has completed.
5745
6105
  // global swift values remain lazy; native application initializers need separate
5746
6106
  // object evidence and are refused here rather than running the registry early.
@@ -5756,7 +6116,7 @@ function installObjcPeerStartup(
5756
6116
  }
5757
6117
  if (
5758
6118
  (input.nativeTargets?.length ?? 0) > 0 ||
5759
- Object.keys(input.files).some((file) => /\.(?:c|cc|cpp|cxx|m|mm)$/.test(file))
6119
+ Object.keys(input.files).some(isSwiftNativeTranslationUnit)
5760
6120
  )
5761
6121
  fail('original native source targets require constructor provenance before admission')
5762
6122
  validateObjcPeerStartupLibraries(input.libraries ?? {})
@@ -6007,6 +6367,19 @@ export function writeSwiftProject(
6007
6367
  throw new Error('swift compile input has invalid Objective-C peer startup metadata')
6008
6368
  if (input.nativeTargets !== undefined && !isSwiftNativeTargets(input.nativeTargets))
6009
6369
  throw new Error('swift compile input has invalid original clang target inputs')
6370
+ if (input.packageFiles !== undefined && !isSwiftPackageFiles(input.packageFiles))
6371
+ throw new Error('swift compile input has invalid original package files')
6372
+ const packages = input.packageFiles
6373
+ ? swiftManifestPackages(input.files['Package.swift'] ?? '')
6374
+ : new Map<string, string>()
6375
+ for (const directory of packages.values())
6376
+ if (
6377
+ !isSwiftResourcePath(directory) ||
6378
+ !Object.hasOwn(input.packageFiles ?? {}, `${directory}/Package.swift`)
6379
+ )
6380
+ throw new Error(
6381
+ `swift compile input has no transported package manifest for ${directory}`,
6382
+ )
6010
6383
  if (
6011
6384
  input.resourceBundles !== undefined &&
6012
6385
  !isSwiftResourceBundles(input.resourceBundles)
@@ -6062,6 +6435,18 @@ export function writeSwiftProject(
6062
6435
  }
6063
6436
  >()
6064
6437
  const objcProducers = new Set<string>()
6438
+ // the pinned toolchain, checked once for every original target.
6439
+ let checkedToolchain: string | undefined
6440
+ const nativeToolchain = () => {
6441
+ if (checkedToolchain) return checkedToolchain
6442
+ const pin: { release: string } =
6443
+ distribution ??
6444
+ JSON.parse(readFileSync(path.join(moduleRoot, 'toolchain.json'), 'utf8'))
6445
+ checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot))
6446
+ return checkedToolchain
6447
+ }
6448
+ const deploymentTarget = (name: string) =>
6449
+ input.nativeTargets?.find((value) => value.name === name)?.deploymentTarget ?? '16.0'
6065
6450
  const targetStagedFiles = new Map<string, Map<string, string | Buffer | undefined>>()
6066
6451
  const stageTargetFile = (
6067
6452
  target: string,
@@ -6110,7 +6495,7 @@ export function writeSwiftProject(
6110
6495
  }
6111
6496
  targetStagedFiles.delete(target.name)
6112
6497
  if (
6113
- entries.some(([file]) => /\.(?:c|cc|cpp|cxx|m|mm)$/.test(file)) &&
6498
+ entries.some(([file]) => isSwiftNativeTranslationUnit(file)) &&
6114
6499
  (swift || input.nativeTargets?.some((value) => value.name === target.name))
6115
6500
  ) {
6116
6501
  if (!swift) {
@@ -6195,7 +6580,7 @@ export function writeSwiftProject(
6195
6580
  for (const target of targets) {
6196
6581
  const prefix = target.path === '.' ? '' : `${target.path}/`
6197
6582
  const entries = targetEntries(target)
6198
- const units = entries.filter(([file]) => /\.(?:c|cc|cpp|cxx|m|mm)$/.test(file))
6583
+ const units = entries.filter(([file]) => isSwiftNativeTranslationUnit(file))
6199
6584
  if (units.length === 0) continue
6200
6585
  const includes = `${prefix}include/`
6201
6586
  const consumers = new Map<string, Set<string>>()
@@ -6251,17 +6636,14 @@ export function writeSwiftProject(
6251
6636
  mkdirSync(path.dirname(destination), { recursive: true })
6252
6637
  writeFileSync(destination, input.files[file]!)
6253
6638
  }
6254
- const search = [
6255
- ...new Set([
6256
- ...(settings?.headerSearchPaths ?? []),
6257
- ...headers.map((file) => path.posix.dirname(file)),
6258
- ]),
6259
- ].flatMap((dir) => ['-I', path.join(layout.root, dir)])
6260
- const pin: { release: string } =
6261
- distribution ??
6262
- JSON.parse(readFileSync(path.join(moduleRoot, 'toolchain.json'), 'utf8'))
6263
- const release = pin.release
6264
- const toolchainBin = swiftToolchain(release, swiftModuleSdk(moduleRoot))
6639
+ // xcode searches only the target's search paths and header maps; a
6640
+ // -I per header directory would let an angle include land on a
6641
+ // project header xcode never exposes (damus: <stdint.h> on flatcc's
6642
+ // portable/include/std/stdint.h instead of the sdk).
6643
+ const search = [...new Set([...(settings?.headerSearchPaths ?? [])])].flatMap(
6644
+ (dir) => ['-I', path.join(layout.root, dir)],
6645
+ )
6646
+ const toolchainBin = nativeToolchain()
6265
6647
  const sdkHeaders = materializeObjcSdk(
6266
6648
  path.join(layout.root, '.build', 'peach-objc-sdk'),
6267
6649
  )
@@ -6301,7 +6683,8 @@ export function writeSwiftProject(
6301
6683
  ?.resources ?? false,
6302
6684
  usesBundleMacro: entries.some(
6303
6685
  ([file, contents]) =>
6304
- /\.(?:c|cc|cpp|cxx|m|mm|h|hpp|hh|hxx)$/.test(file) &&
6686
+ (isSwiftNativeTranslationUnit(file) ||
6687
+ /\.(?:h|hpp|hh|hxx)$/.test(file)) &&
6305
6688
  /\bSWIFTPM_MODULE_BUNDLE\b/.test(contents),
6306
6689
  ),
6307
6690
  bundles: input.resourceBundles,
@@ -6362,7 +6745,7 @@ export function writeSwiftProject(
6362
6745
  path.join(layout.root, '.build', 'peach-objc-imports', target.name),
6363
6746
  {
6364
6747
  flags: stageFlags(originalFlags, path.join(sdkHeaders, 'usr/include')),
6365
- target: `arm64-apple-ios${settings?.deploymentTarget ?? '16.0'}-simulator`,
6748
+ target: `arm64-apple-ios${deploymentTarget(target.name)}-simulator`,
6366
6749
  },
6367
6750
  )
6368
6751
  const defined = new Set<string>()
@@ -6869,26 +7252,42 @@ export function writeSwiftProject(
6869
7252
  `import ${swiftTargetModuleName(target.name)}\n@main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }\n`,
6870
7253
  )
6871
7254
  }
6872
- // original units compile on the objective-c runtime whether or not swift
6873
- // exports anything to them.
7255
+ // original units compile on the objective-c runtime, at their target's
7256
+ // deployment minimum, whether or not swift exports anything to them.
6874
7257
  const nativeFlags = (() => {
6875
7258
  if (native.size === 0) return undefined
6876
7259
  const headers = materializeObjcSdk(path.join(layout.root, '.build', 'peach-objc-sdk'))
6877
- return [
6878
- '-fobjc-runtime=gnustep-2.2',
6879
- '-fobjc-exceptions',
6880
- '-fexceptions',
6881
- '-fwasm-exceptions',
6882
- ...WASI_EMULATION_FLAGS,
6883
- '-fobjc-arc',
6884
- '-fblocks',
6885
- '-F',
6886
- path.join(headers, 'System/Library/Frameworks'),
6887
- '-idirafter',
6888
- path.join(headers, 'usr/include'),
6889
- '-I',
6890
- headerDirectory,
6891
- ]
7260
+ const moduleMaps = rootOwner
7261
+ ? [...objcModules].map(
7262
+ (name) =>
7263
+ `-fmodule-map-file=${path.join(headerModuleDirectory, name, 'module.modulemap')}`,
7264
+ )
7265
+ : []
7266
+ return new Map(
7267
+ targets.map((target) => {
7268
+ const version = deploymentTarget(target.name)
7269
+ const minimum = iosDeploymentMinimum(version)
7270
+ if (minimum === undefined)
7271
+ throw new Error(
7272
+ `${target.name}: unsupported IPHONEOS_DEPLOYMENT_TARGET ${JSON.stringify(version)}`,
7273
+ )
7274
+ return [
7275
+ target.name,
7276
+ [
7277
+ '-fobjc-runtime=gnustep-2.2',
7278
+ '-fobjc-exceptions',
7279
+ '-fexceptions',
7280
+ '-fwasm-exceptions',
7281
+ '-fobjc-arc',
7282
+ '-fblocks',
7283
+ ...objcSdkIntakeFlags(headers, nativeToolchain(), minimum),
7284
+ '-I',
7285
+ headerDirectory,
7286
+ ...moduleMaps,
7287
+ ],
7288
+ ]
7289
+ }),
7290
+ )
6892
7291
  })()
6893
7292
  let objcExports: Parameters<typeof emitSwiftPackageManifest>[0]['objcExports']
6894
7293
  if (rootOwner && input.objcPeerStartup)
@@ -6951,17 +7350,7 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
6951
7350
  '',
6952
7351
  ].join('\n'),
6953
7352
  )
6954
- objcExports = {
6955
- modules: objcModules,
6956
- rootModule,
6957
- flags: [
6958
- ...nativeFlags!,
6959
- ...[...objcModules].map(
6960
- (name) =>
6961
- `-fmodule-map-file=${path.join(headerModuleDirectory, name, 'module.modulemap')}`,
6962
- ),
6963
- ],
6964
- }
7353
+ objcExports = { modules: objcModules, rootModule }
6965
7354
  }
6966
7355
  if (targets.length === 0) {
6967
7356
  for (const [file, contents] of Object.entries(input.files)) {
@@ -7033,6 +7422,7 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
7033
7422
  path.join(layout.root, 'Package.swift'),
7034
7423
  emitSwiftPackageManifest({
7035
7424
  targets,
7425
+ packages,
7036
7426
  native,
7037
7427
  objcExports,
7038
7428
  nativeFlags,
@@ -7056,6 +7446,35 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
7056
7446
  }) + moduleFiles,
7057
7447
  )
7058
7448
  }
7449
+ for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
7450
+ files.set(path.join(layout.root, file), Buffer.from(bytes, 'base64'))
7451
+ if (input.packageFiles) {
7452
+ files.set(
7453
+ path.join(layout.root, '.peach-target-toolset.json'),
7454
+ JSON.stringify({
7455
+ schemaVersion: '1.0',
7456
+ swiftCompiler: {
7457
+ extraCLIOptions: [
7458
+ '-I',
7459
+ distribution
7460
+ ? path.join(moduleRoot, 'modules')
7461
+ : path.join(layout.root, '.build', WASM_TRIPLE, 'release', 'Modules'),
7462
+ '-Xfrontend',
7463
+ '-enable-cross-import-overlays',
7464
+ ...swiftCrossImportFlags(moduleRoot, Boolean(distribution)),
7465
+ ...(distribution
7466
+ ? FOUNDATION_IMPLICIT_MODULES.flatMap((module) => [
7467
+ '-Xfrontend',
7468
+ '-import-module',
7469
+ '-Xfrontend',
7470
+ module,
7471
+ ])
7472
+ : []),
7473
+ ],
7474
+ },
7475
+ }),
7476
+ )
7477
+ }
7059
7478
  // resource accessors and the /res pack share the original target assignment.
7060
7479
  for (const target of resourceTargets) {
7061
7480
  if (!target.resources) continue
@@ -7525,6 +7944,9 @@ export function compileSwiftProjectUnit(
7525
7944
  ...swiftSdkOptions(),
7526
7945
  '--swift-sdk',
7527
7946
  sdk,
7947
+ ...(input.packageFiles
7948
+ ? ['--toolset', path.join(root, '.peach-target-toolset.json')]
7949
+ : []),
7528
7950
  '-c',
7529
7951
  'release',
7530
7952
  '-Xswiftc',
@@ -7563,6 +7985,17 @@ export function compileSwiftProjectUnit(
7563
7985
  }
7564
7986
  report('compiling and linking Swift modules')
7565
7987
  try {
7988
+ if (input.packageFiles && !swiftDistributionAt(moduleRoot)) {
7989
+ const frameworks = new Set(['SwiftUI'])
7990
+ for (const name of input.packageGuestImports ?? [])
7991
+ if (OPTIONAL_FRAMEWORKS.has(name)) frameworks.add(name)
7992
+ for (const framework of frameworks)
7993
+ await runCompiler(
7994
+ swift,
7995
+ [...buildArgs, '--target', framework],
7996
+ buildOptions,
7997
+ )
7998
+ }
7566
7999
  // clang consumes the real emitted headers after swift finishes.
7567
8000
  // swiftpm's transitive swift module maps are not C declarations:
7568
8001
  // importing them would shadow SDK modules such as ObjectiveC.