expo 58.0.16 → 58.0.17
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.
- package/android/build.gradle +2 -2
- package/bundledNativeModules.json +26 -26
- package/package.json +16 -15
- package/scripts/spm/README.md +23 -6
- package/scripts/spm/__tests__/app-target.test.js +3 -2
- package/scripts/spm/__tests__/commands.test.js +34 -0
- package/scripts/spm/__tests__/diagnostics.test.js +2 -0
- package/scripts/spm/__tests__/flavored-frameworks.test.js +185 -0
- package/scripts/spm/__tests__/manifests.test.js +104 -0
- package/scripts/spm/__tests__/plugin.test.js +206 -1
- package/scripts/spm/__tests__/script-phases.test.js +326 -0
- package/scripts/spm/app-target.js +4 -3
- package/scripts/spm/commands.js +32 -0
- package/scripts/spm/diagnostics.js +6 -4
- package/scripts/spm/flavored-frameworks.js +78 -3
- package/scripts/spm/manifests.js +60 -7
- package/scripts/spm/plugin.js +78 -7
- package/scripts/spm/script-phases.js +54 -0
- package/src/__tests__/tsconfig-base-export.test.node.ts +23 -0
- package/template.tgz +0 -0
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
|
|
18
18
|
const fs = require('fs');
|
|
19
19
|
|
|
20
|
+
const { spmUpdateCommand } = require('./commands');
|
|
21
|
+
|
|
20
22
|
/**
|
|
21
23
|
* Pod-name families already covered by the SwiftPM graph: Expo's own modules
|
|
22
24
|
* (contributed by this plugin) and React Native's products (contributed by RN).
|
|
@@ -239,7 +241,7 @@ function renderPrebuildAvailable({ podName, packageName, moduleRoot, productName
|
|
|
239
241
|
`It declares "${productName}" in its spm.config.json, so it does not need a Package.swift — the Expo prebuild pipeline builds it. The artifact is just missing.`,
|
|
240
242
|
`Build it — omit --flavor so both Debug and Release are built, since the plugin declares an immutable pair and rejects a half-built one:`,
|
|
241
243
|
` et prebuild ${packageName}`,
|
|
242
|
-
`Then re-run
|
|
244
|
+
`Then re-run \`${spmUpdateCommand()}\`. A published ${packageName} that ships prebuilds/output/<flavor>/xcframeworks is picked up with no local build.`,
|
|
243
245
|
],
|
|
244
246
|
moduleRoot
|
|
245
247
|
);
|
|
@@ -510,12 +512,12 @@ function renderPartiallyPrecompiled({
|
|
|
510
512
|
const precompile = [
|
|
511
513
|
`To precompile all of them, ${productStep}. Omit --flavor so both Debug and Release are built, since the plugin declares an immutable pair and rejects a half-built one:`,
|
|
512
514
|
` et prebuild ${packageName}`,
|
|
513
|
-
` Then re-run
|
|
515
|
+
` Then re-run \`${spmUpdateCommand()}\`.`,
|
|
514
516
|
];
|
|
515
517
|
const remedies = [
|
|
516
518
|
...(sourceOnly ? [] : [precompile]),
|
|
517
519
|
[
|
|
518
|
-
`To build it from source instead, delete the prebuilt ${siblings} artifacts — ${artifacts}, under debug/xcframeworks and release/xcframeworks — from each directory below, then re-run
|
|
520
|
+
`To build it from source instead, delete the prebuilt ${siblings} artifacts — ${artifacts}, under debug/xcframeworks and release/xcframeworks — from each directory below, then re-run \`${spmUpdateCommand()}\`. The plugin searches them in this order and uses the first one that has an artifact, so one left behind anywhere is picked up again:`,
|
|
519
521
|
...artifactDirs.map((dir) => ` ${dir}`),
|
|
520
522
|
],
|
|
521
523
|
[remedy.exclude(packageName)],
|
|
@@ -711,7 +713,7 @@ function renderRootConflictWarning(entries) {
|
|
|
711
713
|
` built by this plugin: ${moduleRoot}`,
|
|
712
714
|
` imported by your app: ${autolinkedRoot}`,
|
|
713
715
|
` Both are real directories, not one directory reached through a symlink, so the copies can be different versions. The plugin builds the first one; your app's JavaScript imports the second. When the two disagree it usually surfaces at runtime, as a missing method or "Cannot find native module" — and two copies of different versions can fail the build instead.`,
|
|
714
|
-
` Run \`npm ls ${packageName}\` (or \`yarn why\` / \`pnpm why\`) to find what pulls in the second copy, deduplicate it with \`npm dedupe\` (or \`yarn dedupe\` / \`pnpm dedupe\`), then re-run
|
|
716
|
+
` Run \`npm ls ${packageName}\` (or \`yarn why\` / \`pnpm why\`) to find what pulls in the second copy, deduplicate it with \`npm dedupe\` (or \`yarn dedupe\` / \`pnpm dedupe\`), then re-run \`${spmUpdateCommand()}\`.`,
|
|
715
717
|
].join('\n')
|
|
716
718
|
)
|
|
717
719
|
.join('\n\n');
|
|
@@ -15,6 +15,7 @@ const { execFileSync } = require('child_process');
|
|
|
15
15
|
const fs = require('fs');
|
|
16
16
|
const path = require('path');
|
|
17
17
|
|
|
18
|
+
const { spmUpdateCommand } = require('./commands');
|
|
18
19
|
const { pluginError } = require('./diagnostics');
|
|
19
20
|
|
|
20
21
|
const FLAVORS = ['debug', 'release'];
|
|
@@ -31,8 +32,10 @@ function stableFrameworkId(frameworkName) {
|
|
|
31
32
|
return kebab.startsWith('expo-') ? kebab : `expo-${kebab}`;
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
const artifactDir = (baseDir, flavor) => path.join(baseDir, flavor, 'xcframeworks');
|
|
36
|
+
|
|
34
37
|
function artifactCandidates(baseDir, flavor, frameworkName) {
|
|
35
|
-
const dir =
|
|
38
|
+
const dir = artifactDir(baseDir, flavor);
|
|
36
39
|
return {
|
|
37
40
|
xcframework: path.join(dir, `${frameworkName}.xcframework`),
|
|
38
41
|
tarball: path.join(dir, `${frameworkName}.tar.gz`),
|
|
@@ -237,7 +240,7 @@ function resolveFlavoredFramework({ packageName, moduleRoot, frameworkName, cach
|
|
|
237
240
|
if (sources[flavor] == null) {
|
|
238
241
|
throw pluginError({
|
|
239
242
|
what: `${frameworkName} has an incomplete precompiled pair in ${baseDir}: missing ${flavor}.`,
|
|
240
|
-
how:
|
|
243
|
+
how: `Run the Expo prebuild pipeline for both Debug and Release before \`${spmUpdateCommand()}\`.`,
|
|
241
244
|
});
|
|
242
245
|
}
|
|
243
246
|
}
|
|
@@ -254,6 +257,75 @@ function resolveFlavoredFramework({ packageName, moduleRoot, frameworkName, cach
|
|
|
254
257
|
return null;
|
|
255
258
|
}
|
|
256
259
|
|
|
260
|
+
/**
|
|
261
|
+
* The interface-only `<Product>Headers` XCFramework a product publishes in place of its
|
|
262
|
+
* binaries, from the same bases as its flavored frameworks. Null when no base has one.
|
|
263
|
+
*/
|
|
264
|
+
function resolveHeadersXCFramework({ packageName, moduleRoot, productName, cacheDir }) {
|
|
265
|
+
const frameworkName = `${productName}Headers`;
|
|
266
|
+
for (const baseDir of artifactBaseDirs(packageName, moduleRoot)) {
|
|
267
|
+
const source = existingArtifactSource(baseDir, 'headers', frameworkName);
|
|
268
|
+
if (source == null) continue;
|
|
269
|
+
const xcframework = prepareArtifactSource(source, frameworkName, cacheDir, 'headers');
|
|
270
|
+
if (!fs.existsSync(path.join(xcframework, 'Info.plist'))) {
|
|
271
|
+
throw pluginError({
|
|
272
|
+
what: `${xcframework} has no Info.plist.`,
|
|
273
|
+
why: 'The XCFramework is incomplete, so Swift packages cannot compile against it.',
|
|
274
|
+
how: `Reinstall ${packageName}, or delete it and run the Expo prebuild pipeline for ${packageName} again.`,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return xcframework;
|
|
278
|
+
}
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Throws when the headers XCFramework of `productName` was generated from another version of
|
|
284
|
+
* `packageName` than any of `sourceRoots`, the installed copies the app's build phase may build
|
|
285
|
+
* the framework from. Headers without the `expo-package.json` stamp predate it and pass.
|
|
286
|
+
*/
|
|
287
|
+
function assertHeadersMatchSources(headers, { packageName, productName, sourceRoots }) {
|
|
288
|
+
const stampPath = path.join(headers, 'expo-package.json');
|
|
289
|
+
if (!fs.existsSync(stampPath)) return;
|
|
290
|
+
const readVersion = (file) => readPackageVersion(file, { packageName, productName });
|
|
291
|
+
const headersVersion = readVersion(stampPath);
|
|
292
|
+
for (const root of sourceRoots) {
|
|
293
|
+
const version = readVersion(path.join(root, 'package.json'));
|
|
294
|
+
if (version === headersVersion) continue;
|
|
295
|
+
throw pluginError({
|
|
296
|
+
what: `${headers} was generated from ${packageName} ${headersVersion}, but ${packageName} at ${root} is ${version}.`,
|
|
297
|
+
why: `The app's "Build ${productName}" phase builds the framework from the installed sources, and Swift packages compile against the headers. Headers from another version make the link fail with an error that does not name this cause.`,
|
|
298
|
+
how: `Make the versions match: in the Expo repository, rebuild the headers with \`et prebuild ${packageName}\`; otherwise unset EXPO_PRECOMPILED_MODULES_PATH, or reinstall ${packageName}.`,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function readPackageVersion(file, { packageName, productName }) {
|
|
304
|
+
let version;
|
|
305
|
+
let cause;
|
|
306
|
+
try {
|
|
307
|
+
version = JSON.parse(fs.readFileSync(file, 'utf8')).version;
|
|
308
|
+
} catch (error) {
|
|
309
|
+
cause = error;
|
|
310
|
+
}
|
|
311
|
+
if (typeof version === 'string') return version;
|
|
312
|
+
throw pluginError(
|
|
313
|
+
{
|
|
314
|
+
what: `${file} could not be read as JSON with a string "version".`,
|
|
315
|
+
why: `The plugin compares that version to check that the ${productName} headers match the installed ${packageName} sources; this file is damaged or incomplete.`,
|
|
316
|
+
how: `Reinstall ${packageName}. In the Expo repository, rebuild the headers with \`et prebuild ${packageName}\`.`,
|
|
317
|
+
},
|
|
318
|
+
{ cause }
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** The directories `resolveHeadersXCFramework` searches, in lookup order. */
|
|
323
|
+
function headersXCFrameworkDirs(packageName, moduleRoot) {
|
|
324
|
+
return artifactBaseDirs(packageName, moduleRoot).map((baseDir) =>
|
|
325
|
+
artifactDir(baseDir, 'headers')
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
257
329
|
/**
|
|
258
330
|
* Candidate parents (each holding `<flavor>/<Dep>.xcframework`) for a SwiftPM
|
|
259
331
|
* package a precompiled module links. The bundled copy lives in the npm package
|
|
@@ -320,7 +392,7 @@ function isDirectory(candidate) {
|
|
|
320
392
|
{
|
|
321
393
|
what: `${candidate} could not be read: ${error.message}.`,
|
|
322
394
|
why: 'The plugin cannot tell whether a precompiled dependency is there, and it will not silently build an app without one.',
|
|
323
|
-
how:
|
|
395
|
+
how: `Make that path readable — or delete it and rebuild the dependency with the Expo prebuild pipeline — then run \`${spmUpdateCommand()}\` again.`,
|
|
324
396
|
},
|
|
325
397
|
{ cause: error }
|
|
326
398
|
);
|
|
@@ -474,9 +546,12 @@ module.exports = {
|
|
|
474
546
|
FLAVORS,
|
|
475
547
|
artifactBaseDirs,
|
|
476
548
|
assertDistinctFlavoredFrameworks,
|
|
549
|
+
assertHeadersMatchSources,
|
|
477
550
|
byteOrder,
|
|
551
|
+
headersXCFrameworkDirs,
|
|
478
552
|
prepareCompileInterfaces,
|
|
479
553
|
resolveFlavoredFramework,
|
|
554
|
+
resolveHeadersXCFramework,
|
|
480
555
|
resolveSpmDependencyFrameworks,
|
|
481
556
|
stableFrameworkId,
|
|
482
557
|
validateFlavoredFramework,
|
package/scripts/spm/manifests.js
CHANGED
|
@@ -862,12 +862,13 @@ function emitPackage(
|
|
|
862
862
|
frameworkSearchPath,
|
|
863
863
|
outDir,
|
|
864
864
|
codegenPkgPath = null,
|
|
865
|
+
jsiHeadersPkgPath = null,
|
|
865
866
|
minimumIosDeploymentTarget = null,
|
|
866
867
|
macroFlags = [],
|
|
867
868
|
satisfiedDependencies = new Set(),
|
|
868
869
|
}
|
|
869
870
|
) {
|
|
870
|
-
const { targetDeps, pkgDeps } = sourceDependencies(react, codegenPkgPath);
|
|
871
|
+
const { targetDeps, pkgDeps } = sourceDependencies(react, codegenPkgPath, jsiHeadersPkgPath);
|
|
871
872
|
const { manifest: linked, partlyProvidedPackages } = withoutSatisfiedProducts(
|
|
872
873
|
manifest,
|
|
873
874
|
satisfiedDependencies
|
|
@@ -900,17 +901,68 @@ function emitPackage(
|
|
|
900
901
|
};
|
|
901
902
|
}
|
|
902
903
|
|
|
904
|
+
const JSI_HEADERS = 'ExpoModulesJSIHeaders';
|
|
905
|
+
const JSI_LINK = 'ExpoModulesJSILink';
|
|
906
|
+
|
|
903
907
|
/**
|
|
904
908
|
* React compile products are the exact invariant set supplied by RN's context.
|
|
905
909
|
* Every Expo source target needs them: even a target that only imports
|
|
906
910
|
* ExpoModulesCore loads its Clang module map, which declares `use React`.
|
|
911
|
+
*
|
|
912
|
+
* ExpoModulesCore's interface has `@_exported import ExpoModulesJSI`, so every source
|
|
913
|
+
* target also needs the ExpoModulesJSI headers package when there is one.
|
|
907
914
|
*/
|
|
908
|
-
function sourceDependencies(react, codegenPkgPath) {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
915
|
+
function sourceDependencies(react, codegenPkgPath, jsiHeadersPkgPath) {
|
|
916
|
+
const targetDeps = react != null ? reactProductDependencies(react) : [];
|
|
917
|
+
const pkgDeps = react != null ? reactPackageDeclarations(react, codegenPkgPath) : [];
|
|
918
|
+
if (jsiHeadersPkgPath != null) {
|
|
919
|
+
targetDeps.push(`.product(name: "${JSI_HEADERS}", package: "${JSI_HEADERS}")`);
|
|
920
|
+
pkgDeps.push(
|
|
921
|
+
`.package(name: "${JSI_HEADERS}", path: "${escapeSwiftString(jsiHeadersPkgPath)}")`
|
|
922
|
+
);
|
|
923
|
+
}
|
|
924
|
+
return { targetDeps, pkgDeps };
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Writes `<outDir>/ExpoModulesJSIHeaders`: a package that hands source packages the
|
|
929
|
+
* ExpoModulesJSI interface from `headersXCFramework`, while the app's "Build
|
|
930
|
+
* ExpoModulesJSI" phase supplies the real framework. Replaces any previous emission.
|
|
931
|
+
* Returns the package directory.
|
|
932
|
+
*/
|
|
933
|
+
function emitExpoModulesJSIHeadersPackage(headersXCFramework, outDir) {
|
|
934
|
+
const pkgDir = path.join(outDir, JSI_HEADERS);
|
|
935
|
+
fs.rmSync(pkgDir, { recursive: true, force: true });
|
|
936
|
+
fs.mkdirSync(path.join(pkgDir, JSI_LINK), { recursive: true });
|
|
937
|
+
fs.symlinkSync(headersXCFramework, path.join(pkgDir, `${JSI_HEADERS}.xcframework`));
|
|
938
|
+
fs.writeFileSync(path.join(pkgDir, JSI_LINK, `${JSI_LINK}.swift`), '');
|
|
939
|
+
fs.writeFileSync(
|
|
940
|
+
path.join(pkgDir, 'Package.swift'),
|
|
941
|
+
`// swift-tools-version: 6.0
|
|
942
|
+
// AUTO-GENERATED by expo/scripts/spm/plugin.js — do not edit.
|
|
943
|
+
// Compile-only ExpoModulesJSI. The app's "Build ExpoModulesJSI" phase builds and embeds the
|
|
944
|
+
// real framework.
|
|
945
|
+
import PackageDescription
|
|
946
|
+
|
|
947
|
+
let package = Package(
|
|
948
|
+
name: "${JSI_HEADERS}",
|
|
949
|
+
products: [
|
|
950
|
+
.library(name: "${JSI_HEADERS}", targets: ["${JSI_HEADERS}", "${JSI_LINK}"]),
|
|
951
|
+
],
|
|
952
|
+
targets: [
|
|
953
|
+
.binaryTarget(name: "${JSI_HEADERS}", path: "${JSI_HEADERS}.xcframework"),
|
|
954
|
+
// Swift records no auto-link entry for a module it loads from a library
|
|
955
|
+
// XCFramework, so the app's link step gets the real framework from here.
|
|
956
|
+
.target(
|
|
957
|
+
name: "${JSI_LINK}",
|
|
958
|
+
path: "${JSI_LINK}",
|
|
959
|
+
linkerSettings: [.linkedFramework("ExpoModulesJSI")]
|
|
960
|
+
),
|
|
961
|
+
]
|
|
962
|
+
)
|
|
963
|
+
`
|
|
964
|
+
);
|
|
965
|
+
return pkgDir;
|
|
914
966
|
}
|
|
915
967
|
|
|
916
968
|
/**
|
|
@@ -985,4 +1037,5 @@ module.exports = {
|
|
|
985
1037
|
raiseFloor,
|
|
986
1038
|
emitSourceManifestPackage,
|
|
987
1039
|
emitPureSwiftSourcePackage,
|
|
1040
|
+
emitExpoModulesJSIHeadersPackage,
|
|
988
1041
|
};
|
package/scripts/spm/plugin.js
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* two forms:
|
|
8
8
|
*
|
|
9
9
|
* - PRECOMPILED — modules with built Debug + Release xcframeworks
|
|
10
|
-
* (ExpoModulesCore,
|
|
10
|
+
* (ExpoModulesCore, ExpoModulesWorklets, …): declared to
|
|
11
11
|
* RN as paired dynamic frameworks. RN selects, links, embeds, and signs
|
|
12
|
-
* them outside SwiftPM.
|
|
12
|
+
* them outside SwiftPM. ExpoModulesJSI is the exception: an app build
|
|
13
|
+
* phase compiles it against the app's React Native.
|
|
13
14
|
* - SOURCE-BUILT — modules compiled from source (Expo, EXConstants, …):
|
|
14
15
|
* emitted as a source `Package.swift`. Pure-Swift modules are a single
|
|
15
16
|
* target; mixed Swift/ObjC modules need a checked-in Package.swift.
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
'use strict';
|
|
38
39
|
|
|
39
40
|
const fs = require('fs');
|
|
41
|
+
const { createRequire } = require('module');
|
|
40
42
|
const path = require('path');
|
|
41
43
|
|
|
42
44
|
const { readPodfileProperties, resolveAppTarget } = require('./app-target');
|
|
@@ -53,6 +55,7 @@ const {
|
|
|
53
55
|
moduleNeedsReact,
|
|
54
56
|
scanAppleSources,
|
|
55
57
|
} = require('./classify');
|
|
58
|
+
const { configureSpmUpdateCommand, spmUpdateCommand } = require('./commands');
|
|
56
59
|
const {
|
|
57
60
|
classifyUnsupported,
|
|
58
61
|
collectDuplicatePods,
|
|
@@ -71,17 +74,25 @@ const {
|
|
|
71
74
|
const {
|
|
72
75
|
artifactBaseDirs,
|
|
73
76
|
assertDistinctFlavoredFrameworks,
|
|
77
|
+
assertHeadersMatchSources,
|
|
74
78
|
byteOrder,
|
|
79
|
+
headersXCFrameworkDirs,
|
|
75
80
|
prepareCompileInterfaces,
|
|
76
81
|
resolveFlavoredFramework,
|
|
82
|
+
resolveHeadersXCFramework,
|
|
77
83
|
resolveSpmDependencyFrameworks,
|
|
78
84
|
} = require('./flavored-frameworks');
|
|
79
|
-
const {
|
|
85
|
+
const {
|
|
86
|
+
emitExpoModulesJSIHeadersPackage,
|
|
87
|
+
emitPureSwiftSourcePackage,
|
|
88
|
+
emitSourceManifestPackage,
|
|
89
|
+
} = require('./manifests');
|
|
80
90
|
const { readPrebuiltMetadata } = require('./metadata');
|
|
81
91
|
const { readPodspecFacts } = require('./podspec');
|
|
82
92
|
const { scriptPhasesForModules } = require('./script-phases');
|
|
83
93
|
|
|
84
94
|
const CORE_POD = 'ExpoModulesCore';
|
|
95
|
+
const JSI_POD = 'ExpoModulesJSI';
|
|
85
96
|
|
|
86
97
|
/** npm name → autolinked root, only for roots still on disk. */
|
|
87
98
|
function collectAutolinkedRoots(autolinking) {
|
|
@@ -286,8 +297,8 @@ function uncoveredPod(identity, ...refusals) {
|
|
|
286
297
|
|
|
287
298
|
/**
|
|
288
299
|
* What the passes decided for each pod, keyed by pod name: CocoaPods pod names are
|
|
289
|
-
* unique, so a name two packages list is one pod. `linkedAs` is `'
|
|
290
|
-
* `'manifest'`, `'pure-swift'` or null. A precompiled record carries its
|
|
300
|
+
* unique, so a name two packages list is one pod. `linkedAs` is `'build-phase'`,
|
|
301
|
+
* `'precompiled'`, `'manifest'`, `'pure-swift'` or null. A precompiled record carries its
|
|
291
302
|
* `framework`.
|
|
292
303
|
*/
|
|
293
304
|
function podRecords(identities) {
|
|
@@ -300,6 +311,52 @@ function podRecords(identities) {
|
|
|
300
311
|
return records;
|
|
301
312
|
}
|
|
302
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Before pass 1 — ExpoModulesJSI is never linked precompiled, whatever artifacts exist:
|
|
316
|
+
* it must be compiled against the app's React Native, which the app's "Build
|
|
317
|
+
* ExpoModulesJSI" phase does. Source packages compile against its headers package
|
|
318
|
+
* instead. Returns that package's directory, or null when expo-modules-jsi is not
|
|
319
|
+
* autolinked.
|
|
320
|
+
*/
|
|
321
|
+
function linkExpoModulesJSI(records, outDir, cacheDir, appRoot) {
|
|
322
|
+
const record = records.get(JSI_POD);
|
|
323
|
+
if (record == null) return null;
|
|
324
|
+
record.linkedAs = 'build-phase';
|
|
325
|
+
const { packageName, moduleRoot, productName } = record.identity;
|
|
326
|
+
const headers = resolveHeadersXCFramework({ packageName, moduleRoot, productName, cacheDir });
|
|
327
|
+
if (headers == null) {
|
|
328
|
+
const searched = headersXCFrameworkDirs(packageName, moduleRoot);
|
|
329
|
+
throw pluginError({
|
|
330
|
+
what: `${productName}Headers.xcframework (or .tar.gz) was not found in ${searched.join(', ')}.`,
|
|
331
|
+
why: `npm ships only the headers of ${productName}, because the framework must be compiled against the app's React Native: Swift packages compile against those headers, and the app's "Build ${productName}" phase builds the framework.`,
|
|
332
|
+
how: `Reinstall ${packageName} with your package manager. In the Expo repository, build the headers with \`et prebuild ${packageName}\`.`,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
const builtRoot = buildPhaseJsiRoot(appRoot);
|
|
336
|
+
assertHeadersMatchSources(headers, {
|
|
337
|
+
packageName,
|
|
338
|
+
productName,
|
|
339
|
+
sourceRoots: builtRoot == null ? [moduleRoot] : [moduleRoot, builtRoot],
|
|
340
|
+
});
|
|
341
|
+
return emitExpoModulesJSIHeadersPackage(headers, outDir);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* The expo-modules-jsi the app's "Build ExpoModulesJSI" phase builds, resolved through expo and
|
|
346
|
+
* expo-modules-core as its launcher in script-phases.js does. Null when that chain does not resolve.
|
|
347
|
+
*/
|
|
348
|
+
function buildPhaseJsiRoot(appRoot) {
|
|
349
|
+
// Not `require.resolve(..., { paths })`: from inside the expo package, Node resolves `expo` to
|
|
350
|
+
// this package itself, whatever the paths.
|
|
351
|
+
const dir = (name, from) =>
|
|
352
|
+
path.dirname(createRequire(path.join(from, 'package.json')).resolve(`${name}/package.json`));
|
|
353
|
+
try {
|
|
354
|
+
return dir('expo-modules-jsi', dir('expo-modules-core', dir('expo', appRoot)));
|
|
355
|
+
} catch {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
303
360
|
/**
|
|
304
361
|
* Pass 1 — precompiled runtime frameworks. The declaration is all-or-nothing:
|
|
305
362
|
* once one flavor exists, the resolver requires and prepares both before RN
|
|
@@ -608,6 +665,16 @@ function macroPluginFlags(coreModuleRoot) {
|
|
|
608
665
|
return ['-Xfrontend', '-load-plugin-executable', '-Xfrontend', `${tool}#ExpoModulesMacros`];
|
|
609
666
|
}
|
|
610
667
|
|
|
668
|
+
/** The app's react-native: the root React Native passes, or else the one the app resolves. */
|
|
669
|
+
function appReactNativeRoot(context, appRoot) {
|
|
670
|
+
if (typeof context.reactNativeRoot === 'string') return context.reactNativeRoot;
|
|
671
|
+
try {
|
|
672
|
+
return path.dirname(require.resolve('react-native/package.json', { paths: [appRoot] }));
|
|
673
|
+
} catch {
|
|
674
|
+
return null;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
611
678
|
module.exports = function expoSpmPlugin(context) {
|
|
612
679
|
const { autolinking, react, outputDir } = context;
|
|
613
680
|
// `context.appRoot` is the Xcode project dir (`<app>/ios`); the autolinking
|
|
@@ -617,6 +684,7 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
617
684
|
// provider, with no Expo modules registering at runtime. RN's contract hands
|
|
618
685
|
// us that root directly.
|
|
619
686
|
const appRoot = context.projectRoot;
|
|
687
|
+
configureSpmUpdateCommand({ appRoot, reactNativeRoot: appReactNativeRoot(context, appRoot) });
|
|
620
688
|
const { modules, extraDependencies } = resolveExpoModules(appRoot);
|
|
621
689
|
const metadata = readPrebuiltMetadata(appRoot);
|
|
622
690
|
const autolinkedRoots = collectAutolinkedRoots(autolinking);
|
|
@@ -655,6 +723,7 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
655
723
|
: null;
|
|
656
724
|
|
|
657
725
|
const records = podRecords(identities);
|
|
726
|
+
const jsiHeadersPkgPath = linkExpoModulesJSI(records, outDir, artifactCacheDir, appRoot);
|
|
658
727
|
const precompiled = linkPrecompiledPods(identities, records, artifactCacheDir);
|
|
659
728
|
// The SwiftPM packages those modules link ship as their own XCFrameworks, and
|
|
660
729
|
// RN takes them in the same flat array. They join before the interface tree is
|
|
@@ -686,6 +755,7 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
686
755
|
frameworkSearchPath,
|
|
687
756
|
outDir,
|
|
688
757
|
codegenPkgPath,
|
|
758
|
+
jsiHeadersPkgPath,
|
|
689
759
|
minimumIosDeploymentTarget: core.iosDeploymentTarget,
|
|
690
760
|
satisfiedDependencies,
|
|
691
761
|
// Every emitted target may use the macros (CocoaPods' "is core or depends on core" gate).
|
|
@@ -710,6 +780,7 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
710
780
|
});
|
|
711
781
|
const logListed = (label, names) =>
|
|
712
782
|
console.log(`[expo-spm-plugin] ${label} (${names.length}): ${names.join(', ') || '—'}`);
|
|
783
|
+
logListed('built by an app build phase', jsiHeadersPkgPath != null ? [JSI_POD] : []);
|
|
713
784
|
logListed('paired runtime frameworks', summary.precompiledPods);
|
|
714
785
|
logListed('source via checked-in manifest', summary.manifestPackages);
|
|
715
786
|
logListed('source pure-Swift', summary.pureSwiftPods);
|
|
@@ -776,7 +847,7 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
776
847
|
[
|
|
777
848
|
`Generating ExpoModulesProvider.swift for ${appRoot} failed: ${error.message}`,
|
|
778
849
|
' That file is the registry every Expo native module is looked up through, so without it the app builds and then fails at launch with "Cannot find native module".',
|
|
779
|
-
|
|
850
|
+
` The message above comes from \`expo-modules-autolinking generate-modules-provider\`. Fix what it names — a module with an unreadable expo-module.config.json is the common cause — then re-run \`${spmUpdateCommand()}\`.`,
|
|
780
851
|
].join('\n'),
|
|
781
852
|
{ cause: error }
|
|
782
853
|
);
|
|
@@ -786,7 +857,7 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
786
857
|
[
|
|
787
858
|
`The Expo module registry generator wrote no ExpoModulesProvider.swift to ${outDir}, although ${modules.length} Expo ${modules.length === 1 ? 'module' : 'modules'} resolved.`,
|
|
788
859
|
' Without that file no Expo native module is registered, and the app fails at launch with "Cannot find native module".',
|
|
789
|
-
|
|
860
|
+
` Re-run \`${spmUpdateCommand()}\`. If the file is still missing, report it at https://github.com/expo/expo/issues with the output of \`npx expo-modules-autolinking resolve --platform apple --json\` run in your app.`,
|
|
790
861
|
].join('\n')
|
|
791
862
|
);
|
|
792
863
|
}
|
|
@@ -70,8 +70,62 @@ export EXPO_CONSTANTS_ALLOW_NON_PODS=1
|
|
|
70
70
|
exec "$EXPO_CONSTANTS_DIR/scripts/get-app-config-ios.sh"
|
|
71
71
|
`;
|
|
72
72
|
|
|
73
|
+
const EXPO_MODULES_JSI_LAUNCHER_SCRIPT = `set -euo pipefail
|
|
74
|
+
|
|
75
|
+
if [ -z "\${NODE_BINARY:-}" ]; then
|
|
76
|
+
set +eu
|
|
77
|
+
if [ -f "$SRCROOT/.xcode.env" ]; then . "$SRCROOT/.xcode.env"; fi
|
|
78
|
+
if [ -f "$SRCROOT/.xcode.env.local" ]; then . "$SRCROOT/.xcode.env.local"; fi
|
|
79
|
+
set -eu
|
|
80
|
+
fi
|
|
81
|
+
NODE_BINARY="\${NODE_BINARY:-$(command -v node || true)}"
|
|
82
|
+
if [ -z "$NODE_BINARY" ]; then
|
|
83
|
+
echo "error: ExpoModulesJSI could not be built because node was not found. The build uses node to find react-native and expo-modules-jsi. Set NODE_BINARY in $SRCROOT/.xcode.env, for example: echo \\"export NODE_BINARY=\\$(command -v node)\\" >> \\"$SRCROOT/.xcode.env\\"" >&2
|
|
84
|
+
exit 1
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
PROJECT_ROOT="\${PROJECT_ROOT:-$(cd "$SRCROOT/.." && pwd)}"
|
|
88
|
+
|
|
89
|
+
# expo-modules-jsi is a dependency of expo-modules-core, not of the app, so it is resolved through
|
|
90
|
+
# that chain: under pnpm it is not reachable from the app root.
|
|
91
|
+
RESOLVED="$("$NODE_BINARY" -e '
|
|
92
|
+
const path = require("path");
|
|
93
|
+
const dir = (name, from) => path.dirname(require.resolve(\`\${name}/package.json\`, { paths: [from] }));
|
|
94
|
+
const root = process.argv[1];
|
|
95
|
+
const core = dir("expo-modules-core", dir("expo", root));
|
|
96
|
+
console.log(\`\${dir("react-native", root)}\\n\${dir("expo-modules-jsi", core)}\`);
|
|
97
|
+
' "$PROJECT_ROOT" || true)"
|
|
98
|
+
RN_DIR="$(printf '%s\\n' "$RESOLVED" | sed -n 1p)"
|
|
99
|
+
JSI_DIR="$(printf '%s\\n' "$RESOLVED" | sed -n 2p)"
|
|
100
|
+
if [ -z "$RN_DIR" ] || [ -z "$JSI_DIR" ]; then
|
|
101
|
+
echo "error: ExpoModulesJSI could not be built because react-native, or expo-modules-jsi through expo and expo-modules-core, could not be resolved from $PROJECT_ROOT. The dependencies are not installed, or PROJECT_ROOT does not point at the app. Install the app's dependencies, then build again." >&2
|
|
102
|
+
exit 1
|
|
103
|
+
fi
|
|
104
|
+
if [ ! -f "$JSI_DIR/apple/scripts/build-swiftpm-app-phase.sh" ]; then
|
|
105
|
+
echo "error: ExpoModulesJSI could not be built because $JSI_DIR has no apple/scripts/build-swiftpm-app-phase.sh. The installed expo-modules-jsi is older than this version of expo. Update expo-modules-jsi by reinstalling the app's dependencies so they match this version of expo, then build again." >&2
|
|
106
|
+
exit 1
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
export RN_DIR
|
|
110
|
+
exec /bin/bash "$JSI_DIR/apple/scripts/build-swiftpm-app-phase.sh"
|
|
111
|
+
`;
|
|
112
|
+
|
|
73
113
|
/** Each phase, keyed by the npm package of the module that needs it. */
|
|
74
114
|
const SCRIPT_PHASES = [
|
|
115
|
+
{
|
|
116
|
+
packageName: 'expo-modules-jsi',
|
|
117
|
+
phase: {
|
|
118
|
+
id: 'expo-modules-jsi.build',
|
|
119
|
+
name: 'Build ExpoModulesJSI',
|
|
120
|
+
script: EXPO_MODULES_JSI_LAUNCHER_SCRIPT,
|
|
121
|
+
// Source packages compile against the headers XCFramework alone; the app's own
|
|
122
|
+
// sources and its link step need the real framework.
|
|
123
|
+
position: 'beforeCompile',
|
|
124
|
+
// Xcode cannot see the framework's inputs. build-xcframework.sh skips the build
|
|
125
|
+
// when its source hash is unchanged; the copy and codesign run on every build.
|
|
126
|
+
alwaysOutOfDate: true,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
75
129
|
{
|
|
76
130
|
packageName: 'expo-constants',
|
|
77
131
|
phase: {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
const packageRoot = path.resolve(__dirname, '../..');
|
|
5
|
+
const tsconfigBasePath = path.join(packageRoot, 'tsconfig.base.json');
|
|
6
|
+
|
|
7
|
+
// Jest replaces require, so check Node's own resolution
|
|
8
|
+
const resolveInNode = (specifier: string) =>
|
|
9
|
+
execFileSync(process.execPath, ['-p', `require.resolve(${JSON.stringify(specifier)})`], {
|
|
10
|
+
cwd: packageRoot,
|
|
11
|
+
encoding: 'utf8',
|
|
12
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
13
|
+
}).trim();
|
|
14
|
+
|
|
15
|
+
describe('expo package exports', () => {
|
|
16
|
+
it("resolves 'expo/tsconfig.base' to the package's 'tsconfig.base.json'", () => {
|
|
17
|
+
expect(resolveInNode('expo/tsconfig.base')).toBe(tsconfigBasePath);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("resolves 'expo/tsconfig.base.json' to the package's 'tsconfig.base.json'", () => {
|
|
21
|
+
expect(resolveInNode('expo/tsconfig.base.json')).toBe(tsconfigBasePath);
|
|
22
|
+
});
|
|
23
|
+
});
|
package/template.tgz
CHANGED
|
Binary file
|