peachsim 0.1.2017 → 0.1.2019

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 (130) hide show
  1. package/cli/telemetry.ts +19 -0
  2. package/dist-lib/agent-daemon-client.cjs +1 -1
  3. package/dist-lib/agent-events.cjs +1 -1
  4. package/dist-lib/attached-projects.cjs +1 -1
  5. package/dist-lib/auth/shared-session.cjs +1 -1
  6. package/dist-lib/backend-origin.cjs +1 -1
  7. package/dist-lib/beta.cjs +1 -1
  8. package/dist-lib/beta.mjs +1 -1
  9. package/dist-lib/bridge-constants.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.mjs +1 -1
  12. package/dist-lib/bridge-contract.cjs +1 -1
  13. package/dist-lib/bridge-contract.mjs +1 -1
  14. package/dist-lib/bundle-channel.cjs +379 -102
  15. package/dist-lib/capture-contract.cjs +1 -1
  16. package/dist-lib/capture-contract.mjs +1 -1
  17. package/dist-lib/cloud-contract.cjs +1 -1
  18. package/dist-lib/cloud-contract.mjs +1 -1
  19. package/dist-lib/cloud-test-args.cjs +1 -1
  20. package/dist-lib/cloud-test-args.mjs +1 -1
  21. package/dist-lib/cloud.cjs +1 -1
  22. package/dist-lib/cloud.mjs +1 -1
  23. package/dist-lib/config.cjs +1 -1
  24. package/dist-lib/config.mjs +1 -1
  25. package/dist-lib/detox/index.cjs +1 -1
  26. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  27. package/dist-lib/expo-swift-bundle.cjs +373 -96
  28. package/dist-lib/expo-swift-metadata.cjs +1 -1
  29. package/dist-lib/expo-swift-metadata.mjs +1 -1
  30. package/dist-lib/home-paths.cjs +1 -1
  31. package/dist-lib/host/bridge-host.cjs +378 -101
  32. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  33. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  34. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  35. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  36. package/dist-lib/host/websocket-proxy.cjs +1 -1
  37. package/dist-lib/index.cjs +74 -15
  38. package/dist-lib/jump-to-source-babel.cjs +1 -1
  39. package/dist-lib/jump-to-source-native.cjs +1 -1
  40. package/dist-lib/kotlin-host.cjs +1 -1
  41. package/dist-lib/menu.cjs +1 -1
  42. package/dist-lib/menu.mjs +1 -1
  43. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  44. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  45. package/dist-lib/metro-production-bundle.cjs +1 -1
  46. package/dist-lib/metro-production-bundle.mjs +1 -1
  47. package/dist-lib/metro.cjs +74 -15
  48. package/dist-lib/native-app-identity-project.cjs +72 -13
  49. package/dist-lib/native-app-identity-project.mjs +72 -12
  50. package/dist-lib/native-app-identity.cjs +5 -2
  51. package/dist-lib/native-app-identity.mjs +5 -2
  52. package/dist-lib/native-firebase-metadata.cjs +1 -1
  53. package/dist-lib/native-firebase-metadata.mjs +1 -1
  54. package/dist-lib/pdfium-raster.cjs +1 -1
  55. package/dist-lib/pdfium-raster.mjs +1 -1
  56. package/dist-lib/plist.cjs +1 -1
  57. package/dist-lib/plist.mjs +1 -1
  58. package/dist-lib/profiles.cjs +1 -1
  59. package/dist-lib/public-brand.cjs +1 -1
  60. package/dist-lib/public-origins-lib-esm.json +24 -24
  61. package/dist-lib/public-origins-lib.json +53 -53
  62. package/dist-lib/react-native-host-modules.cjs +1 -1
  63. package/dist-lib/react-native-host-modules.mjs +1 -1
  64. package/dist-lib/reap-browser.cjs +1 -1
  65. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  66. package/dist-lib/sdk.cjs +1 -1
  67. package/dist-lib/sdk.mjs +1 -1
  68. package/dist-lib/skills.cjs +380 -103
  69. package/dist-lib/swift-compile.cjs +101 -66
  70. package/dist-lib/swift-compile.mjs +100 -65
  71. package/dist-lib/swift-package.cjs +1 -1
  72. package/dist-lib/swift-package.mjs +1 -1
  73. package/dist-lib/swift-submit.cjs +1 -1
  74. package/dist-lib/swift-submit.mjs +1 -1
  75. package/dist-lib/swift-toolchain.cjs +26 -1
  76. package/dist-lib/swift.cjs +1 -1
  77. package/dist-lib/vite-swift.cjs +372 -95
  78. package/dist-lib/vite.cjs +1 -1
  79. package/dist-lib/worklet-executable.cjs +1 -1
  80. package/dist-lib/worklet-executable.mjs +1 -1
  81. package/dist-types/packages/peach-engine/src/components/native-ui/context-menu-types.d.ts +84 -0
  82. package/dist-types/packages/peach-engine/src/engine/animated.d.ts +1 -1
  83. package/dist-types/packages/peach-engine/src/engine/fontDataContract.d.ts +4 -0
  84. package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +1 -0
  85. package/dist-types/packages/peach-engine/src/engine/rn-spring.d.ts +2 -2
  86. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -1
  87. package/dist-types/packages/peach-engine/src/engine/types.d.ts +2 -1
  88. package/dist-types/packages/peach-engine/src/render-worker/graph-linked-value.d.ts +4 -1
  89. package/dist-types/packages/peach-engine/src/render-worker/native-menu-gesture.d.ts +6 -0
  90. package/package.json +1 -1
  91. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSession.h +1 -1
  92. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/CoreData.h +2 -0
  93. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSEntityDescription.h +10 -0
  94. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSFetchRequest.h +28 -0
  95. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSManagedObject.h +1 -1
  96. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSManagedObjectContext.h +16 -1
  97. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSManagedObjectModel.h +3 -0
  98. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSPersistentStoreCoordinator.h +7 -0
  99. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSPersistentStoreRequest.h +3 -0
  100. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSPredicate.h +1 -1
  101. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSSortDescriptor.h +1 -1
  102. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSURLConnection.h +1 -1
  103. package/sdk/ios/System/Library/Frameworks/LocalAuthentication.framework/Headers/LAContext.h +1 -1
  104. package/sdk/ios/System/Library/Frameworks/SafariServices.framework/Headers/SFAuthenticationSession.h +17 -0
  105. package/sdk/ios/System/Library/Frameworks/SafariServices.framework/Headers/SafariServices.h +1 -0
  106. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIInputViewController.h +1 -1
  107. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIPageViewController.h +1 -1
  108. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIPointerStyle.h +1 -6
  109. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Modules/module.modulemap +1 -0
  110. package/sdk/ios/System/Library/Frameworks/UIKitTypes.framework/Headers/UIKitTypes.h +6 -0
  111. package/sdk/ios/System/Library/Frameworks/WatchConnectivity.framework/Headers/WCSession.h +1 -1
  112. package/sdk/ios/usr/include/objc/NSObject.h +1 -1
  113. package/sdk/ios/wasm/include/stdlib.h +1 -0
  114. package/src/nitro-adapter.lock.json +274 -274
  115. package/src/nitro-superset.lock.json +4 -4
  116. package/src/swift-compile.ts +70 -81
  117. package/src/swift-distribution.lock.json +14 -12
  118. package/src/swift-guest-image-ledger.ts +15 -10
  119. package/src/swift-guest-source-inputs.ts +6 -3
  120. package/src/swift-guest-source-plan.ts +5 -1
  121. package/src/swift-objc-compile.ts +2 -2
  122. package/src/swift-objc-standin.ts +197 -5
  123. package/src/swift-packages.ts +13 -12
  124. package/src/swift-shared-sdk.ts +2 -1
  125. package/src/swift-standin-emit.ts +43 -5
  126. package/src/swift-standins.ts +41 -2
  127. package/src/swift-toolchain.ts +24 -0
  128. package/src/turbo-runtime.lock.json +23 -23
  129. package/src/xcode-project.ts +55 -1
  130. package/src/xcode-target-members.ts +4 -0
