expo 58.0.16 → 58.0.19
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 +36 -36
- package/package.json +19 -18
- package/scripts/spm/README.md +65 -8
- package/scripts/spm/__tests__/app-target.test.js +3 -2
- package/scripts/spm/__tests__/cli.test.js +17 -2
- package/scripts/spm/__tests__/commands.test.js +95 -0
- package/scripts/spm/__tests__/diagnostics.test.js +212 -9
- package/scripts/spm/__tests__/direct.test.js +387 -0
- package/scripts/spm/__tests__/flavored-frameworks.test.js +312 -0
- package/scripts/spm/__tests__/helpers.js +9 -0
- package/scripts/spm/__tests__/manifests.test.js +142 -50
- package/scripts/spm/__tests__/plugin.test.js +1425 -35
- package/scripts/spm/__tests__/precompiled-sources.test.js +139 -0
- package/scripts/spm/__tests__/script-phases.test.js +326 -0
- package/scripts/spm/app-target.js +4 -3
- package/scripts/spm/classify.js +8 -6
- package/scripts/spm/cli.js +11 -4
- package/scripts/spm/commands.js +49 -0
- package/scripts/spm/diagnostics.js +118 -12
- package/scripts/spm/direct.js +215 -0
- package/scripts/spm/flavored-frameworks.js +190 -30
- package/scripts/spm/manifests.js +64 -10
- package/scripts/spm/plugin.js +501 -80
- package/scripts/spm/script-phases.js +54 -0
- package/src/__tests__/tsconfig-base-export.test.node.ts +23 -0
- package/template.tgz +0 -0
|
@@ -15,7 +15,8 @@ const { execFileSync } = require('child_process');
|
|
|
15
15
|
const fs = require('fs');
|
|
16
16
|
const path = require('path');
|
|
17
17
|
|
|
18
|
-
const {
|
|
18
|
+
const { spmUpdateCommand } = require('./commands');
|
|
19
|
+
const { pluginError, rerunSpmUpdate } = require('./diagnostics');
|
|
19
20
|
|
|
20
21
|
const FLAVORS = ['debug', 'release'];
|
|
21
22
|
|
|
@@ -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`),
|
|
@@ -51,23 +54,32 @@ function existingArtifactSource(baseDir, flavor, frameworkName) {
|
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
/**
|
|
54
|
-
*
|
|
55
|
-
* `
|
|
57
|
+
* The kinds of place every precompiled artifact lookup tries, in order:
|
|
58
|
+
* EXPO_PRECOMPILED_MODULES_PATH (`env`), monorepo prebuild output (`monorepo`), and the npm
|
|
59
|
+
* package's `prebuilds/` copy (`bundled`, skipped without a module root).
|
|
56
60
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
path.resolve(__dirname, '..', '..', '..', 'precompile', '.build', ...buildPath),
|
|
64
|
-
path.join(moduleRoot, 'prebuilds', ...bundledPath)
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
const PRECOMPILED_SOURCE_KINDS = Object.freeze(['env', 'monorepo', 'bundled']);
|
|
62
|
+
|
|
63
|
+
function precompiledBases(buildPath, moduleRoot, bundledPath) {
|
|
64
|
+
const envPath = process.env.EXPO_PRECOMPILED_MODULES_PATH;
|
|
65
|
+
const dirs = {
|
|
66
|
+
env: envPath ? path.resolve(envPath, ...buildPath) : null,
|
|
67
|
+
monorepo: path.resolve(__dirname, '..', '..', '..', 'precompile', '.build', ...buildPath),
|
|
68
|
+
bundled: moduleRoot != null ? path.join(moduleRoot, 'prebuilds', ...bundledPath) : null,
|
|
69
|
+
};
|
|
70
|
+
const bases = PRECOMPILED_SOURCE_KINDS.filter((kind) => dirs[kind] != null).map((kind) => ({
|
|
71
|
+
kind,
|
|
72
|
+
dir: dirs[kind],
|
|
73
|
+
}));
|
|
74
|
+
return bases.filter((base, index) => bases.findIndex((b) => b.dir === base.dir) === index);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function artifactBases(packageName, moduleRoot) {
|
|
78
|
+
return precompiledBases([packageName, 'output'], moduleRoot, ['output']);
|
|
67
79
|
}
|
|
68
80
|
|
|
69
81
|
function artifactBaseDirs(packageName, moduleRoot) {
|
|
70
|
-
return
|
|
82
|
+
return artifactBases(packageName, moduleRoot).map((base) => base.dir);
|
|
71
83
|
}
|
|
72
84
|
|
|
73
85
|
/**
|
|
@@ -117,7 +129,15 @@ function validateTarEntries(tarballPath, frameworkName) {
|
|
|
117
129
|
}
|
|
118
130
|
}
|
|
119
131
|
|
|
120
|
-
function
|
|
132
|
+
function incompleteXCFrameworkError(what, packageName) {
|
|
133
|
+
return pluginError({
|
|
134
|
+
what,
|
|
135
|
+
why: 'The XCFramework is incomplete because its build or its extraction did not finish, or the file is damaged.',
|
|
136
|
+
how: `Reinstall ${packageName}, or from the Expo repository root run \`node tools/bin/expotools.js prebuild ${packageName}\`. ${rerunSpmUpdate()}`,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function extractTarball(sourcePath, packageName, frameworkName, cacheDir, flavor) {
|
|
121
141
|
const stat = fs.statSync(sourcePath);
|
|
122
142
|
const destination = path.join(cacheDir, stableFrameworkId(frameworkName), flavor);
|
|
123
143
|
const xcframeworkPath = path.join(destination, `${frameworkName}.xcframework`);
|
|
@@ -142,9 +162,10 @@ function extractTarball(sourcePath, frameworkName, cacheDir, flavor) {
|
|
|
142
162
|
execFileSync('tar', ['-xzf', sourcePath, '-C', temp], { stdio: 'pipe' });
|
|
143
163
|
const extracted = path.join(temp, `${frameworkName}.xcframework`);
|
|
144
164
|
if (!fs.existsSync(path.join(extracted, 'Info.plist'))) {
|
|
145
|
-
throw
|
|
146
|
-
|
|
147
|
-
|
|
165
|
+
throw incompleteXCFrameworkError(
|
|
166
|
+
`${sourcePath} holds ${frameworkName}.xcframework with no Info.plist.`,
|
|
167
|
+
packageName
|
|
168
|
+
);
|
|
148
169
|
}
|
|
149
170
|
fs.writeFileSync(path.join(temp, '.source.json'), stamp, 'utf8');
|
|
150
171
|
});
|
|
@@ -169,9 +190,9 @@ function replaceDirectory(destination, fill) {
|
|
|
169
190
|
}
|
|
170
191
|
}
|
|
171
192
|
|
|
172
|
-
function prepareArtifactSource(source, frameworkName, cacheDir, flavor) {
|
|
193
|
+
function prepareArtifactSource(source, packageName, frameworkName, cacheDir, flavor) {
|
|
173
194
|
if (source.type === 'tarball') {
|
|
174
|
-
return extractTarball(source.path, frameworkName, cacheDir, flavor);
|
|
195
|
+
return extractTarball(source.path, packageName, frameworkName, cacheDir, flavor);
|
|
175
196
|
}
|
|
176
197
|
return path.resolve(source.path);
|
|
177
198
|
}
|
|
@@ -220,15 +241,21 @@ function validateFlavoredFramework(framework) {
|
|
|
220
241
|
};
|
|
221
242
|
}
|
|
222
243
|
|
|
244
|
+
/**
|
|
245
|
+
* The declaration goes to React Native as is, so where it was resolved from is kept beside
|
|
246
|
+
* it rather than in it.
|
|
247
|
+
*/
|
|
248
|
+
const frameworkSources = new WeakMap();
|
|
249
|
+
|
|
223
250
|
/**
|
|
224
251
|
* Returns null when this module has no precompiled artifact at all. Once any
|
|
225
252
|
* flavor is present, both are mandatory at the same source base; a partial
|
|
226
253
|
* build must not silently degrade to a one-flavor declaration.
|
|
227
254
|
*/
|
|
228
255
|
function resolveFlavoredFramework({ packageName, moduleRoot, frameworkName, cacheDir }) {
|
|
229
|
-
for (const
|
|
256
|
+
for (const base of artifactBases(packageName, moduleRoot)) {
|
|
230
257
|
const sources = Object.fromEntries(
|
|
231
|
-
FLAVORS.map((flavor) => [flavor, existingArtifactSource(
|
|
258
|
+
FLAVORS.map((flavor) => [flavor, existingArtifactSource(base.dir, flavor, frameworkName)])
|
|
232
259
|
);
|
|
233
260
|
if (sources.debug == null && sources.release == null) {
|
|
234
261
|
continue;
|
|
@@ -236,31 +263,156 @@ function resolveFlavoredFramework({ packageName, moduleRoot, frameworkName, cach
|
|
|
236
263
|
for (const flavor of FLAVORS) {
|
|
237
264
|
if (sources[flavor] == null) {
|
|
238
265
|
throw pluginError({
|
|
239
|
-
what: `${frameworkName} has an incomplete precompiled pair in ${
|
|
240
|
-
how:
|
|
266
|
+
what: `${frameworkName} has an incomplete precompiled pair in ${base.dir}: missing ${flavor}.`,
|
|
267
|
+
how: `Run the Expo prebuild pipeline for both Debug and Release before \`${spmUpdateCommand()}\`.`,
|
|
241
268
|
});
|
|
242
269
|
}
|
|
243
270
|
}
|
|
244
|
-
|
|
271
|
+
const framework = validateFlavoredFramework({
|
|
245
272
|
id: stableFrameworkId(frameworkName),
|
|
246
273
|
frameworkName,
|
|
247
274
|
linkage: 'dynamic',
|
|
248
275
|
flavors: {
|
|
249
|
-
debug: prepareArtifactSource(sources.debug, frameworkName, cacheDir, 'debug'),
|
|
250
|
-
release: prepareArtifactSource(
|
|
276
|
+
debug: prepareArtifactSource(sources.debug, packageName, frameworkName, cacheDir, 'debug'),
|
|
277
|
+
release: prepareArtifactSource(
|
|
278
|
+
sources.release,
|
|
279
|
+
packageName,
|
|
280
|
+
frameworkName,
|
|
281
|
+
cacheDir,
|
|
282
|
+
'release'
|
|
283
|
+
),
|
|
251
284
|
},
|
|
252
285
|
});
|
|
286
|
+
frameworkSources.set(framework, base);
|
|
287
|
+
return framework;
|
|
288
|
+
}
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Whether `resolveFlavoredFramework` would find an artifact, without validating or
|
|
294
|
+
* extracting it: for a pod that is not linked precompiled.
|
|
295
|
+
*/
|
|
296
|
+
function hasPrecompiledArtifact({ packageName, moduleRoot, frameworkName }) {
|
|
297
|
+
return artifactBases(packageName, moduleRoot).some((base) =>
|
|
298
|
+
FLAVORS.some((flavor) => existingArtifactSource(base.dir, flavor, frameworkName) != null)
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** The `{ kind, dir }` base a `resolveFlavoredFramework` declaration came from. */
|
|
303
|
+
function frameworkSource(framework) {
|
|
304
|
+
return frameworkSources.get(framework) ?? null;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const HEADERS_FLAVOR = 'headers';
|
|
308
|
+
|
|
309
|
+
/** Every path `resolveHeadersXCFrameworkWithSource` tries, in its order. */
|
|
310
|
+
function headersXCFrameworkSearchPaths({ packageName, moduleRoot, productName }) {
|
|
311
|
+
return artifactBases(packageName, moduleRoot).flatMap((base) =>
|
|
312
|
+
Object.values(artifactCandidates(base.dir, HEADERS_FLAVOR, `${productName}Headers`))
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* The interface-only `<Product>Headers` XCFramework a product publishes in place of its
|
|
318
|
+
* binaries, from the first of its flavored frameworks' bases that has one, as
|
|
319
|
+
* `{ xcframework, source }`. Null when no base has one.
|
|
320
|
+
*
|
|
321
|
+
* @param lastKind when set, the lookup ends after the base of this kind, so a base past it
|
|
322
|
+
* is neither returned nor validated.
|
|
323
|
+
*/
|
|
324
|
+
function resolveHeadersXCFrameworkWithSource({
|
|
325
|
+
packageName,
|
|
326
|
+
moduleRoot,
|
|
327
|
+
productName,
|
|
328
|
+
cacheDir,
|
|
329
|
+
lastKind,
|
|
330
|
+
}) {
|
|
331
|
+
const frameworkName = `${productName}Headers`;
|
|
332
|
+
const lastRank =
|
|
333
|
+
lastKind != null ? PRECOMPILED_SOURCE_KINDS.indexOf(lastKind) : PRECOMPILED_SOURCE_KINDS.length;
|
|
334
|
+
const bases = artifactBases(packageName, moduleRoot).filter(
|
|
335
|
+
(base) => PRECOMPILED_SOURCE_KINDS.indexOf(base.kind) <= lastRank
|
|
336
|
+
);
|
|
337
|
+
for (const base of bases) {
|
|
338
|
+
const artifact = existingArtifactSource(base.dir, HEADERS_FLAVOR, frameworkName);
|
|
339
|
+
if (artifact == null) continue;
|
|
340
|
+
const xcframework = prepareArtifactSource(
|
|
341
|
+
artifact,
|
|
342
|
+
packageName,
|
|
343
|
+
frameworkName,
|
|
344
|
+
cacheDir,
|
|
345
|
+
HEADERS_FLAVOR
|
|
346
|
+
);
|
|
347
|
+
if (!fs.existsSync(path.join(xcframework, 'Info.plist'))) {
|
|
348
|
+
throw incompleteXCFrameworkError(`${xcframework} has no Info.plist.`, packageName);
|
|
349
|
+
}
|
|
350
|
+
return { xcframework, source: base };
|
|
253
351
|
}
|
|
254
352
|
return null;
|
|
255
353
|
}
|
|
256
354
|
|
|
355
|
+
/**
|
|
356
|
+
* Throws when the headers XCFramework of `productName` was generated from another version of
|
|
357
|
+
* `packageName` than any of `sourceRoots`, the installed copies the app's build phase may build
|
|
358
|
+
* the framework from. Headers without the `expo-package.json` stamp predate it and pass.
|
|
359
|
+
*/
|
|
360
|
+
function assertHeadersMatchSources(headers, { packageName, productName, sourceRoots }) {
|
|
361
|
+
const stampPath = path.join(headers, 'expo-package.json');
|
|
362
|
+
if (!fs.existsSync(stampPath)) return;
|
|
363
|
+
const readVersion = (file) => readPackageVersion(file, { packageName, productName });
|
|
364
|
+
const headersVersion = readVersion(stampPath);
|
|
365
|
+
for (const root of sourceRoots) {
|
|
366
|
+
const version = readVersion(path.join(root, 'package.json'));
|
|
367
|
+
if (version === headersVersion) continue;
|
|
368
|
+
throw pluginError({
|
|
369
|
+
what: `${headers} was generated from ${packageName} ${headersVersion}, but ${packageName} at ${root} is ${version}.`,
|
|
370
|
+
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.`,
|
|
371
|
+
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}.`,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function readPackageVersion(file, { packageName, productName }) {
|
|
377
|
+
let version;
|
|
378
|
+
let cause;
|
|
379
|
+
try {
|
|
380
|
+
version = JSON.parse(fs.readFileSync(file, 'utf8')).version;
|
|
381
|
+
} catch (error) {
|
|
382
|
+
cause = error;
|
|
383
|
+
}
|
|
384
|
+
if (typeof version === 'string') return version;
|
|
385
|
+
throw pluginError(
|
|
386
|
+
{
|
|
387
|
+
what: `${file} could not be read as JSON with a string "version".`,
|
|
388
|
+
why: `The plugin compares that version to check that the ${productName} headers match the installed ${packageName} sources; this file is damaged or incomplete.`,
|
|
389
|
+
how: `Reinstall ${packageName}. In the Expo repository, rebuild the headers with \`et prebuild ${packageName}\`.`,
|
|
390
|
+
},
|
|
391
|
+
{ cause }
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/** `resolveHeadersXCFrameworkWithSource` without the source: the XCFramework path, or null. */
|
|
396
|
+
function resolveHeadersXCFramework(lookup) {
|
|
397
|
+
return resolveHeadersXCFrameworkWithSource(lookup)?.xcframework ?? null;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** The directories `resolveHeadersXCFramework` searches, in lookup order. */
|
|
401
|
+
function headersXCFrameworkDirs(packageName, moduleRoot) {
|
|
402
|
+
return artifactBaseDirs(packageName, moduleRoot).map((baseDir) =>
|
|
403
|
+
artifactDir(baseDir, HEADERS_FLAVOR)
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
257
407
|
/**
|
|
258
408
|
* Candidate parents (each holding `<flavor>/<Dep>.xcframework`) for a SwiftPM
|
|
259
409
|
* package a precompiled module links. The bundled copy lives in the npm package
|
|
260
410
|
* of the module that links it.
|
|
261
411
|
*/
|
|
262
412
|
function spmDependencyBaseDirs(depName, ownerModuleRoot) {
|
|
263
|
-
return
|
|
413
|
+
return precompiledBases(['.spm-deps', depName], ownerModuleRoot, ['spm-deps', depName]).map(
|
|
414
|
+
(base) => base.dir
|
|
415
|
+
);
|
|
264
416
|
}
|
|
265
417
|
|
|
266
418
|
function readXcframeworkPlist(plistPath) {
|
|
@@ -320,7 +472,7 @@ function isDirectory(candidate) {
|
|
|
320
472
|
{
|
|
321
473
|
what: `${candidate} could not be read: ${error.message}.`,
|
|
322
474
|
why: 'The plugin cannot tell whether a precompiled dependency is there, and it will not silently build an app without one.',
|
|
323
|
-
how:
|
|
475
|
+
how: `Make that path readable — or delete it and rebuild the dependency with the Expo prebuild pipeline — then run \`${spmUpdateCommand()}\` again.`,
|
|
324
476
|
},
|
|
325
477
|
{ cause: error }
|
|
326
478
|
);
|
|
@@ -472,11 +624,19 @@ function prepareCompileInterfaces(frameworks, destination) {
|
|
|
472
624
|
|
|
473
625
|
module.exports = {
|
|
474
626
|
FLAVORS,
|
|
627
|
+
PRECOMPILED_SOURCE_KINDS,
|
|
475
628
|
artifactBaseDirs,
|
|
476
629
|
assertDistinctFlavoredFrameworks,
|
|
630
|
+
assertHeadersMatchSources,
|
|
477
631
|
byteOrder,
|
|
632
|
+
frameworkSource,
|
|
633
|
+
hasPrecompiledArtifact,
|
|
634
|
+
headersXCFrameworkDirs,
|
|
635
|
+
headersXCFrameworkSearchPaths,
|
|
478
636
|
prepareCompileInterfaces,
|
|
479
637
|
resolveFlavoredFramework,
|
|
638
|
+
resolveHeadersXCFramework,
|
|
639
|
+
resolveHeadersXCFrameworkWithSource,
|
|
480
640
|
resolveSpmDependencyFrameworks,
|
|
481
641
|
stableFrameworkId,
|
|
482
642
|
validateFlavoredFramework,
|
package/scripts/spm/manifests.js
CHANGED
|
@@ -11,7 +11,6 @@ const fs = require('fs');
|
|
|
11
11
|
const path = require('path');
|
|
12
12
|
const { appleSourceDir, scanAppleSources } = require('./classify');
|
|
13
13
|
const { reactProductDependencies, reactPackageDeclarations } = require('./react-descriptor');
|
|
14
|
-
const { runDumpPackage } = require('./cli');
|
|
15
14
|
const { pluginError } = require('./diagnostics');
|
|
16
15
|
|
|
17
16
|
// ---------------------------------------------------------------------------
|
|
@@ -862,12 +861,13 @@ function emitPackage(
|
|
|
862
861
|
frameworkSearchPath,
|
|
863
862
|
outDir,
|
|
864
863
|
codegenPkgPath = null,
|
|
864
|
+
jsiHeadersPkgPath = null,
|
|
865
865
|
minimumIosDeploymentTarget = null,
|
|
866
866
|
macroFlags = [],
|
|
867
867
|
satisfiedDependencies = new Set(),
|
|
868
868
|
}
|
|
869
869
|
) {
|
|
870
|
-
const { targetDeps, pkgDeps } = sourceDependencies(react, codegenPkgPath);
|
|
870
|
+
const { targetDeps, pkgDeps } = sourceDependencies(react, codegenPkgPath, jsiHeadersPkgPath);
|
|
871
871
|
const { manifest: linked, partlyProvidedPackages } = withoutSatisfiedProducts(
|
|
872
872
|
manifest,
|
|
873
873
|
satisfiedDependencies
|
|
@@ -900,17 +900,68 @@ function emitPackage(
|
|
|
900
900
|
};
|
|
901
901
|
}
|
|
902
902
|
|
|
903
|
+
const JSI_HEADERS = 'ExpoModulesJSIHeaders';
|
|
904
|
+
const JSI_LINK = 'ExpoModulesJSILink';
|
|
905
|
+
|
|
903
906
|
/**
|
|
904
907
|
* React compile products are the exact invariant set supplied by RN's context.
|
|
905
908
|
* Every Expo source target needs them: even a target that only imports
|
|
906
909
|
* ExpoModulesCore loads its Clang module map, which declares `use React`.
|
|
910
|
+
*
|
|
911
|
+
* ExpoModulesCore's interface has `@_exported import ExpoModulesJSI`, so every source
|
|
912
|
+
* target also needs the ExpoModulesJSI headers package when there is one.
|
|
907
913
|
*/
|
|
908
|
-
function sourceDependencies(react, codegenPkgPath) {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
+
function sourceDependencies(react, codegenPkgPath, jsiHeadersPkgPath) {
|
|
915
|
+
const targetDeps = react != null ? reactProductDependencies(react) : [];
|
|
916
|
+
const pkgDeps = react != null ? reactPackageDeclarations(react, codegenPkgPath) : [];
|
|
917
|
+
if (jsiHeadersPkgPath != null) {
|
|
918
|
+
targetDeps.push(`.product(name: "${JSI_HEADERS}", package: "${JSI_HEADERS}")`);
|
|
919
|
+
pkgDeps.push(
|
|
920
|
+
`.package(name: "${JSI_HEADERS}", path: "${escapeSwiftString(jsiHeadersPkgPath)}")`
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
return { targetDeps, pkgDeps };
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Writes `<outDir>/ExpoModulesJSIHeaders`: a package that hands source packages the
|
|
928
|
+
* ExpoModulesJSI interface from `headersXCFramework`, while the app's "Build
|
|
929
|
+
* ExpoModulesJSI" phase supplies the real framework. Replaces any previous emission.
|
|
930
|
+
* Returns the package directory.
|
|
931
|
+
*/
|
|
932
|
+
function emitExpoModulesJSIHeadersPackage(headersXCFramework, outDir) {
|
|
933
|
+
const pkgDir = path.join(outDir, JSI_HEADERS);
|
|
934
|
+
fs.rmSync(pkgDir, { recursive: true, force: true });
|
|
935
|
+
fs.mkdirSync(path.join(pkgDir, JSI_LINK), { recursive: true });
|
|
936
|
+
fs.symlinkSync(headersXCFramework, path.join(pkgDir, `${JSI_HEADERS}.xcframework`));
|
|
937
|
+
fs.writeFileSync(path.join(pkgDir, JSI_LINK, `${JSI_LINK}.swift`), '');
|
|
938
|
+
fs.writeFileSync(
|
|
939
|
+
path.join(pkgDir, 'Package.swift'),
|
|
940
|
+
`// swift-tools-version: 6.0
|
|
941
|
+
// AUTO-GENERATED by expo/scripts/spm/plugin.js — do not edit.
|
|
942
|
+
// Compile-only ExpoModulesJSI. The app's "Build ExpoModulesJSI" phase builds and embeds the
|
|
943
|
+
// real framework.
|
|
944
|
+
import PackageDescription
|
|
945
|
+
|
|
946
|
+
let package = Package(
|
|
947
|
+
name: "${JSI_HEADERS}",
|
|
948
|
+
products: [
|
|
949
|
+
.library(name: "${JSI_HEADERS}", targets: ["${JSI_HEADERS}", "${JSI_LINK}"]),
|
|
950
|
+
],
|
|
951
|
+
targets: [
|
|
952
|
+
.binaryTarget(name: "${JSI_HEADERS}", path: "${JSI_HEADERS}.xcframework"),
|
|
953
|
+
// Swift records no auto-link entry for a module it loads from a library
|
|
954
|
+
// XCFramework, so the app's link step gets the real framework from here.
|
|
955
|
+
.target(
|
|
956
|
+
name: "${JSI_LINK}",
|
|
957
|
+
path: "${JSI_LINK}",
|
|
958
|
+
linkerSettings: [.linkedFramework("ExpoModulesJSI")]
|
|
959
|
+
),
|
|
960
|
+
]
|
|
961
|
+
)
|
|
962
|
+
`
|
|
963
|
+
);
|
|
964
|
+
return pkgDir;
|
|
914
965
|
}
|
|
915
966
|
|
|
916
967
|
/**
|
|
@@ -922,10 +973,12 @@ function sourceDependencies(react, codegenPkgPath) {
|
|
|
922
973
|
* depends on a target or declares a Swift package the generated package cannot
|
|
923
974
|
* declare, or a target's sources cannot be located — the module is then skipped and
|
|
924
975
|
* diagnosed rather than emitted broken.
|
|
976
|
+
*
|
|
977
|
+
* @param dumpedJson the manifest's `swift package dump-package` output.
|
|
925
978
|
*/
|
|
926
|
-
function emitSourceManifestPackage(moduleRoot, emitContext) {
|
|
979
|
+
function emitSourceManifestPackage(moduleRoot, emitContext, dumpedJson) {
|
|
927
980
|
const { unsupportedTargetDeps, unsupportedPackageDeps, ...dumped } = parseDumpedManifest(
|
|
928
|
-
|
|
981
|
+
dumpedJson,
|
|
929
982
|
injectedPackageNames(emitContext.react)
|
|
930
983
|
);
|
|
931
984
|
if (unsupportedTargetDeps.length) {
|
|
@@ -985,4 +1038,5 @@ module.exports = {
|
|
|
985
1038
|
raiseFloor,
|
|
986
1039
|
emitSourceManifestPackage,
|
|
987
1040
|
emitPureSwiftSourcePackage,
|
|
1041
|
+
emitExpoModulesJSIHeadersPackage,
|
|
988
1042
|
};
|