expo 58.0.22 → 58.0.24

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.
@@ -10,7 +10,7 @@ buildscript {
10
10
  }
11
11
 
12
12
  group = 'host.exp.exponent'
13
- version = '58.0.22'
13
+ version = '58.0.24'
14
14
 
15
15
  expoModule {
16
16
  // We can't prebuild the module because it depends on the generated files.
@@ -21,7 +21,7 @@ android {
21
21
  namespace "expo.core"
22
22
  defaultConfig {
23
23
  versionCode 1
24
- versionName "58.0.22"
24
+ versionName "58.0.24"
25
25
  consumerProguardFiles("proguard-rules.pro")
26
26
  }
27
27
  testOptions {
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "@expo/dom-webview": "~58.0.2",
3
- "@expo/fingerprint": "~0.21.8",
4
- "@expo/metro-runtime": "~58.0.16",
3
+ "@expo/fingerprint": "~0.21.10",
4
+ "@expo/metro-runtime": "~58.0.17",
5
5
  "@expo/vector-icons": "^15.0.2",
6
- "@expo/ui": "~58.0.26",
6
+ "@expo/ui": "~58.0.28",
7
7
  "@react-native-async-storage/async-storage": "2.2.0",
8
8
  "@react-native-community/datetimepicker": "9.2.1",
9
9
  "@react-native-masked-view/masked-view": "0.3.2",
@@ -16,39 +16,39 @@
16
16
  "eslint-config-expo": "~58.0.4",
17
17
  "expo-analytics-amplitude": "~11.3.0",
18
18
  "expo-app-auth": "~11.1.0",
19
- "expo-app-intents": "~0.5.15",
19
+ "expo-app-intents": "~0.5.17",
20
20
  "expo-app-loader-provider": "~8.0.0",
21
- "expo-app-metrics": "~58.0.14",
22
- "expo-apple-authentication": "~58.0.2",
21
+ "expo-app-metrics": "~58.0.15",
22
+ "expo-apple-authentication": "~58.0.3",
23
23
  "expo-application": "~58.1.2",
24
- "expo-asset": "~58.0.19",
25
- "expo-audio": "~58.0.11",
26
- "expo-auth-session": "~58.0.16",
27
- "expo-background-fetch": "~58.0.12",
28
- "expo-background-task": "~58.0.12",
29
- "expo-battery": "~58.0.3",
30
- "expo-blur": "~58.0.5",
31
- "expo-brightness": "~58.0.2",
32
- "expo-brownfield": "~58.0.18",
24
+ "expo-asset": "~58.0.21",
25
+ "expo-audio": "~58.0.12",
26
+ "expo-auth-session": "~58.0.18",
27
+ "expo-background-fetch": "~58.0.13",
28
+ "expo-background-task": "~58.0.13",
29
+ "expo-battery": "~58.0.4",
30
+ "expo-blur": "~58.0.6",
31
+ "expo-brightness": "~58.0.3",
32
+ "expo-brownfield": "~58.0.20",
33
33
  "expo-build-properties": "~58.0.12",
34
34
  "expo-calendar": "~58.0.6",
35
35
  "expo-camera": "~58.0.14",
36
- "expo-cellular": "~58.0.3",
36
+ "expo-cellular": "~58.0.4",
37
37
  "expo-checkbox": "~58.0.2",
38
38
  "expo-clipboard": "~58.0.4",
39
- "expo-constants": "~58.0.14",
39
+ "expo-constants": "~58.0.16",
40
40
  "expo-contacts": "~58.0.10",
41
- "expo-crypto": "~58.0.7",
42
- "expo-dev-client": "~58.0.18",
41
+ "expo-crypto": "~58.0.8",
42
+ "expo-dev-client": "~58.0.19",
43
43
  "expo-device": "~58.0.5",
44
- "expo-document-picker": "~58.0.4",
44
+ "expo-document-picker": "~58.0.5",
45
45
  "expo-eas-client": "~58.0.2",
46
46
  "expo-file-system": "~58.0.13",
47
- "expo-font": "~58.0.11",
47
+ "expo-font": "~58.0.12",
48
48
  "expo-gl": "~58.0.4",
49
49
  "expo-glass-effect": "~58.0.5",
50
50
  "expo-google-app-auth": "~8.3.0",
51
- "expo-haptics": "~58.0.7",
51
+ "expo-haptics": "~58.0.8",
52
52
  "expo-hinge": "~58.0.2",
53
53
  "expo-image": "~58.0.18",
54
54
  "expo-image-loader": "~58.0.3",
@@ -56,49 +56,49 @@
56
56
  "expo-image-picker": "~58.0.10",
57
57
  "expo-intent-launcher": "~58.0.3",
58
58
  "expo-insights": "~58.0.11",
59
- "expo-keep-awake": "~58.0.3",
60
- "expo-linear-gradient": "~58.0.3",
61
- "expo-linking": "~58.0.15",
62
- "expo-local-authentication": "~58.0.2",
59
+ "expo-keep-awake": "~58.0.4",
60
+ "expo-linear-gradient": "~58.0.4",
61
+ "expo-linking": "~58.0.17",
62
+ "expo-local-authentication": "~58.0.3",
63
63
  "expo-localization": "~58.0.5",
64
- "expo-location": "~58.0.20",
65
- "expo-mail-composer": "~58.0.3",
64
+ "expo-location": "~58.0.21",
65
+ "expo-mail-composer": "~58.0.4",
66
66
  "expo-manifests": "~58.0.1",
67
67
  "expo-maps": "~58.0.11",
68
68
  "expo-mcp": "~0.2.1",
69
- "expo-media-library": "~58.0.13",
70
- "expo-mesh-gradient": "~58.0.3",
69
+ "expo-media-library": "~58.0.14",
70
+ "expo-mesh-gradient": "~58.0.4",
71
71
  "expo-module-template": "~58.0.9",
72
- "expo-modules-core": "~58.0.29",
72
+ "expo-modules-core": "~58.1.0",
73
73
  "expo-navigation-bar": "~58.0.4",
74
- "expo-network": "~58.0.4",
75
- "expo-notifications": "~58.1.7",
76
- "expo-observe": "~58.0.17",
77
- "expo-print": "~58.0.8",
78
- "expo-live-photo": "~58.0.7",
79
- "expo-router": "~58.0.29",
74
+ "expo-network": "~58.0.5",
75
+ "expo-notifications": "~58.1.9",
76
+ "expo-observe": "~58.0.19",
77
+ "expo-print": "~58.0.9",
78
+ "expo-live-photo": "~58.0.8",
79
+ "expo-router": "~58.0.31",
80
80
  "expo-screen-capture": "~58.0.6",
81
- "expo-screen-orientation": "~58.0.3",
82
- "expo-secure-store": "~58.0.2",
83
- "expo-sensors": "~58.0.4",
84
- "expo-server": "~58.0.6",
85
- "expo-sharing": "~58.0.21",
86
- "expo-sms": "~58.0.2",
87
- "expo-speech": "~58.0.3",
88
- "expo-splash-screen": "~58.0.12",
89
- "expo-sqlite": "~58.0.15",
90
- "expo-status-bar": "~58.0.4",
91
- "expo-store-review": "~58.0.2",
92
- "expo-symbols": "~58.0.4",
81
+ "expo-screen-orientation": "~58.0.4",
82
+ "expo-secure-store": "~58.0.3",
83
+ "expo-sensors": "~58.0.5",
84
+ "expo-server": "~58.1.0",
85
+ "expo-sharing": "~58.0.23",
86
+ "expo-sms": "~58.0.3",
87
+ "expo-speech": "~58.0.4",
88
+ "expo-splash-screen": "~58.0.14",
89
+ "expo-sqlite": "~58.0.16",
90
+ "expo-status-bar": "~58.0.5",
91
+ "expo-store-review": "~58.0.3",
92
+ "expo-symbols": "~58.0.5",
93
93
  "expo-system-ui": "~58.0.7",
94
- "expo-task-manager": "~58.0.13",
95
- "expo-tracking-transparency": "~58.0.2",
96
- "expo-updates": "~58.0.20",
97
- "expo-video-thumbnails": "~58.0.2",
98
- "expo-video": "~58.0.13",
99
- "expo-web-browser": "~58.0.7",
100
- "expo-widgets": "~58.0.26",
101
- "jest-expo": "~58.0.13",
94
+ "expo-task-manager": "~58.0.14",
95
+ "expo-tracking-transparency": "~58.1.0",
96
+ "expo-updates": "~58.0.22",
97
+ "expo-video-thumbnails": "~58.0.3",
98
+ "expo-video": "~58.0.14",
99
+ "expo-web-browser": "~58.0.8",
100
+ "expo-widgets": "~58.0.28",
101
+ "jest-expo": "~58.0.14",
102
102
  "lottie-react-native": "~7.5.0",
103
103
  "react": "19.3.0",
104
104
  "react-dom": "19.3.0",
@@ -111,7 +111,7 @@
111
111
  "react-native-worklets": "0.13.0",
112
112
  "react-native-reanimated": "4.7.1",
113
113
  "react-native-screens": "~4.30.1",
114
- "react-native-safe-area-context": "~5.10.1",
114
+ "react-native-safe-area-context": "~5.11.1",
115
115
  "react-native-svg": "15.16.0",
116
116
  "react-native-view-shot": "6.1.1",
117
117
  "react-native-webview": "14.0.1",
@@ -13,6 +13,6 @@ open class ExpoReactNativeFactoryDelegate: RCTDefaultReactNativeFactoryDelegate
13
13
  open override func createRootViewController() -> UIViewController {
14
14
  return ExpoAppDelegateSubscriberRepository.reactDelegateHandlers.lazy
15
15
  .compactMap { $0.createRootViewController() }
16
- .first(where: { _ in true }) ?? UIViewController()
16
+ .first(where: { _ in true }) ?? ExpoRootViewController()
17
17
  }
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo",
3
- "version": "58.0.22",
3
+ "version": "58.0.24",
4
4
  "description": "The Expo SDK",
5
5
  "keywords": [
6
6
  "expo"
@@ -212,36 +212,36 @@
212
212
  },
213
213
  "dependencies": {
214
214
  "@babel/runtime": "^7.20.0",
215
- "@expo/cli": "^58.1.18",
216
- "@expo/config": "~58.0.10",
217
- "@expo/config-plugins": "~58.0.11",
215
+ "@expo/cli": "^58.1.20",
216
+ "@expo/config": "~58.0.12",
217
+ "@expo/config-plugins": "~58.0.13",
218
218
  "@expo/devtools": "~58.0.2",
219
219
  "@expo/dom-webview": "~58.0.2",
220
- "@expo/fingerprint": "^0.21.8",
221
- "@expo/local-build-cache-provider": "^58.0.10",
222
- "@expo/log-box": "^58.0.14",
220
+ "@expo/fingerprint": "^0.21.10",
221
+ "@expo/local-build-cache-provider": "^58.0.12",
222
+ "@expo/log-box": "^58.0.15",
223
223
  "@expo/log-box-utils": "^58.0.2",
224
224
  "@expo/metro": "~58.0.0",
225
- "@expo/metro-config": "~58.0.20",
225
+ "@expo/metro-config": "~58.0.22",
226
226
  "@ungap/structured-clone": "^1.3.0",
227
- "babel-preset-expo": "~58.0.23",
228
- "expo-asset": "~58.0.19",
229
- "expo-constants": "~58.0.14",
227
+ "babel-preset-expo": "~58.0.25",
228
+ "expo-asset": "~58.0.21",
229
+ "expo-constants": "~58.0.16",
230
230
  "expo-file-system": "~58.0.13",
231
- "expo-font": "~58.0.11",
232
- "expo-keep-awake": "~58.0.3",
233
- "expo-modules-autolinking": "~58.0.16",
234
- "expo-modules-cli": "~0.4.0",
235
- "expo-modules-core": "~58.0.29",
231
+ "expo-font": "~58.0.12",
232
+ "expo-keep-awake": "~58.0.4",
233
+ "expo-modules-autolinking": "~58.1.0",
234
+ "expo-modules-cli": "~0.5.0",
235
+ "expo-modules-core": "~58.1.0",
236
236
  "pretty-format": "^29.7.0",
237
237
  "react-refresh": "^0.14.2",
238
238
  "whatwg-url-minimum": "^0.2.0"
239
239
  },
240
240
  "devDependencies": {
241
- "@expo/metro-runtime": "58.0.16",
241
+ "@expo/metro-runtime": "58.0.17",
242
242
  "@types/node": "^22.14.0",
243
243
  "@types/react": "~19.3.0",
244
- "expo-updates": "58.0.20",
244
+ "expo-updates": "58.0.22",
245
245
  "npm-run-all2": "^8.0.4",
246
246
  "react": "19.3.0",
247
247
  "react-dom": "19.3.0",
@@ -92,7 +92,11 @@ The plugin decides each module in this order:
92
92
  2. Otherwise, when its `Package.swift` depends on the `ExpoModulesCoreHeaders`
93
93
  product, the plugin builds it from that manifest as it stands. The manifest
94
94
  compiles against the `ExpoModulesCoreHeaders` and `ExpoModulesJSIHeaders`
95
- xcframeworks.
95
+ xcframeworks. `ExpoModulesCoreHeaders` depends on the `expo-modules-macros`
96
+ package, so SwiftPM builds the Expo macro plugin and loads it into the module
97
+ with no compiler flags in its manifest. `ExpoModulesCoreHeaders` also depends
98
+ on React Native's header products, so a module that imports React gets them
99
+ through it and does not name React Native in its manifest.
96
100
  3. Otherwise its `Package.swift` is mirrored into a generated package, or a
97
101
  pure-Swift module gets a generated package over its sources.
98
102
 
@@ -11,12 +11,7 @@ jest.mock('../cli', () => ({
11
11
  }));
12
12
 
13
13
  const { runDumpPackage } = require('../cli');
14
- const {
15
- dependsOnCoreHeaders,
16
- dumpModuleManifest,
17
- emitDirectPackage,
18
- prepareDirectWatchPaths,
19
- } = require('../direct');
14
+ const { dependsOnCoreHeaders, dumpModuleManifest, emitDirectPackage } = require('../direct');
20
15
  const { rerunSpmUpdate, thrownBy } = require('./helpers');
21
16
 
22
17
  const hapticsManifest = {
@@ -137,25 +132,33 @@ describe('emitDirectPackage', () => {
137
132
  let pkgDir;
138
133
  let coreHeadersXCFramework;
139
134
  let jsiHeadersPkgPath;
135
+ let macrosPackageRoot;
140
136
 
141
- const emit = () =>
137
+ const emit = (react = null, codegenPkgPath = null) =>
142
138
  emitDirectPackage({
143
139
  moduleRoot: path.join(root, 'expo-haptics'),
144
140
  packageName: 'expo-haptics',
145
141
  outDir,
146
142
  coreHeadersXCFramework,
147
143
  jsiHeadersPkgPath,
148
- macroTool: path.join(root, 'ExpoModulesMacros'),
144
+ macrosPackageRoot,
145
+ react,
146
+ codegenPkgPath,
149
147
  manifest: hapticsManifest,
150
148
  });
151
149
  const manifest = () => fs.readFileSync(path.join(pkgDir, 'Package.swift'), 'utf8');
152
150
 
153
151
  beforeEach(() => {
154
- delete process.env.BUILD_DIR;
155
152
  root = fs.mkdtempSync(path.join(os.tmpdir(), 'direct-emit-'));
156
153
  outDir = path.join(root, 'out');
157
154
  pkgDir = path.join(outDir, 'direct', 'ExpoModulesCoreHeaders');
158
155
  jsiHeadersPkgPath = path.join(outDir, 'ExpoModulesJSIHeaders');
156
+ macrosPackageRoot = path.join(root, 'node_modules', 'expo-modules-macros');
157
+ fs.mkdirSync(macrosPackageRoot, { recursive: true });
158
+ fs.writeFileSync(
159
+ path.join(macrosPackageRoot, 'Package.swift'),
160
+ '// swift-tools-version: 6.2\n'
161
+ );
159
162
  fs.mkdirSync(path.join(root, 'expo-haptics'));
160
163
  coreHeadersXCFramework = path.join(
161
164
  root,
@@ -212,6 +215,79 @@ describe('emitDirectPackage', () => {
212
215
  expect(fs.existsSync(path.join(outDir, 'direct'))).toBe(false);
213
216
  });
214
217
 
218
+ it('gives its dependents the macro plugin through the expo-modules-macros package', () => {
219
+ emit();
220
+ expect(manifest()).toContain(
221
+ '.package(name: "expo-modules-macros", path: "../../../node_modules/expo-modules-macros")'
222
+ );
223
+ expect(manifest()).toMatch(
224
+ /\.target\(\s*name: "ExpoModulesCoreHeadersDependencies",\s*dependencies: \[[^\]]*\.product\(name: "ExpoModulesMacrosPlugin", package: "expo-modules-macros"\)/
225
+ );
226
+ });
227
+
228
+ describe("gives its dependents React Native's header products", () => {
229
+ const dependenciesTarget = () =>
230
+ manifest().match(
231
+ /\.target\(\s*name: "ExpoModulesCoreHeadersDependencies",\s*dependencies: \[([^\]]*)\]/
232
+ )[1];
233
+
234
+ it('from a local React Native package and the app codegen package', () => {
235
+ emit(
236
+ {
237
+ packageRef: { name: 'ReactNative', path: '/abs/react-native' },
238
+ products: [
239
+ { name: 'ReactHeaders', package: 'ReactNative' },
240
+ { name: 'ReactNativeHeaders', package: 'ReactNative' },
241
+ { name: 'ReactNativeDependenciesHeaders', package: 'ReactNative' },
242
+ { name: 'ReactAppHeaders', package: 'React-GeneratedCode' },
243
+ ],
244
+ },
245
+ '/abs/app/ios'
246
+ );
247
+ expect(manifest()).toContain('.package(name: "ReactNative", path: "/abs/react-native")');
248
+ expect(manifest()).toContain('.package(name: "React-GeneratedCode", path: "/abs/app/ios")');
249
+ for (const [name, pkg] of [
250
+ ['ReactHeaders', 'ReactNative'],
251
+ ['ReactNativeHeaders', 'ReactNative'],
252
+ ['ReactNativeDependenciesHeaders', 'ReactNative'],
253
+ ['ReactAppHeaders', 'React-GeneratedCode'],
254
+ ]) {
255
+ expect(dependenciesTarget()).toContain(`.product(name: "${name}", package: "${pkg}")`);
256
+ }
257
+ });
258
+
259
+ it('from a remote React Native package', () => {
260
+ emit(
261
+ {
262
+ packageRef: { name: 'ReactNative', url: 'https://example/rn.git', version: '0.87.0' },
263
+ products: [{ name: 'ReactHeaders', package: 'ReactNative' }],
264
+ },
265
+ '/abs/app/ios'
266
+ );
267
+ expect(manifest()).toContain('.package(url: "https://example/rn.git", exact: "0.87.0")');
268
+ expect(dependenciesTarget()).toContain(
269
+ '.product(name: "ReactHeaders", package: "ReactNative")'
270
+ );
271
+ });
272
+ });
273
+
274
+ it('links no macro plugin into the build folder', () => {
275
+ process.env.BUILD_DIR = path.join(root, 'Build', 'Products');
276
+ emit();
277
+ expect(fs.existsSync(path.join(root, 'Build'))).toBe(false);
278
+ });
279
+
280
+ it('fails, writing no package, when expo-modules-macros is too old to be a Swift package', () => {
281
+ fs.rmSync(path.join(macrosPackageRoot, 'Package.swift'));
282
+ expect(emit).toThrow(
283
+ `expo-haptics is built from its own Package.swift and needs the Expo Swift macros as a Swift package, but expo-modules-macros at ${macrosPackageRoot} has no Package.swift.`
284
+ );
285
+ expect(emit).toThrow('expo-modules-macros 0.29.0 or later');
286
+ expect(emit).toThrow('npx expo install --fix');
287
+ expect(emit).toThrow(rerunSpmUpdate);
288
+ expect(fs.existsSync(path.join(outDir, 'direct'))).toBe(false);
289
+ });
290
+
215
291
  it('places the ExpoModulesCore headers xcframework in the package by link', () => {
216
292
  emit();
217
293
  const link = path.join(pkgDir, 'ExpoModulesCoreHeaders.xcframework');
@@ -252,7 +328,7 @@ describe('emitDirectPackage', () => {
252
328
  outDir,
253
329
  coreHeadersXCFramework,
254
330
  jsiHeadersPkgPath,
255
- macroTool: path.join(root, 'ExpoModulesMacros'),
331
+ macrosPackageRoot,
256
332
  manifest: hapticsManifest,
257
333
  });
258
334
  const link = path.join(outDir, 'direct', '@acme', 'widgets');
@@ -271,7 +347,7 @@ describe('emitDirectPackage', () => {
271
347
  outDir,
272
348
  coreHeadersXCFramework,
273
349
  jsiHeadersPkgPath,
274
- macroTool: path.join(root, 'ExpoModulesMacros'),
350
+ macrosPackageRoot,
275
351
  manifest: { ...hapticsManifest, name: 'ExpoHapticsPackage' },
276
352
  });
277
353
  expect(fs.existsSync(generated)).toBe(false);
@@ -306,82 +382,3 @@ describe('emitDirectPackage', () => {
306
382
  expect(snapshot()).toEqual(first);
307
383
  });
308
384
  });
309
-
310
- describe('prepareDirectWatchPaths', () => {
311
- const savedBuildDir = process.env.BUILD_DIR;
312
- let outDir;
313
- beforeEach(() => {
314
- outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'direct-watch-'));
315
- });
316
- afterEach(() => {
317
- fs.rmSync(outDir, { recursive: true, force: true });
318
- if (savedBuildDir === undefined) {
319
- delete process.env.BUILD_DIR;
320
- } else {
321
- process.env.BUILD_DIR = savedBuildDir;
322
- }
323
- });
324
-
325
- // Clean Build Folder deletes the macro plugin link while RN's sync stamp survives.
326
- // A watched path that has vanished makes RN re-sync then.
327
- it('watches the macro plugin link when a direct module is emitted', () => {
328
- process.env.BUILD_DIR = '/tmp/Build/Products';
329
- expect(prepareDirectWatchPaths(['expo-haptics'], outDir)).toEqual([
330
- path.join('/tmp/Build/Products', 'ExpoModulesMacros'),
331
- ]);
332
- });
333
-
334
- it('watches nothing when no direct module is emitted', () => {
335
- process.env.BUILD_DIR = '/tmp/Build/Products';
336
- expect(prepareDirectWatchPaths([], outDir)).toEqual([]);
337
- delete process.env.BUILD_DIR;
338
- expect(prepareDirectWatchPaths([], outDir)).toEqual([]);
339
- });
340
-
341
- // A command-line sync has no BUILD_DIR, so it cannot create the link, yet it writes a
342
- // fresh stamp. RN keeps only watched paths that exist and re-syncs when one is newer
343
- // than the stamp, so the marker must exist and stay newer than any later stamp.
344
- it('forces the next build to sync when sync runs outside a build', () => {
345
- delete process.env.BUILD_DIR;
346
- const watched = prepareDirectWatchPaths(['expo-haptics'], outDir);
347
- expect(watched).toHaveLength(1);
348
- expect(fs.existsSync(watched[0])).toBe(true);
349
- expect(fs.statSync(watched[0]).mtimeMs).toBeGreaterThan(Date.now() + 365 * 24 * 3600 * 1000);
350
- });
351
-
352
- it('leaves the marker untouched when a later sync outside a build finds it in place', () => {
353
- delete process.env.BUILD_DIR;
354
- prepareDirectWatchPaths(['expo-haptics'], outDir);
355
- const writes = [jest.spyOn(fs, 'writeFileSync'), jest.spyOn(fs, 'utimesSync')];
356
- try {
357
- prepareDirectWatchPaths(['expo-haptics'], outDir);
358
- for (const write of writes) expect(write).not.toHaveBeenCalled();
359
- } finally {
360
- for (const write of writes) write.mockRestore();
361
- }
362
- });
363
-
364
- it('dates the marker in the future again when its date has changed', () => {
365
- delete process.env.BUILD_DIR;
366
- const [marker] = prepareDirectWatchPaths(['expo-haptics'], outDir);
367
- const now = new Date();
368
- fs.utimesSync(marker, now, now);
369
- prepareDirectWatchPaths(['expo-haptics'], outDir);
370
- expect(fs.statSync(marker).mtimeMs).toBeGreaterThan(Date.now() + 365 * 24 * 3600 * 1000);
371
- });
372
-
373
- it('removes the marker once no direct module is emitted', () => {
374
- delete process.env.BUILD_DIR;
375
- const [marker] = prepareDirectWatchPaths(['expo-haptics'], outDir);
376
- prepareDirectWatchPaths([], outDir);
377
- expect(fs.existsSync(marker)).toBe(false);
378
- });
379
-
380
- it('removes the marker once a sync runs inside a build', () => {
381
- delete process.env.BUILD_DIR;
382
- const [marker] = prepareDirectWatchPaths(['expo-haptics'], outDir);
383
- process.env.BUILD_DIR = '/tmp/Build/Products';
384
- prepareDirectWatchPaths(['expo-haptics'], outDir);
385
- expect(fs.existsSync(marker)).toBe(false);
386
- });
387
- });
@@ -431,6 +431,41 @@ describe('artifact preparation', () => {
431
431
  expect(fs.existsSync(path.join(result.xcframework, 'Info.plist'))).toBe(true);
432
432
  });
433
433
 
434
+ itNotWindows('gives the extracted headers the extraction time, not the archived mtime', () => {
435
+ const source = path.join(root, 'source');
436
+ const xcframework = makeXcframework(source, 'ExpoModulesCoreHeaders', 'headers');
437
+ const archived = new Date('2001-01-01T00:00:00Z');
438
+ const header = path.join(
439
+ 'ios-arm64',
440
+ 'ExpoModulesCoreHeaders.framework',
441
+ 'Headers',
442
+ 'ExpoModulesCoreHeaders.h'
443
+ );
444
+ fs.utimesSync(path.join(xcframework, header), archived, archived);
445
+ const moduleRoot = path.join(root, 'module');
446
+ packTarball(
447
+ path.join(source, 'headers'),
448
+ path.join(
449
+ moduleRoot,
450
+ 'prebuilds',
451
+ 'output',
452
+ 'headers',
453
+ 'xcframeworks',
454
+ 'ExpoModulesCoreHeaders.tar.gz'
455
+ ),
456
+ ['ExpoModulesCoreHeaders.xcframework']
457
+ );
458
+
459
+ const extractedAfter = Date.now() - 2000;
460
+ const { xcframework: extracted } = resolveHeadersXCFrameworkWithSource({
461
+ packageName: 'expo-spm-headers-fixture',
462
+ moduleRoot,
463
+ productName: 'ExpoModulesCore',
464
+ cacheDir: path.join(root, 'cache'),
465
+ });
466
+ expect(fs.statSync(path.join(extracted, header)).mtimeMs).toBeGreaterThan(extractedAfter);
467
+ });
468
+
434
469
  it('produces byte-identical compile interfaces regardless of declaration order', () => {
435
470
  const aDebug = makeXcframework(root, 'ExpoA', 'a-debug', 'a');
436
471
  const aRelease = makeXcframework(root, 'ExpoA', 'a-release', 'a');
@@ -1844,7 +1844,7 @@ describe('where precompiled modules and headers come from', () => {
1844
1844
  * given kinds of place, and a direct module when `headers` says where the
1845
1845
  * ExpoModulesCore headers come from (null for headers that are not found).
1846
1846
  */
1847
- function sync({ frameworks, headers }) {
1847
+ function sync({ frameworks, headers, react = null }) {
1848
1848
  const tmp = makeTempDir('expo-spm-plugin-sources-');
1849
1849
  const listed = Object.keys({ ...frameworks, ExpoModulesJSI: null }).map((frameworkName) => [
1850
1850
  packageOf[frameworkName],
@@ -1890,14 +1890,18 @@ describe('where precompiled modules and headers come from', () => {
1890
1890
  resolveHeadersXCFramework.mockReturnValue(jsiHeadersXCFramework);
1891
1891
  const outDir = path.join(tmp, 'out');
1892
1892
  providerWrittenTo(outDir);
1893
+ const codegenPkgPath = path.join(tmp, 'ios');
1894
+ fs.mkdirSync(codegenPkgPath);
1895
+ fs.writeFileSync(path.join(codegenPkgPath, 'Package.swift'), '// swift-tools-version: 6.0\n');
1893
1896
  let result = null;
1894
1897
  const thrown = thrownBy(() => {
1895
- result = runPlugin(tmp);
1898
+ result = runPlugin(tmp, { react });
1896
1899
  });
1897
1900
  return {
1898
1901
  thrown,
1899
1902
  result,
1900
1903
  jsiHeadersPkgPath: path.join(outDir, 'expo', 'ExpoModulesJSIHeaders'),
1904
+ codegenPkgPath,
1901
1905
  };
1902
1906
  }
1903
1907
 
@@ -2021,6 +2025,7 @@ describe('where precompiled modules and headers come from', () => {
2021
2025
  expect.objectContaining({
2022
2026
  coreHeadersXCFramework: '/abs/ExpoModulesCoreHeaders.xcframework',
2023
2027
  jsiHeadersPkgPath,
2028
+ macrosPackageRoot: expect.any(String),
2024
2029
  })
2025
2030
  );
2026
2031
  expect(resolveHeadersXCFrameworkWithSource).not.toHaveBeenCalledWith(
@@ -2028,6 +2033,22 @@ describe('where precompiled modules and headers come from', () => {
2028
2033
  );
2029
2034
  });
2030
2035
 
2036
+ it("hands a direct module React Native's descriptor and the app codegen package", () => {
2037
+ const react = {
2038
+ packageRef: { name: 'ReactNative', path: '/abs/react-native' },
2039
+ products: [{ name: 'ReactAppHeaders', package: 'React-GeneratedCode' }],
2040
+ };
2041
+ const { thrown, codegenPkgPath } = sync({
2042
+ frameworks: { ExpoModulesCore: 'env' },
2043
+ headers: { ExpoModulesCore: 'env' },
2044
+ react,
2045
+ });
2046
+ expect(thrown).toBeNull();
2047
+ expect(emitDirectPackage).toHaveBeenCalledWith(
2048
+ expect.objectContaining({ react, codegenPkgPath })
2049
+ );
2050
+ });
2051
+
2031
2052
  it('emits the ExpoModulesJSI headers package when the only source package is a direct one', () => {
2032
2053
  emitPureSwiftSourcePackage.mockClear();
2033
2054
  const { thrown, jsiHeadersPkgPath } = sync({
@@ -0,0 +1,120 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const { dependsOnCoreHeaders, dumpModuleManifest, emitDirectPackage } = require('../direct');
7
+ const { makeTempDir, removeTempDirs } = require('./helpers');
8
+
9
+ const REPO_ROOT = path.resolve(__dirname, '../../../../..');
10
+
11
+ /**
12
+ * Copies a repository package the way npm installs it: the package's `.npmignore` strips
13
+ * `/ios/Tests/**`, so a manifest that excludes `Tests` names a directory that is not there.
14
+ */
15
+ function installLikeNpm(packageName, destination) {
16
+ const source = path.join(REPO_ROOT, 'packages', packageName);
17
+ const moduleRoot = path.join(destination, 'node_modules', packageName);
18
+ fs.cpSync(source, moduleRoot, {
19
+ recursive: true,
20
+ filter: (file) => {
21
+ const relative = path.relative(source, file);
22
+ return relative !== 'node_modules' && relative !== path.join('ios', 'Tests');
23
+ },
24
+ });
25
+ return moduleRoot;
26
+ }
27
+
28
+ afterEach(removeTempDirs);
29
+
30
+ const DIRECT_MANIFESTS = [
31
+ ['expo-age-range', 'ExpoAgeRange'],
32
+ ['expo-apple-authentication', 'ExpoAppleAuthentication'],
33
+ ['expo-asset', 'ExpoAsset'],
34
+ ['expo-background-fetch', 'ExpoBackgroundFetch'],
35
+ ['expo-battery', 'ExpoBattery'],
36
+ ['expo-blur', 'ExpoBlur'],
37
+ ['expo-brightness', 'ExpoBrightness'],
38
+ ['expo-cellular', 'ExpoCellular'],
39
+ ['expo-document-picker', 'ExpoDocumentPicker'],
40
+ ['expo-font', 'ExpoFont'],
41
+ ['expo-haptics', 'ExpoHaptics'],
42
+ ['expo-keep-awake', 'ExpoKeepAwake'],
43
+ ['expo-linear-gradient', 'ExpoLinearGradient'],
44
+ ['expo-linking', 'ExpoLinking'],
45
+ ['expo-live-photo', 'ExpoLivePhoto'],
46
+ ['expo-local-authentication', 'ExpoLocalAuthentication'],
47
+ ['expo-mail-composer', 'ExpoMailComposer'],
48
+ ['expo-mesh-gradient', 'ExpoMeshGradient'],
49
+ ['expo-network', 'ExpoNetwork'],
50
+ ['expo-print', 'ExpoPrint'],
51
+ ['expo-secure-store', 'ExpoSecureStore'],
52
+ ['expo-sensors', 'ExpoSensors'],
53
+ ['expo-sms', 'ExpoSMS'],
54
+ ['expo-speech', 'ExpoSpeech'],
55
+ ['expo-status-bar', 'ExpoStatusBar'],
56
+ ['expo-store-review', 'ExpoStoreReview'],
57
+ ['expo-symbols', 'ExpoSymbols'],
58
+ ['expo-video-thumbnails', 'ExpoVideoThumbnails'],
59
+ ['expo-web-browser', 'ExpoWebBrowser'],
60
+ ];
61
+
62
+ // expo-dev-menu-interface depends on nothing, so the plugin builds it through the generated
63
+ // manifest, not the direct path.
64
+ const CHECKED_IN_MANIFESTS = [
65
+ ...DIRECT_MANIFESTS.map(([packageName]) => packageName),
66
+ 'expo-dev-menu-interface',
67
+ ];
68
+
69
+ // These run the real `swift package dump-package`, so they read the checked-in manifests as
70
+ // SwiftPM does rather than a recorded dump of them.
71
+ it.each(DIRECT_MANIFESTS)(
72
+ 'links the real %s, installed from npm, directly through its checked-in Package.swift',
73
+ (packageName, productName) => {
74
+ const tmp = makeTempDir('spm-real-manifest-');
75
+ const moduleRoot = installLikeNpm(packageName, path.join(tmp, 'app'));
76
+ expect(fs.existsSync(path.join(moduleRoot, 'ios', 'Tests'))).toBe(false);
77
+
78
+ const { manifest } = dumpModuleManifest(moduleRoot, packageName);
79
+ expect(dependsOnCoreHeaders(manifest)).toBe(true);
80
+
81
+ const outDir = path.join(tmp, 'out');
82
+ const coreHeadersXCFramework = path.join(tmp, 'headers', 'ExpoModulesCoreHeaders.xcframework');
83
+ fs.mkdirSync(coreHeadersXCFramework, { recursive: true });
84
+ const macrosPackageRoot = path.join(tmp, 'app', 'node_modules', 'expo-modules-macros');
85
+ fs.mkdirSync(macrosPackageRoot, { recursive: true });
86
+ fs.writeFileSync(
87
+ path.join(macrosPackageRoot, 'Package.swift'),
88
+ '// swift-tools-version: 6.2\n'
89
+ );
90
+
91
+ const { ok } = emitDirectPackage({
92
+ moduleRoot,
93
+ packageName,
94
+ outDir,
95
+ coreHeadersXCFramework,
96
+ jsiHeadersPkgPath: path.join(outDir, 'ExpoModulesJSIHeaders'),
97
+ macrosPackageRoot,
98
+ manifest,
99
+ });
100
+
101
+ const link = path.join(outDir, 'direct', packageName);
102
+ expect(ok.packageDep).toEqual({ name: packageName, path: link });
103
+ expect(ok.productDeps).toEqual([{ name: productName, package: packageName }]);
104
+ expect(fs.realpathSync(link)).toBe(fs.realpathSync(moduleRoot));
105
+ },
106
+ 60_000
107
+ );
108
+
109
+ it.each(CHECKED_IN_MANIFESTS)(
110
+ 'loads the macros of the real %s with no unsafe flags',
111
+ (packageName) => {
112
+ const moduleRoot = installLikeNpm(packageName, makeTempDir('spm-real-manifest-'));
113
+ const { manifest } = dumpModuleManifest(moduleRoot, packageName);
114
+ const unsafeSettings = manifest.targets
115
+ .flatMap((target) => target.settings ?? [])
116
+ .filter((setting) => setting.kind?.unsafeFlags != null);
117
+ expect(unsafeSettings).toEqual([]);
118
+ },
119
+ 60_000
120
+ );
@@ -5,10 +5,11 @@
5
5
  *
6
6
  * direct/<package> → relative symlink to the module root
7
7
  * direct/ExpoModulesCoreHeaders → compile-only ExpoModulesCore: a relative symlink to its
8
- * prebuilt headers xcframework, plus a dependency on the
9
- * ExpoModulesJSI headers package the plugin emits
10
- * $BUILD_DIR/ExpoModulesMacros → relative symlink to the prebuilt macro plugin; the
11
- * manifest names it as `${BUILD_DIR}/ExpoModulesMacros`
8
+ * prebuilt headers xcframework, plus dependencies on the
9
+ * ExpoModulesJSI headers package the plugin emits and on
10
+ * the expo-modules-macros package, whose macro plugin
11
+ * SwiftPM builds and loads into every dependent, and on
12
+ * React Native's header products
12
13
  */
13
14
 
14
15
  'use strict';
@@ -18,10 +19,13 @@ const path = require('path');
18
19
 
19
20
  const { runDumpPackage } = require('./cli');
20
21
  const { pluginError, rerunSpmUpdate } = require('./diagnostics');
22
+ const { reactPackageDeclarations, reactProductDependencies } = require('./react-descriptor');
21
23
 
22
24
  const CORE_HEADERS = 'ExpoModulesCoreHeaders';
23
25
  const JSI_HEADERS = 'ExpoModulesJSIHeaders';
24
- // A binary target cannot have dependencies, so this source target carries the JSI one.
26
+ const MACROS_PACKAGE = 'expo-modules-macros';
27
+ const MACROS_PRODUCT = 'ExpoModulesMacrosPlugin';
28
+ // A binary target cannot have dependencies, so this source target carries them.
25
29
  const CORE_HEADERS_DEPENDENCIES = 'ExpoModulesCoreHeadersDependencies';
26
30
  // Written into the package by an earlier generator; nothing reads it now.
27
31
  const LEGACY_STUBS_DIR = '.stubs';
@@ -43,9 +47,20 @@ function dependsOnCoreHeaders(manifest) {
43
47
  * Module manifests depend on the product, so it keeps the package's name. ExpoModulesCore's
44
48
  * interface re-exports ExpoModulesJSI, so the product brings the JSI headers package along;
45
49
  * it must not declare a JSI headers target of its own, because SwiftPM rejects two targets
46
- * of one name in a graph.
50
+ * of one name in a graph. SwiftPM loads the macro plugin into every target that depends, at
51
+ * any depth, on a target that depends on the plugin's product, so module manifests need no
52
+ * flags to load it.
47
53
  */
48
- function coreHeadersManifest(jsiHeadersPkgRelativePath) {
54
+ function coreHeadersManifest(
55
+ jsiHeadersPkgRelativePath,
56
+ macrosPkgRelativePath,
57
+ react,
58
+ codegenPkgPath
59
+ ) {
60
+ const lines = (dependencies, indent) =>
61
+ dependencies.map((dependency) => `${indent}${dependency},\n`).join('');
62
+ const reactPackages = react != null ? reactPackageDeclarations(react, codegenPkgPath) : [];
63
+ const reactProducts = react != null ? reactProductDependencies(react) : [];
49
64
  return `// swift-tools-version: 6.0
50
65
  // AUTO-GENERATED by expo/scripts/spm/direct.js — do not edit.
51
66
  // Compile-only ExpoModulesCore. The runtime framework is linked and embedded by React
@@ -59,12 +74,16 @@ let package = Package(
59
74
  ],
60
75
  dependencies: [
61
76
  .package(name: "${JSI_HEADERS}", path: "${jsiHeadersPkgRelativePath}"),
62
- ],
77
+ .package(name: "${MACROS_PACKAGE}", path: "${macrosPkgRelativePath}"),
78
+ ${lines(reactPackages, ' ')} ],
63
79
  targets: [
64
80
  .binaryTarget(name: "${CORE_HEADERS}", path: "${CORE_HEADERS}.xcframework"),
65
81
  .target(
66
82
  name: "${CORE_HEADERS_DEPENDENCIES}",
67
- dependencies: [.product(name: "${JSI_HEADERS}", package: "${JSI_HEADERS}")],
83
+ dependencies: [
84
+ .product(name: "${JSI_HEADERS}", package: "${JSI_HEADERS}"),
85
+ .product(name: "${MACROS_PRODUCT}", package: "${MACROS_PACKAGE}"),
86
+ ${lines(reactProducts, ' ')} ],
68
87
  path: "${CORE_HEADERS_DEPENDENCIES}"
69
88
  ),
70
89
  ]
@@ -87,7 +106,14 @@ function writeIfChanged(file, contents) {
87
106
  fs.writeFileSync(file, contents);
88
107
  }
89
108
 
90
- function emitCoreHeadersPackage(directDir, coreHeadersXCFramework, jsiHeadersPkgPath) {
109
+ function emitCoreHeadersPackage(
110
+ directDir,
111
+ coreHeadersXCFramework,
112
+ jsiHeadersPkgPath,
113
+ macrosPackageRoot,
114
+ react,
115
+ codegenPkgPath
116
+ ) {
91
117
  const pkgDir = path.join(directDir, CORE_HEADERS);
92
118
  fs.mkdirSync(pkgDir, { recursive: true });
93
119
  fs.rmSync(path.join(pkgDir, LEGACY_STUBS_DIR), { recursive: true, force: true });
@@ -98,7 +124,12 @@ function emitCoreHeadersPackage(directDir, coreHeadersXCFramework, jsiHeadersPkg
98
124
  );
99
125
  writeIfChanged(
100
126
  path.join(pkgDir, 'Package.swift'),
101
- coreHeadersManifest(path.relative(pkgDir, jsiHeadersPkgPath))
127
+ coreHeadersManifest(
128
+ path.relative(pkgDir, jsiHeadersPkgPath),
129
+ path.relative(pkgDir, macrosPackageRoot),
130
+ react,
131
+ codegenPkgPath
132
+ )
102
133
  );
103
134
  }
104
135
 
@@ -108,6 +139,9 @@ function emitCoreHeadersPackage(directDir, coreHeadersXCFramework, jsiHeadersPkg
108
139
  *
109
140
  * @param jsiHeadersPkgPath the ExpoModulesJSI headers package the plugin emits, or null when
110
141
  * expo-modules-jsi is not autolinked.
142
+ * @param macrosPackageRoot the expo-modules-macros package that expo-modules-core resolves.
143
+ * @param react React Native's ReactDescriptor, or null when React Native passes none.
144
+ * @param codegenPkgPath the app's React-GeneratedCode package, or null when there is none.
111
145
  * @param manifest the module's manifest, as `dumpModuleManifest` parsed it.
112
146
  */
113
147
  function emitDirectPackage({
@@ -116,7 +150,9 @@ function emitDirectPackage({
116
150
  outDir,
117
151
  coreHeadersXCFramework,
118
152
  jsiHeadersPkgPath,
119
- macroTool,
153
+ macrosPackageRoot,
154
+ react,
155
+ codegenPkgPath,
120
156
  manifest,
121
157
  }) {
122
158
  if (jsiHeadersPkgPath == null) {
@@ -126,14 +162,23 @@ function emitDirectPackage({
126
162
  how: `expo-modules-core depends on expo-modules-jsi, so reinstall your JavaScript dependencies, and remove expo-modules-jsi from \`"expo": { "autolinking": { "exclude": [...] } }\` in your package.json if it is listed there. ${rerunSpmUpdate()}`,
127
163
  });
128
164
  }
165
+ if (!fs.existsSync(path.join(macrosPackageRoot, 'Package.swift'))) {
166
+ throw pluginError({
167
+ what: `${packageName} is built from its own Package.swift and needs the Expo Swift macros as a Swift package, but ${MACROS_PACKAGE} at ${macrosPackageRoot} has no Package.swift.`,
168
+ why: `SwiftPM builds the macro plugin from that package, and versions of ${MACROS_PACKAGE} before 0.29.0 ship it only as a prebuilt binary.`,
169
+ how: `expo-modules-core must depend on ${MACROS_PACKAGE} 0.29.0 or later. Run \`npx expo install --fix\` to align the Expo package versions. ${rerunSpmUpdate()}`,
170
+ });
171
+ }
129
172
  const directDir = path.join(outDir, 'direct');
130
173
  fs.mkdirSync(directDir, { recursive: true });
131
- emitCoreHeadersPackage(directDir, coreHeadersXCFramework, jsiHeadersPkgPath);
132
- const macroLink = macroPluginLink();
133
- if (macroLink) {
134
- fs.mkdirSync(path.dirname(macroLink), { recursive: true });
135
- relativeSymlink(macroTool, macroLink);
136
- }
174
+ emitCoreHeadersPackage(
175
+ directDir,
176
+ coreHeadersXCFramework,
177
+ jsiHeadersPkgPath,
178
+ macrosPackageRoot,
179
+ react,
180
+ codegenPkgPath
181
+ );
137
182
  const link = path.join(directDir, packageName);
138
183
  fs.mkdirSync(path.dirname(link), { recursive: true });
139
184
  relativeSymlink(moduleRoot, link);
@@ -176,40 +221,8 @@ function dumpFailureDetail(error) {
176
221
  return output.trim().split('\n')[0];
177
222
  }
178
223
 
179
- function macroPluginLink() {
180
- return process.env.BUILD_DIR ? path.join(process.env.BUILD_DIR, 'ExpoModulesMacros') : null;
181
- }
182
-
183
- // Far enough ahead that every later sync stamp is older.
184
- const PENDING_MARKER_MTIME = new Date('2100-01-01T00:00:00Z');
185
-
186
- /**
187
- * Only a sync inside a build knows BUILD_DIR, so only it can create the macro plugin link.
188
- * RN re-syncs in the build when a watched path has vanished or is newer than its stamp,
189
- * and drops watched paths that do not exist.
190
- * - In a build: watch the link, since Clean Build Folder deletes it but keeps the stamp.
191
- * - Outside a build: the link cannot be made, yet the stamp is fresh. Watch a marker
192
- * dated in the future, so the next build always re-syncs; that sync removes it.
193
- */
194
- function prepareDirectWatchPaths(directPackages, outDir) {
195
- const marker = path.join(outDir, 'direct', '.macro-plugin-link-pending');
196
- const macroLink = macroPluginLink();
197
- const hasDirect = directPackages.length > 0;
198
- if (!hasDirect || macroLink) {
199
- fs.rmSync(marker, { force: true });
200
- return hasDirect ? [macroLink] : [];
201
- }
202
- if (fs.statSync(marker, { throwIfNoEntry: false })?.mtimeMs !== PENDING_MARKER_MTIME.getTime()) {
203
- fs.mkdirSync(path.dirname(marker), { recursive: true });
204
- fs.writeFileSync(marker, '');
205
- fs.utimesSync(marker, PENDING_MARKER_MTIME, PENDING_MARKER_MTIME);
206
- }
207
- return [marker];
208
- }
209
-
210
224
  module.exports = {
211
225
  dependsOnCoreHeaders,
212
226
  dumpModuleManifest,
213
227
  emitDirectPackage,
214
- prepareDirectWatchPaths,
215
228
  };
@@ -159,7 +159,10 @@ function extractTarball(sourcePath, packageName, frameworkName, cacheDir, flavor
159
159
 
160
160
  validateTarEntries(sourcePath, frameworkName);
161
161
  replaceDirectory(destination, (temp) => {
162
- execFileSync('tar', ['-xzf', sourcePath, '-C', temp], { stdio: 'pipe' });
162
+ // `-m` stamps the files with the extraction time. With the archived mtimes,
163
+ // a newer header version looks older than Xcode's cached explicit module,
164
+ // and Xcode reuses that stale module.
165
+ execFileSync('tar', ['-xzmf', sourcePath, '-C', temp], { stdio: 'pipe' });
163
166
  const extracted = path.join(temp, `${frameworkName}.xcframework`);
164
167
  if (!fs.existsSync(path.join(extracted, 'Info.plist'))) {
165
168
  throw incompleteXCFrameworkError(
@@ -90,12 +90,7 @@ const {
90
90
  resolveHeadersXCFrameworkWithSource,
91
91
  resolveSpmDependencyFrameworks,
92
92
  } = require('./flavored-frameworks');
93
- const {
94
- dependsOnCoreHeaders,
95
- dumpModuleManifest,
96
- emitDirectPackage,
97
- prepareDirectWatchPaths,
98
- } = require('./direct');
93
+ const { dependsOnCoreHeaders, dumpModuleManifest, emitDirectPackage } = require('./direct');
99
94
  const {
100
95
  emitExpoModulesJSIHeadersPackage,
101
96
  emitPureSwiftSourcePackage,
@@ -577,7 +572,9 @@ function emitSourceModule(identity, hasManifest, emitContext, dumpManifest) {
577
572
  outDir: emitContext.outDir,
578
573
  coreHeadersXCFramework: emitContext.coreHeadersXCFramework,
579
574
  jsiHeadersPkgPath: emitContext.jsiHeadersPkgPath,
580
- macroTool: emitContext.macroTool,
575
+ macrosPackageRoot: emitContext.macrosPackageRoot,
576
+ react: emitContext.react,
577
+ codegenPkgPath: emitContext.codegenPkgPath,
581
578
  manifest,
582
579
  });
583
580
  return { ...emission, direct: true };
@@ -760,8 +757,8 @@ function linkPasses(
760
757
  get macroFlags() {
761
758
  return (resolvedMacroFlags ??= macroPluginFlags(core.moduleRoot));
762
759
  },
763
- get macroTool() {
764
- return macroPluginTool(core.moduleRoot);
760
+ get macrosPackageRoot() {
761
+ return macrosPackageRoot(core.moduleRoot);
765
762
  },
766
763
  // Lazy: only a direct module needs the headers, and only then must they exist.
767
764
  get coreHeadersXCFramework() {
@@ -943,24 +940,22 @@ function watchPaths(identities, { entitlementPath, podfilePropertiesPath }) {
943
940
  ];
944
941
  }
945
942
 
946
- // Swift macros need the prebuilt plugin executable; mirrors
947
- // project_integrator.rb#resolve_macros_plugin_dir.
948
- // It declares no SwiftPM products, so it travels as a compiler flag, not a dependency.
949
- function macroPluginTool(coreModuleRoot) {
950
- const macroPluginFault = (
951
- what,
952
- missing,
953
- how = 'Reinstall your JavaScript dependencies and build again.'
954
- ) => ({
955
- what,
956
- why: `Expo modules are compiled from source here, and their Swift macros cannot expand without ${missing} — the build would fail with "external macro implementation could not be found".`,
957
- how,
958
- });
959
- let pkgJsonPath;
943
+ const macroPluginFault = (
944
+ what,
945
+ missing,
946
+ how = 'Reinstall your JavaScript dependencies and build again.'
947
+ ) => ({
948
+ what,
949
+ why: `Expo modules are compiled from source here, and their Swift macros cannot expand without ${missing} — the build would fail with "external macro implementation could not be found".`,
950
+ how,
951
+ });
952
+
953
+ // Mirrors project_integrator.rb#resolve_macros_plugin_dir.
954
+ function macrosPackageRoot(coreModuleRoot) {
960
955
  try {
961
- pkgJsonPath = require.resolve('expo-modules-macros/package.json', {
962
- paths: [coreModuleRoot],
963
- });
956
+ return path.dirname(
957
+ require.resolve('expo-modules-macros/package.json', { paths: [coreModuleRoot] })
958
+ );
964
959
  } catch (error) {
965
960
  throw pluginError(
966
961
  macroPluginFault(
@@ -971,7 +966,11 @@ function macroPluginTool(coreModuleRoot) {
971
966
  { cause: error }
972
967
  );
973
968
  }
974
- const tool = path.join(path.dirname(pkgJsonPath), 'apple', 'ExpoModulesMacros');
969
+ }
970
+
971
+ // Generated manifests load the prebuilt plugin executable with a compiler flag.
972
+ function macroPluginTool(coreModuleRoot) {
973
+ const tool = path.join(macrosPackageRoot(coreModuleRoot), 'apple', 'ExpoModulesMacros');
975
974
  if (!fs.existsSync(tool)) {
976
975
  throw pluginError(
977
976
  macroPluginFault(`The Expo Swift macro plugin is missing its executable at ${tool}.`, 'it')
@@ -1231,13 +1230,12 @@ module.exports = function expoSpmPlugin(context) {
1231
1230
  );
1232
1231
  }
1233
1232
 
1234
- const directWatchPaths = prepareDirectWatchPaths(summary.directPackages, outDir);
1235
1233
  return {
1236
1234
  packageDependencies: summary.packageDependencies,
1237
1235
  productDependencies: summary.productDependencies,
1238
1236
  generatedSources,
1239
1237
  flavoredFrameworks,
1240
- watchPaths: [...watchPaths(identities, appTarget), ...directWatchPaths],
1238
+ watchPaths: watchPaths(identities, appTarget),
1241
1239
  scriptPhases,
1242
1240
  };
1243
1241
  };
package/template.tgz CHANGED
Binary file