@@ -46,6 +46,8 @@ export interface ObjcView {
46
46
  graphs: SymbolGraph[]
47
47
  /** external superclass conformances read from the same sdk. */
48
48
  inheritedConformances?: ReadonlyMap<string, ReadonlySet<string>>
49
+ /** paths of the objective-c classes' init() the swift importer marks required. */
50
+ requiredInits?: ReadonlySet<string>
49
51
  /** a mixed framework's objc protocol properties by symbol id: symbol
50
52
  * graphs omit custom accessor selectors, which clang reads from the headers. */
51
53
  protocolProperties?: Map<string, { getter: string; setter?: string }>
@@ -477,6 +479,14 @@ export function objcView(
477
479
  // clang stops there, so UIKit/UIApplication.h is missing. the pinned
478
480
  // simulator sdk is the one xcode searches.
479
481
  const sdk = original ? pinnedNativeSdk().sdkPath : materializeObjcSdk(cacheDir)
482
+ const moduleCache = path.join(
483
+ cacheDir,
484
+ 'ios-module-cache',
485
+ createHash('sha256')
486
+ .update([toolchainBin, stdlib, sdk].map((dir) => fs.realpathSync(dir)).join('\0'))
487
+ .digest('hex')
488
+ .slice(0, 16),
489
+ )
480
490
  // a framework's module map sits in Modules/ beside Headers/; a library
481
491
  // slice keeps it among its headers.
482
492
  const framework = path.basename(path.dirname(surface.modulemap)) === 'Modules'
@@ -549,6 +559,12 @@ export function objcView(
549
559
  } else {
550
560
  fs.copyFileSync(surface.modulemap, path.join(headersDir, 'module.modulemap'))
551
561
  }
562
+ const stagedSurface = {
563
+ ...surface,
564
+ modulemap: framework
565
+ ? path.join(frameworks, `${surface.module}.framework`, 'Modules/module.modulemap')
566
+ : path.join(headersDir, 'module.modulemap'),
567
+ }
552
568
  // dependency headers take the same learned declarations but never become
553
569
  // the surface's own imports.
554
570
  const dependencyOriginals = new Map<string, string>()
@@ -731,7 +747,7 @@ export function objcView(
731
747
  ...(original?.flags.flatMap((flag) => ['-Xcc', flag]) ?? []),
732
748
  ...(surface.moduleMapFlags ?? []).flatMap((flag) => ['-Xcc', flag]),
733
749
  '-module-cache-path',
734
- path.join(cacheDir, 'ios-module-cache'),
750
+ moduleCache,
735
751
  '-minimum-access-level',
736
752
  // symbol graphs hide public underscored names at the public threshold.
737
753
  // original clang headers remain the declaration boundary, and a swift
@@ -866,6 +882,7 @@ export function objcView(
866
882
  }),
867
883
  }
868
884
  })
885
+ inheritedDefaultInits(stagedSurface, graphs, toolchainBin, search, moduleCache, work)
869
886
  // a swift class whose superclass another module declares must not restate
870
887
  // a conformance that superclass already brings, through its ancestors,
871
888
  // categories, protocol parents or a swift overlay. the swift compiler
@@ -926,7 +943,7 @@ export function objcView(
926
943
  ...search,
927
944
  ...(surface.moduleMapFlags ?? []).flatMap((flag) => ['-Xcc', flag]),
928
945
  '-module-cache-path',
929
- path.join(cacheDir, 'ios-module-cache'),
946
+ moduleCache,
930
947
  probe,
931
948
  ],
932
949
  { encoding: 'utf8', env: swiftEnvironment() },
@@ -988,8 +1005,16 @@ export function objcView(
988
1005
  ...(surface.interface
989
1006
  ? {
990
1007
  inheritedConformances,
991
- protocolProperties: protocolProperties(
1008
+ requiredInits: requiredInits(
992
1009
  surface,
1010
+ graphs,
1011
+ toolchainBin,
1012
+ search,
1013
+ moduleCache,
1014
+ work,
1015
+ ),
1016
+ protocolProperties: protocolProperties(
1017
+ stagedSurface,
993
1018
  headersDir,
994
1019
  graphs,
995
1020
  toolchainBin,
@@ -1001,7 +1026,7 @@ export function objcView(
1001
1026
  ...(original
1002
1027
  ? {
1003
1028
  clangAST: objcDeclarationAST(
1004
- surface,
1029
+ stagedSurface,
1005
1030
  framework,
1006
1031
  toolchainBin,
1007
1032
  search,
@@ -1011,11 +1036,178 @@ export function objcView(
1011
1036
  ),
1012
1037
  }
1013
1038
  : {}),
1014
- values: enumValues(graphs, surface, framework, toolchainBin, search, work, original),
1039
+ values: enumValues(
1040
+ graphs,
1041
+ stagedSurface,
1042
+ framework,
1043
+ toolchainBin,
1044
+ search,
1045
+ work,
1046
+ original,
1047
+ ),
1015
1048
  imports: [...imports].sort(),
1016
1049
  }
1017
1050
  }
1018
1051
 
1052
+ function inheritedDefaultInits(
1053
+ surface: ObjcSurface,
1054
+ graphs: SymbolGraph[],
1055
+ toolchainBin: string,
1056
+ search: string[],
1057
+ moduleCache: string,
1058
+ work: string,
1059
+ ): void {
1060
+ const symbols = graphs.flatMap((graph) => graph.symbols)
1061
+ const classes = symbols.filter(
1062
+ (symbol) =>
1063
+ /^c:objc\(cs\)\w+$/.test(symbol.identifier.precise) &&
1064
+ symbol.pathComponents.length === 1 &&
1065
+ !symbols.some(
1066
+ (member) =>
1067
+ member.pathComponents.join('.') === `${symbol.pathComponents[0]}.init()`,
1068
+ ) &&
1069
+ symbols.some(
1070
+ (member) =>
1071
+ member.pathComponents[0] === symbol.pathComponents[0] &&
1072
+ member.kind.identifier === 'swift.init',
1073
+ ),
1074
+ )
1075
+ if (classes.length === 0) return
1076
+ const probe = path.join(work, 'inherited-default-inits.swift')
1077
+ fs.writeFileSync(
1078
+ probe,
1079
+ [
1080
+ `import ${surface.module}`,
1081
+ ...classes.map(
1082
+ (symbol, index) =>
1083
+ `@MainActor func peachInherited${index}() { _ = ${surface.module}.${symbol.pathComponents[0]}() }`,
1084
+ ),
1085
+ ].join('\n'),
1086
+ )
1087
+ const run = spawnSync(
1088
+ path.join(toolchainBin, 'swift-frontend'),
1089
+ [
1090
+ '-dump-ast',
1091
+ '-diagnostic-style',
1092
+ 'llvm',
1093
+ '-no-color-diagnostics',
1094
+ '-target',
1095
+ IOS_SDK_TARGET,
1096
+ ...search,
1097
+ ...(surface.moduleMapFlags ?? []).flatMap((flag) => ['-Xcc', flag]),
1098
+ '-module-cache-path',
1099
+ moduleCache,
1100
+ probe,
1101
+ ],
1102
+ { encoding: 'utf8', env: swiftEnvironment(), maxBuffer: 64 * 1024 * 1024 },
1103
+ )
1104
+ if (run.error) throw run.error
1105
+ const rejected = new Set<number>()
1106
+ for (const line of run.stderr.split('\n')) {
1107
+ if (!line.includes('error:')) continue
1108
+ const location = line.startsWith(`${probe}:`)
1109
+ ? /^:(\d+):\d+: error:/.exec(line.slice(probe.length))
1110
+ : null
1111
+ const index = location ? Number(location[1]) - 2 : -1
1112
+ if (index < 0 || index >= classes.length)
1113
+ throw new Error(`inherited initializer probe does not typecheck: ${line}`)
1114
+ rejected.add(index)
1115
+ }
1116
+ if (run.status !== 0 && rejected.size === 0)
1117
+ throw new Error(
1118
+ `inherited initializer probe failed: ${run.stderr || run.signal || run.status}`,
1119
+ )
1120
+ const references = run.stdout
1121
+ .split('\n')
1122
+ .filter((line) => line.includes('declref_expr'))
1123
+ for (const [index, symbol] of classes.entries()) {
1124
+ if (rejected.has(index)) continue
1125
+ if (
1126
+ !references.some(
1127
+ (line) =>
1128
+ line.includes(`location=${probe}:${index + 2}:`) &&
1129
+ line.includes(`.${symbol.pathComponents[0]}.init()@`),
1130
+ )
1131
+ )
1132
+ continue
1133
+ const id = `${symbol.identifier.precise}(im)init`
1134
+ graphs[0]!.symbols.push({
1135
+ kind: { identifier: 'swift.init' },
1136
+ identifier: { precise: id },
1137
+ pathComponents: [...symbol.pathComponents, 'init()'],
1138
+ declarationFragments: [{ kind: 'keyword', spelling: 'override init()' }],
1139
+ accessLevel: 'public',
1140
+ })
1141
+ graphs[0]!.relationships.push({
1142
+ kind: 'memberOf',
1143
+ source: id,
1144
+ target: symbol.identifier.precise,
1145
+ })
1146
+ }
1147
+ }
1148
+
1149
+ // a subclass that declares its own designated init inherits no required
1150
+ // init, so the compiler names each class whose init() the importer made
1151
+ // required: the symbol graph omits protocol members that are unavailable
1152
+ function requiredInits(
1153
+ surface: ObjcSurface,
1154
+ graphs: SymbolGraph[],
1155
+ toolchainBin: string,
1156
+ search: string[],
1157
+ moduleCache: string,
1158
+ work: string,
1159
+ ): Set<string> {
1160
+ const classes = graphs
1161
+ .flatMap((graph) => graph.symbols)
1162
+ .filter(
1163
+ (symbol) =>
1164
+ /^c:objc\(cs\)\w+$/.test(symbol.identifier.precise) &&
1165
+ symbol.pathComponents.length === 1 &&
1166
+ graphs.some((graph) =>
1167
+ graph.symbols.some(
1168
+ (member) =>
1169
+ member.pathComponents.join('.') === `${symbol.pathComponents[0]}.init()`,
1170
+ ),
1171
+ ),
1172
+ )
1173
+ .map((symbol) => symbol.pathComponents[0]!)
1174
+ const found = new Set<string>()
1175
+ if (classes.length === 0) return found
1176
+ const probe = path.join(work, 'required-inits.swift')
1177
+ fs.writeFileSync(
1178
+ probe,
1179
+ [
1180
+ `import ${surface.module}`,
1181
+ ...classes.map(
1182
+ (name, index) =>
1183
+ `class PeachRequired${index}: ${surface.module}.${name} { init(peach: Int) { fatalError() } }`,
1184
+ ),
1185
+ ].join('\n'),
1186
+ )
1187
+ const run = spawnSync(
1188
+ path.join(toolchainBin, 'swift-frontend'),
1189
+ [
1190
+ '-typecheck',
1191
+ '-target',
1192
+ IOS_SDK_TARGET,
1193
+ ...search,
1194
+ ...(surface.moduleMapFlags ?? []).flatMap((flag) => ['-Xcc', flag]),
1195
+ '-module-cache-path',
1196
+ moduleCache,
1197
+ probe,
1198
+ ],
1199
+ { encoding: 'utf8', env: swiftEnvironment(), maxBuffer: 64 * 1024 * 1024 },
1200
+ )
1201
+ if (run.error) throw run.error
1202
+ const unknown = /error: (?:no such module|cannot find type) .*/.exec(run.stderr)
1203
+ if (unknown) throw new Error(`required init probe does not typecheck: ${unknown[0]}`)
1204
+ for (const match of run.stderr.matchAll(
1205
+ /error: 'required' initializer 'init\(\)' must be provided by subclass of '(?:\w+\.)?(\w+)'/g,
1206
+ ))
1207
+ found.add(`${match[1]}.init()`)
1208
+ return found
1209
+ }
1210
+
1019
1211
  /** the swift search flags as clang spells them. */
1020
1212
  function clangSearchFlags(search: readonly string[]): string[] {
1021
1213
  const flags: string[] = []
@@ -522,7 +522,8 @@ export function resolveSwiftPackages(options: {
522
522
  requirePrepared?: boolean
523
523
  }): SwiftPackages {
524
524
  const { rootDir, resolved, products, localDirs } = options
525
- const provided = new Set(options.provided ?? [])
525
+ const providedTargets = new Set(options.provided ?? [])
526
+ const providedProducts = new Set(options.provided ?? [])
526
527
  const result: SwiftPackages = {
527
528
  sourceLinks: { targets: [], owners: [] },
528
529
  targets: [],
@@ -644,7 +645,7 @@ export function resolveSwiftPackages(options: {
644
645
  // a dependency cycle resolves as compiling; swiftpm rejects real cycles
645
646
  targetOutcomes.set(key, [])
646
647
  const outcome = ((): string[] => {
647
- if (provided.has(name)) return []
648
+ if (providedTargets.has(name)) return []
648
649
  const target = pkg.manifest.targets.get(name)
649
650
  if (!target)
650
651
  return [`${path.basename(pkg.manifest.dir)} declares no target ${name}`]
@@ -711,7 +712,7 @@ export function resolveSwiftPackages(options: {
711
712
  // cannot compile: a wrapper package's product is often the module name
712
713
  const productOutcomes = new Map<string, { pkg: LoadedPackage; reason: string[] }>()
713
714
  const resolveProduct = (pkg: LoadedPackage, product: string): string[] => {
714
- if (provided.has(product)) return []
715
+ if (providedProducts.has(product)) return []
715
716
  const roots = pkg.manifest.products.get(product)?.targets
716
717
  const reason = !roots
717
718
  ? [`${path.basename(pkg.manifest.dir)} has no library ${product}`]
@@ -723,7 +724,7 @@ export function resolveSwiftPackages(options: {
723
724
  pkg: LoadedPackage,
724
725
  dependency: Extract<SwiftTargetDependency, { kind: 'product' }>,
725
726
  ): string[] => {
726
- if (provided.has(dependency.name)) return []
727
+ if (providedProducts.has(dependency.name)) return []
727
728
  const loaded = dependencyPackage(pkg, dependency)
728
729
  return typeof loaded === 'string'
729
730
  ? [loaded]
@@ -775,7 +776,7 @@ export function resolveSwiftPackages(options: {
775
776
  )
776
777
  return false
777
778
  claimed.add(key)
778
- provided.delete(name)
779
+ providedTargets.delete(name)
779
780
  for (const dependency of target.dependencies) {
780
781
  if (dependency.kind === 'target') claimTarget(pkg, dependency.name)
781
782
  else {
@@ -788,7 +789,7 @@ export function resolveSwiftPackages(options: {
788
789
  const claimProduct = (pkg: LoadedPackage, product: string): void => {
789
790
  const roots = pkg.manifest.products.get(product)?.targets ?? []
790
791
  if (roots.map((name) => claimTarget(pkg, name)).some(Boolean))
791
- provided.delete(product)
792
+ providedProducts.delete(product)
792
793
  }
793
794
  for (const { product, source } of products) {
794
795
  if (source.kind === 'remote' && !options.provided) continue
@@ -796,7 +797,7 @@ export function resolveSwiftPackages(options: {
796
797
  if (pkg && typeof pkg !== 'string') claimProduct(pkg, product)
797
798
  }
798
799
  for (const { product, source } of products) {
799
- if (provided.has(product)) continue
800
+ if (providedProducts.has(product)) continue
800
801
  if (source.kind === 'remote' && !options.provided) continue
801
802
  const pkg = source.kind === 'unnamed' ? unnamed(source, product) : load(source)
802
803
  const reason =
@@ -913,10 +914,10 @@ export function resolveSwiftPackages(options: {
913
914
  found.add(key)
914
915
  if (pkg.manifest.targets.get(name)?.type === 'macro') return
915
916
  // a placeholder standing in needs none of what its sources import
916
- if (provided.has(name) && placeholderPackage(pkg)) return
917
+ if (providedTargets.has(name) && placeholderPackage(pkg)) return
917
918
  for (const dependency of pkg.manifest.targets.get(name)?.dependencies ?? []) {
918
919
  if (dependency.kind === 'target') visit(pkg, dependency.name)
919
- else if (!provided.has(dependency.name)) {
920
+ else if (!providedProducts.has(dependency.name)) {
920
921
  const nested = dependencyPackage(pkg, dependency)
921
922
  if (nested && typeof nested !== 'string')
922
923
  for (const root of nested.manifest.products.get(dependency.name)?.targets ??
@@ -928,7 +929,7 @@ export function resolveSwiftPackages(options: {
928
929
  // a product peach ships links as its module, so its wrapper targets and
929
930
  // their binary dependencies are not part of what compiles
930
931
  for (const { product, source } of listed) {
931
- if (provided.has(product)) continue
932
+ if (providedProducts.has(product)) continue
932
933
  const pkg =
933
934
  source.kind === 'unnamed'
934
935
  ? unnamed(source, product)
@@ -1018,7 +1019,7 @@ export function resolveSwiftPackages(options: {
1018
1019
  target.dependencies = (target.dependencies ?? []).flatMap(
1019
1020
  (dependency): SwiftTargetDependency[] => {
1020
1021
  if (dependency.kind === 'target') return [dependency]
1021
- if (provided.has(dependency.name)) return []
1022
+ if (providedProducts.has(dependency.name)) return []
1022
1023
  const nested = dependencyPackage(pkg, dependency)
1023
1024
  if (!nested || typeof nested === 'string') return []
1024
1025
  if (nativePackages.has(nested.manifest.dir))
@@ -1087,7 +1088,7 @@ export function resolveSwiftPackages(options: {
1087
1088
  })
1088
1089
  result.sourceLinks.targets.push({
1089
1090
  id,
1090
- sourceTarget: target.type === 'regular' && !provided.has(name) ? name : null,
1091
+ sourceTarget: target.type === 'regular' && !providedTargets.has(name) ? name : null,
1091
1092
  productName: name,
1092
1093
  productType: `swiftpm.target.${target.type}`,
1093
1094
  machOType: null,
@@ -260,7 +260,7 @@ export function swiftSharedSdkViewOptions(
260
260
  .map((entry) => path.join(entry.parentPath, entry.name))
261
261
  .sort()
262
262
  const key = JSON.stringify([
263
- 'v21',
263
+ 'v22',
264
264
  toolchainBin,
265
265
  sdk,
266
266
  frameworks,
@@ -332,6 +332,7 @@ export function swiftSharedSdkViewOptions(
332
332
  [path.join(sysroot, 'darwin/System/Library/Frameworks'), frameworks],
333
333
  ...[
334
334
  'MacTypes.h',
335
+ 'objc/NSObject.h',
335
336
  'net/if.h',
336
337
  'notify.h',
337
338
  'notify.modulemap',
@@ -184,6 +184,8 @@ export type StandinOptions = {
184
184
  superclasses?: ReadonlyMap<string, string>
185
185
  /** external superclass USR → protocol USRs from its native symbol graph. */
186
186
  inheritedConformances?: ReadonlyMap<string, ReadonlySet<string>>
187
+ /** class init() paths the swift importer marks required */
188
+ requiredInits?: ReadonlySet<string>
187
189
  /** clang property selectors keyed by the native protocol property USR. */
188
190
  objcProperties?: ReadonlyMap<string, { getter: string; setter?: string }>
189
191
  /** wrapped property path → its external property wrapper attribute, from
@@ -883,6 +885,9 @@ export function emitSwiftStandin(
883
885
  !unavailable(member) &&
884
886
  !/\bconvenience\b/.test(text(member)),
885
887
  )
888
+ const superChain = function* (id: string) {
889
+ for (let at = superId.get(id); at && byId.has(at); at = superId.get(at)) yield at
890
+ }
886
891
  const hiddenInit = (id: string) => `${pathOf(byId.get(id)!)}.init(_peachInert:)`
887
892
  // a class builds plainly (`T()`) when no class in its module chain declares a
888
893
  // designated initializer, through its hidden one when each that does has it
@@ -1259,7 +1264,19 @@ export function emitSwiftStandin(
1259
1264
  .filter(Boolean)
1260
1265
  .map((flag) => flag.replace(/\(.*/, '')),
1261
1266
  )
1262
- const required = context.inClass && flags.has('required')
1267
+ // clang imports an objective-c init() as required when a protocol the
1268
+ // class conforms to declares it; the graph omits that, so the compiler
1269
+ // is asked per class. the first class overrides NSObject's init, and a
1270
+ // subclass restates the required one with no override
1271
+ const requiredInit = context.inClass && !!options.requiredInits?.has(path)
1272
+ const restatesRequired =
1273
+ context.inClass &&
1274
+ path.endsWith('.init()') &&
1275
+ [...superChain(owner.get(member.identifier.precise) ?? '')].some((at) =>
1276
+ options.requiredInits?.has(`${pathOf(byId.get(at)!)}.init()`),
1277
+ )
1278
+ const required =
1279
+ context.inClass && (flags.has('required') || requiredInit || restatesRequired)
1263
1280
  const final = context.inClass && flags.has('final') ? 'final ' : ''
1264
1281
  const mutating = flags.has('mutating')
1265
1282
  ? 'mutating '
@@ -1272,6 +1289,7 @@ export function emitSwiftStandin(
1272
1289
  const override =
1273
1290
  context.inClass &&
1274
1291
  !options.plain?.has(path) &&
1292
+ !restatesRequired &&
1275
1293
  (flags.has('override') ||
1276
1294
  overrides.has(member.identifier.precise) ||
1277
1295
  options.forcedOverride?.has(path) ||
@@ -1576,7 +1594,7 @@ export function emitSwiftStandin(
1576
1594
  member,
1577
1595
  path,
1578
1596
  })
1579
- else emitWitness(member, inner, path)
1597
+ else emitWitness(member, inner, path, open && isObjC(member))
1580
1598
  }
1581
1599
  }
1582
1600
  if (options.inert && designated && classBuild(id) === 'hidden')
@@ -1591,6 +1609,18 @@ export function emitSwiftStandin(
1591
1609
  emit(
1592
1610
  `${inner}public required init?(coder: NSCoder) { ${options.inert ? 'return nil' : trap(`${path}.init(coder:)`)} }`,
1593
1611
  )
1612
+ // a designated init drops the inherited required init(), so a
1613
+ // subclass restates it
1614
+ if (
1615
+ designated &&
1616
+ !members.some((member) => leaf(member) === 'init()') &&
1617
+ [...superChain(id)].some((at) =>
1618
+ options.requiredInits?.has(`${pathOf(byId.get(at)!)}.init()`),
1619
+ )
1620
+ )
1621
+ emit(
1622
+ `${inner}public required init() { ${options.inert ? superInit(id) : trap(`${path}.init()`)} }`,
1623
+ )
1594
1624
  emit(`${indent}}`)
1595
1625
  return
1596
1626
  }
@@ -1811,7 +1841,13 @@ export function emitSwiftStandin(
1811
1841
  },
1812
1842
  )
1813
1843
 
1814
- const emitWitness = (member: GraphSymbol, indent: string, owner: string) => {
1844
+ const emitWitness = (
1845
+ member: GraphSymbol,
1846
+ indent: string,
1847
+ owner: string,
1848
+ openObjC = false,
1849
+ ) => {
1850
+ const visibility = openObjC ? 'open' : 'public'
1815
1851
  const { 2: rest } = LEADING_ATTRS.exec(text(member))!
1816
1852
  const decl = rest!
1817
1853
  .replace(/^(?:weak |unowned )/, '')
@@ -1826,10 +1862,12 @@ export function emitSwiftStandin(
1826
1862
  const setter = parsed.settable
1827
1863
  ? ` ${parsed.nonmutating ? 'nonmutating ' : ''}set { ${body} }`
1828
1864
  : ''
1829
- emit(`${indent}public ${parsed.decl} { get${parsed.effects} { ${body} }${setter} }`)
1865
+ emit(
1866
+ `${indent}${visibility} ${parsed.decl} { get${parsed.effects} { ${body} }${setter} }`,
1867
+ )
1830
1868
  } else
1831
1869
  emit(
1832
- `${indent}public ${member.kind.identifier === 'swift.init' ? 'required ' : ''}${stripDefaults(decl)} { ${body} }`,
1870
+ `${indent}${member.kind.identifier === 'swift.init' ? 'public required ' : visibility + ' '}${stripDefaults(decl)} { ${body} }`,
1833
1871
  )
1834
1872
  }
1835
1873
 
@@ -420,6 +420,12 @@ export function binaryHeaderSearchPaths(
420
420
  const headers = libraryHeaders && fs.existsSync(libraryHeaders) ? [libraryHeaders] : []
421
421
  if (headers.length === 0 && frameworks.length === 0)
422
422
  return { frameworks: [], headers: [] }
423
+ const provided = new Set(
424
+ declaredFrameworks ? swiftPeachModules(declaredFrameworks.moduleRoot) : [],
425
+ )
426
+ const providedFrameworks = frameworks.filter((framework) =>
427
+ provided.has(path.basename(framework, '.framework')),
428
+ )
423
429
  const declared = new Map<
424
430
  string,
425
431
  {
@@ -462,6 +468,8 @@ export function binaryHeaderSearchPaths(
462
468
  // a warm build root's objects, and a concurrent reader never sees a rewrite.
463
469
  // a per-revision record finds the tree without restaging.
464
470
  const declaredDigest = createHash('sha256')
471
+ for (const framework of providedFrameworks)
472
+ declaredDigest.update(`provided/${path.relative(artifact.dir, framework)}\0`)
465
473
  for (const [framework, { declared: names, imports, sdkHeader }] of declared)
466
474
  declaredDigest
467
475
  .update(path.relative(artifact.dir, framework))
@@ -472,7 +480,7 @@ export function binaryHeaderSearchPaths(
472
480
  const staging = path.join(
473
481
  root,
474
482
  'peach-binary-trees',
475
- declared.size
483
+ declared.size || providedFrameworks.length
476
484
  ? `${artifact.digest.slice(0, 32)}-${declaredDigest.digest('hex').slice(0, 16)}`
477
485
  : artifact.digest.slice(0, 32),
478
486
  )
@@ -497,7 +505,14 @@ export function binaryHeaderSearchPaths(
497
505
  fs.cpSync(
498
506
  path.join(framework, part),
499
507
  path.join(pending, 'frameworks', path.basename(framework), part),
500
- { recursive: true, dereference: true },
508
+ {
509
+ recursive: true,
510
+ dereference: true,
511
+ filter: (source) =>
512
+ !providedFrameworks.includes(framework) ||
513
+ path.basename(source) !==
514
+ `${path.basename(framework, '.framework')}-Swift.h`,
515
+ },
501
516
  )
502
517
  const surface = found.find(
503
518
  (item) => 'headers' in item && path.dirname(item.headers) === framework,
@@ -539,6 +554,23 @@ export function binaryHeaderSearchPaths(
539
554
  }
540
555
  }
541
556
  const contents = createHash('sha256')
557
+ for (const framework of providedFrameworks.filter((item) => !declared.has(item))) {
558
+ const modulemap = path.join(
559
+ pending,
560
+ 'frameworks',
561
+ path.basename(framework),
562
+ 'Modules/module.modulemap',
563
+ )
564
+ const swiftModule = `${path.basename(framework, '.framework')}.Swift`
565
+ fs.writeFileSync(
566
+ modulemap,
567
+ fs
568
+ .readFileSync(modulemap, 'utf8')
569
+ .replace(/\bmodule\s+([\w.]+)\s*\{[^{}]*\}/g, (declaration, name: string) =>
570
+ name === swiftModule ? '' : declaration,
571
+ ),
572
+ )
573
+ }
542
574
  for (const relative of fs
543
575
  .readdirSync(pending, { recursive: true, encoding: 'utf8' })
544
576
  .sort()) {
@@ -1013,6 +1045,7 @@ function swiftStandin(
1013
1045
  binary,
1014
1046
  toolchain,
1015
1047
  work,
1048
+ new Set(),
1016
1049
  behavior,
1017
1050
  // the interface's imports peach ships carry the types its declarations name
1018
1051
  [...new Set(imports)].filter(
@@ -1105,6 +1138,7 @@ function placeholderStandin(
1105
1138
  binary,
1106
1139
  toolchain,
1107
1140
  work,
1141
+ new Set(),
1108
1142
  behavior,
1109
1143
  imports.filter((module) => siblings.has(module)),
1110
1144
  false,
@@ -1289,6 +1323,7 @@ function mixedStandin(
1289
1323
  binary,
1290
1324
  toolchain,
1291
1325
  work,
1326
+ view.requiredInits ?? new Set(),
1292
1327
  behavior,
1293
1328
  imports,
1294
1329
  true,
@@ -1392,6 +1427,7 @@ function objcStandin(
1392
1427
  binary,
1393
1428
  toolchain,
1394
1429
  work,
1430
+ new Set(),
1395
1431
  behavior,
1396
1432
  [
1397
1433
  ...new Set([
@@ -1426,6 +1462,7 @@ function graphStandin(
1426
1462
  binary: SwiftPackageBinary,
1427
1463
  toolchain: Toolchain,
1428
1464
  work: string,
1465
+ requiredInits: ReadonlySet<string>,
1429
1466
  behavior: ReadonlyMap<string, StandinBehavior>,
1430
1467
  imports: string[] = [],
1431
1468
  requireSwift = false,
@@ -1494,6 +1531,7 @@ function graphStandin(
1494
1531
  module,
1495
1532
  source: `${binary.target} (${binary.source})`,
1496
1533
  values,
1534
+ requiredInits,
1497
1535
  behavior,
1498
1536
  omit,
1499
1537
  plain,
@@ -1757,6 +1795,7 @@ function cStandin(
1757
1795
  )
1758
1796
  // the module's own headers, under the target's public include directory
1759
1797
  const include = path.join(work, 'include')
1798
+ fs.mkdirSync(include, { recursive: true })
1760
1799
  for (const [file, text] of texts) {
1761
1800
  fs.mkdirSync(path.dirname(path.join(include, file)), { recursive: true })
1762
1801
  fs.writeFileSync(path.join(include, file), text)
@@ -65,6 +65,24 @@ export interface SwiftHostCompilerPin {
65
65
  // advance. an installed CLI adds the compiler its runtime pins
66
66
  // (registerSwiftHostCompiler).
67
67
  const compilerArchives: Record<string, SwiftHostCompilerPin> = {
68
+ 'swift-6.4.0-RELEASE-custom-11345d60dca47496': {
69
+ identity: '11345d60dca47496',
70
+ archive: 'tar.zst',
71
+ hosts: {
72
+ 'darwin-arm64': {
73
+ checksum: '3df74a95c6f3ffa45aaa412027b390c99f9af81f6f6a41bf6d58a1a3079b5b02',
74
+ manifest: '8e5ed4be6adc967e4c7d955eff004c96d5dc050a589d50e1b3e694b70f9afd63',
75
+ },
76
+ 'linux-x64': {
77
+ checksum: 'a80e46add069932114bacc18640dc2e6a1a8f2a3ea7306a8ea8614d5cdf6e0e7',
78
+ manifest: '662d8869534f3cce827b1205973db1f9a1e1d92027005a5bdb6893f9c2a0b39d',
79
+ },
80
+ 'linux-arm64': {
81
+ checksum: '4ca69bbc284fc7d54be57c80b744b88cce997d470ff23048795db54e7a6fbcba',
82
+ manifest: '85df84da2f814b6a71c264b37b83a81965ac33b5d2b465443d60c08cc7bc5dc3',
83
+ },
84
+ },
85
+ },
68
86
  'swift-6.4.0-RELEASE-custom-45bb46301c86fe73': {
69
87
  identity: '45bb46301c86fe73',
70
88
  archive: 'tar.gz',
@@ -291,7 +309,13 @@ export function privateSwiftDistributionRoot(): string | null {
291
309
 
292
310
  // the private distribution's own compiler release: the only one accepted without
293
311
  // a qualified archive entry.
312
+ export function privateSwiftCompilerRelease(): string | null {
313
+ return process.env.PEACH_SWIFT_PRIVATE_COMPILER_RELEASE?.trim() || null
314
+ }
315
+
294
316
  function privateSwiftRelease(): string | null {
317
+ const compiler = privateSwiftCompilerRelease()
318
+ if (compiler) return compiler
295
319
  const root = privateSwiftDistributionRoot()
296
320
  if (!root) return null
297
321
  const manifest: unknown = JSON.parse(