expo 58.0.17 → 58.0.20
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/android/src/main/java/expo/modules/ExpoModulesPackage.kt +1 -1
- package/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt +1 -1
- package/build/winter/fetch/RequestUtils.d.ts +1 -0
- package/build/winter/fetch/RequestUtils.js +4 -2
- package/build/winter/fetch/RequestUtils.js.map +1 -1
- package/build/winter/fetch/fetch.js +4 -2
- package/build/winter/fetch/fetch.js.map +1 -1
- package/bundledNativeModules.json +19 -19
- package/package.json +12 -12
- package/scripts/spm/README.md +43 -3
- package/scripts/spm/__tests__/cli.test.js +17 -2
- package/scripts/spm/__tests__/commands.test.js +61 -0
- package/scripts/spm/__tests__/diagnostics.test.js +210 -9
- package/scripts/spm/__tests__/direct.test.js +387 -0
- package/scripts/spm/__tests__/flavored-frameworks.test.js +127 -0
- package/scripts/spm/__tests__/helpers.js +9 -0
- package/scripts/spm/__tests__/manifests.test.js +38 -50
- package/scripts/spm/__tests__/plugin.test.js +1238 -53
- package/scripts/spm/__tests__/precompiled-sources.test.js +139 -0
- package/scripts/spm/classify.js +8 -6
- package/scripts/spm/cli.js +11 -4
- package/scripts/spm/commands.js +18 -1
- package/scripts/spm/diagnostics.js +112 -8
- package/scripts/spm/direct.js +215 -0
- package/scripts/spm/flavored-frameworks.js +125 -40
- package/scripts/spm/manifests.js +4 -3
- package/scripts/spm/plugin.js +432 -82
- package/src/winter/fetch/RequestUtils.ts +8 -4
- package/src/winter/fetch/__tests__/fetch-test.native.ts +56 -0
- package/src/winter/fetch/fetch.ts +8 -2
- package/template.tgz +0 -0
package/scripts/spm/plugin.js
CHANGED
|
@@ -62,6 +62,7 @@ const {
|
|
|
62
62
|
collectRootConflicts,
|
|
63
63
|
pluginError,
|
|
64
64
|
realPathOrSelf,
|
|
65
|
+
renderBuildFromSourceFallbackWarning,
|
|
65
66
|
renderExtraPodsWarning,
|
|
66
67
|
renderLeftOutCompanionWarning,
|
|
67
68
|
renderPartlyProvidedPackageWarning,
|
|
@@ -69,19 +70,32 @@ const {
|
|
|
69
70
|
renderUnmappedDependencyWarning,
|
|
70
71
|
renderXcconfigLinkerWarning,
|
|
71
72
|
reportUnsupported,
|
|
73
|
+
BUILD_FROM_SOURCE_OPTION,
|
|
74
|
+
rerunSpmUpdate,
|
|
72
75
|
unmappedPodDependencies,
|
|
73
76
|
} = require('./diagnostics');
|
|
74
77
|
const {
|
|
78
|
+
PRECOMPILED_SOURCE_KINDS,
|
|
75
79
|
artifactBaseDirs,
|
|
76
80
|
assertDistinctFlavoredFrameworks,
|
|
77
81
|
assertHeadersMatchSources,
|
|
78
82
|
byteOrder,
|
|
83
|
+
frameworkSource,
|
|
84
|
+
hasPrecompiledArtifact,
|
|
79
85
|
headersXCFrameworkDirs,
|
|
86
|
+
headersXCFrameworkSearchPaths,
|
|
80
87
|
prepareCompileInterfaces,
|
|
81
88
|
resolveFlavoredFramework,
|
|
82
89
|
resolveHeadersXCFramework,
|
|
90
|
+
resolveHeadersXCFrameworkWithSource,
|
|
83
91
|
resolveSpmDependencyFrameworks,
|
|
84
92
|
} = require('./flavored-frameworks');
|
|
93
|
+
const {
|
|
94
|
+
dependsOnCoreHeaders,
|
|
95
|
+
dumpModuleManifest,
|
|
96
|
+
emitDirectPackage,
|
|
97
|
+
prepareDirectWatchPaths,
|
|
98
|
+
} = require('./direct');
|
|
85
99
|
const {
|
|
86
100
|
emitExpoModulesJSIHeadersPackage,
|
|
87
101
|
emitPureSwiftSourcePackage,
|
|
@@ -92,6 +106,7 @@ const { readPodspecFacts } = require('./podspec');
|
|
|
92
106
|
const { scriptPhasesForModules } = require('./script-phases');
|
|
93
107
|
|
|
94
108
|
const CORE_POD = 'ExpoModulesCore';
|
|
109
|
+
const CORE_PACKAGE = 'expo-modules-core';
|
|
95
110
|
const JSI_POD = 'ExpoModulesJSI';
|
|
96
111
|
|
|
97
112
|
/** npm name → autolinked root, only for roots still on disk. */
|
|
@@ -114,7 +129,7 @@ function collectAutolinkedRoots(autolinking) {
|
|
|
114
129
|
* podspec dir that is gone is its own declaring root, or two missing packages would
|
|
115
130
|
* walk up to one ancestor and pass for one.
|
|
116
131
|
*/
|
|
117
|
-
function podIdentity(record, pod, packageName, autolinkedRoot,
|
|
132
|
+
function podIdentity(record, pod, packageName, autolinkedRoot, readModuleRoot) {
|
|
118
133
|
const documentedRoot = documentedPackageRoot(record);
|
|
119
134
|
const walkedRoot = autolinkedRoot ?? findModuleRoot(pod.podspecDir);
|
|
120
135
|
const declaringRoot =
|
|
@@ -133,21 +148,27 @@ function podIdentity(record, pod, packageName, autolinkedRoot, scanSources) {
|
|
|
133
148
|
iosDeploymentTarget: record?.iosDeploymentTarget ?? null,
|
|
134
149
|
spmPackages: record?.spmPackages ?? [],
|
|
135
150
|
autolinkWhen: record?.autolinkWhen ?? null,
|
|
136
|
-
sources:
|
|
151
|
+
sources: readModuleRoot.sources(moduleRoot),
|
|
137
152
|
podspec: readPodspecFacts({ podName: pod.podName, podspecDir: pod.podspecDir, moduleRoot }),
|
|
138
153
|
};
|
|
139
154
|
}
|
|
140
155
|
|
|
156
|
+
/** `read`, run at most once per module root: several pods can share one. */
|
|
157
|
+
function oncePerModuleRoot(read) {
|
|
158
|
+
const results = new Map();
|
|
159
|
+
return (moduleRoot) => {
|
|
160
|
+
if (!results.has(moduleRoot)) results.set(moduleRoot, read(moduleRoot));
|
|
161
|
+
return results.get(moduleRoot);
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
141
165
|
/**
|
|
142
166
|
* Every pod's identity, keyed by the pod, resolved once so every pass agrees on it.
|
|
143
167
|
*
|
|
144
168
|
* @param metadata `readPrebuiltMetadata()`: records by pod name.
|
|
145
169
|
*/
|
|
146
170
|
function resolvePodIdentities(modules, metadata, autolinkedRoots) {
|
|
147
|
-
const
|
|
148
|
-
const scanSources = (moduleRoot) =>
|
|
149
|
-
sourceScans.get(moduleRoot) ??
|
|
150
|
-
sourceScans.set(moduleRoot, scanAppleSources(moduleRoot)).get(moduleRoot);
|
|
171
|
+
const readModuleRoot = { sources: oncePerModuleRoot(scanAppleSources) };
|
|
151
172
|
const identities = new Map();
|
|
152
173
|
for (const mod of modules) {
|
|
153
174
|
for (const pod of mod.pods ?? []) {
|
|
@@ -158,7 +179,7 @@ function resolvePodIdentities(modules, metadata, autolinkedRoots) {
|
|
|
158
179
|
pod,
|
|
159
180
|
mod.packageName,
|
|
160
181
|
autolinkedRoots.get(mod.packageName),
|
|
161
|
-
|
|
182
|
+
readModuleRoot
|
|
162
183
|
)
|
|
163
184
|
);
|
|
164
185
|
}
|
|
@@ -298,14 +319,16 @@ function uncoveredPod(identity, ...refusals) {
|
|
|
298
319
|
/**
|
|
299
320
|
* What the passes decided for each pod, keyed by pod name: CocoaPods pod names are
|
|
300
321
|
* unique, so a name two packages list is one pod. `linkedAs` is `'build-phase'`,
|
|
301
|
-
* `'precompiled'`, `'manifest'`, `'pure-swift'` or null.
|
|
302
|
-
* `
|
|
322
|
+
* `'precompiled'`, `'manifest'`, `'pure-swift'` or null. ExpoModulesJSI starts as
|
|
323
|
+
* `'build-phase'` (see `linkExpoModulesJSI`). A precompiled record carries its
|
|
324
|
+
* `framework`; `linkPrecompiledPods` documents `buildFromSource`.
|
|
303
325
|
*/
|
|
304
326
|
function podRecords(identities) {
|
|
305
327
|
const records = new Map();
|
|
306
328
|
for (const identity of identities.values()) {
|
|
307
329
|
if (!records.has(identity.podName)) {
|
|
308
|
-
|
|
330
|
+
const linkedAs = identity.podName === JSI_POD ? 'build-phase' : null;
|
|
331
|
+
records.set(identity.podName, { identity, linkedAs });
|
|
309
332
|
}
|
|
310
333
|
}
|
|
311
334
|
return records;
|
|
@@ -318,18 +341,17 @@ function podRecords(identities) {
|
|
|
318
341
|
* instead. Returns that package's directory, or null when expo-modules-jsi is not
|
|
319
342
|
* autolinked.
|
|
320
343
|
*/
|
|
321
|
-
function linkExpoModulesJSI(
|
|
322
|
-
const
|
|
323
|
-
if (
|
|
324
|
-
|
|
325
|
-
const { packageName, moduleRoot, productName } = record.identity;
|
|
344
|
+
function linkExpoModulesJSI(identities, outDir, cacheDir, appRoot) {
|
|
345
|
+
const identity = [...identities.values()].find((i) => i.podName === JSI_POD);
|
|
346
|
+
if (identity == null) return null;
|
|
347
|
+
const { packageName, moduleRoot, productName } = identity;
|
|
326
348
|
const headers = resolveHeadersXCFramework({ packageName, moduleRoot, productName, cacheDir });
|
|
327
349
|
if (headers == null) {
|
|
328
350
|
const searched = headersXCFrameworkDirs(packageName, moduleRoot);
|
|
329
351
|
throw pluginError({
|
|
330
352
|
what: `${productName}Headers.xcframework (or .tar.gz) was not found in ${searched.join(', ')}.`,
|
|
331
353
|
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.
|
|
354
|
+
how: `Reinstall ${packageName} with your package manager. From the Expo repository root, build the headers with \`node tools/bin/expotools.js prebuild ${packageName}\`.`,
|
|
333
355
|
});
|
|
334
356
|
}
|
|
335
357
|
const builtRoot = buildPhaseJsiRoot(appRoot);
|
|
@@ -357,41 +379,209 @@ function buildPhaseJsiRoot(appRoot) {
|
|
|
357
379
|
}
|
|
358
380
|
}
|
|
359
381
|
|
|
382
|
+
/**
|
|
383
|
+
* The entry of the app's `buildFromSource` autolinking option that matches a pod, as
|
|
384
|
+
* `{ entry, exact }`, or undefined. An entry is exact for a pod when it is, character for
|
|
385
|
+
* character, the pod name or the npm package name. Any other entry is a pattern, matched as
|
|
386
|
+
* CocoaPods matches it in `precompiled_modules.rb#build_from_source?`: a regular expression
|
|
387
|
+
* that must match the whole pod name or npm package name. An exact entry wins over a pattern.
|
|
388
|
+
* An exact entry for ExpoModulesCore fails the sync, because every source package compiles
|
|
389
|
+
* against the precompiled one; a pattern matching it leaves it precompiled.
|
|
390
|
+
*/
|
|
391
|
+
function buildFromSourceMatcher(patterns) {
|
|
392
|
+
const entries = patterns.map((pattern) => {
|
|
393
|
+
try {
|
|
394
|
+
return { pattern, expression: new RegExp(`^${pattern}$`) };
|
|
395
|
+
} catch (error) {
|
|
396
|
+
throw pluginError(
|
|
397
|
+
{
|
|
398
|
+
what: `The buildFromSource entry "${pattern}" in your app's Expo autolinking options is not a valid regular expression: ${error.message}.`,
|
|
399
|
+
why: 'Each entry is matched as a regular expression against the pod name and the npm package name of every module, to choose the modules built from source instead of linked precompiled.',
|
|
400
|
+
how: `Fix the entry in ${BUILD_FROM_SOURCE_OPTION}. ${rerunSpmUpdate()}`,
|
|
401
|
+
},
|
|
402
|
+
{ cause: error }
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
const matchFor = ({ podName, packageName }) => {
|
|
407
|
+
const exact = patterns.find((pattern) => pattern === podName || pattern === packageName);
|
|
408
|
+
if (exact != null) return { entry: exact, exact: true };
|
|
409
|
+
const pattern = entries.find(
|
|
410
|
+
({ expression }) => expression.test(podName) || expression.test(packageName)
|
|
411
|
+
)?.pattern;
|
|
412
|
+
return pattern != null ? { entry: pattern, exact: false } : undefined;
|
|
413
|
+
};
|
|
414
|
+
const coreMatch = matchFor({ podName: CORE_POD, packageName: CORE_PACKAGE });
|
|
415
|
+
if (coreMatch?.exact) {
|
|
416
|
+
const coreEntry = coreMatch.entry;
|
|
417
|
+
throw pluginError({
|
|
418
|
+
what: `The buildFromSource entry "${coreEntry}" in your app's Expo autolinking options matches ${CORE_POD} (${CORE_PACKAGE}), which Swift Package Manager cannot build from source.`,
|
|
419
|
+
why: `Under Swift Package Manager, ${CORE_POD} is always linked precompiled: every Expo module built from source compiles against its precompiled interface.`,
|
|
420
|
+
how: `Remove "${coreEntry}" from ${BUILD_FROM_SOURCE_OPTION}, or narrow it so it no longer matches ${CORE_POD} or ${CORE_PACKAGE}. ${rerunSpmUpdate()}`,
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
return matchFor;
|
|
424
|
+
}
|
|
425
|
+
|
|
360
426
|
/**
|
|
361
427
|
* Pass 1 — precompiled runtime frameworks. The declaration is all-or-nothing:
|
|
362
428
|
* once one flavor exists, the resolver requires and prepares both before RN
|
|
363
429
|
* receives the plugin result. No runtime binary enters the SwiftPM graph.
|
|
364
430
|
* A pod name several packages list is looked up from each of them, in order,
|
|
365
|
-
* until one has an artifact.
|
|
431
|
+
* until one has an artifact. A pod the app builds from source — buildFromSource matches
|
|
432
|
+
* the pod or any package that lists it, an exact entry for any of them winning — is never
|
|
433
|
+
* linked precompiled, unless it is one of `fallbackPods`; when it has an artifact, its
|
|
434
|
+
* record keeps the `buildFromSource` match, so a pattern can fall back and an exact entry
|
|
435
|
+
* be reported should no source route take it. A fallback pod whose artifact does not resolve
|
|
436
|
+
* keeps its match too, marked `precompiledIncomplete`. Returns the records it linked, in that
|
|
437
|
+
* order.
|
|
438
|
+
*
|
|
439
|
+
* @param matchBuildFromSource `buildFromSourceMatcher`'s result.
|
|
440
|
+
* @param fallbackPods the matching pattern by pod name, for each pod linked precompiled though
|
|
441
|
+
* a pattern matches it.
|
|
366
442
|
*/
|
|
367
|
-
function linkPrecompiledPods(identities, records, cacheDir) {
|
|
443
|
+
function linkPrecompiledPods(identities, records, cacheDir, matchBuildFromSource, fallbackPods) {
|
|
444
|
+
const matchesByPod = new Map();
|
|
445
|
+
for (const identity of identities.values()) {
|
|
446
|
+
if (fallbackPods.has(identity.podName)) continue;
|
|
447
|
+
const match = matchBuildFromSource(identity);
|
|
448
|
+
const known = matchesByPod.get(identity.podName);
|
|
449
|
+
if (match != null && (known == null || (match.exact && !known.exact))) {
|
|
450
|
+
matchesByPod.set(identity.podName, match);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
368
453
|
const linked = [];
|
|
369
454
|
for (const identity of identities.values()) {
|
|
370
455
|
const record = records.get(identity.podName);
|
|
371
456
|
if (record.linkedAs != null) continue;
|
|
372
|
-
const
|
|
457
|
+
const lookup = {
|
|
373
458
|
packageName: identity.packageName,
|
|
374
459
|
moduleRoot: identity.moduleRoot,
|
|
375
460
|
frameworkName: identity.productName,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
if (
|
|
461
|
+
};
|
|
462
|
+
const match = matchesByPod.get(identity.podName);
|
|
463
|
+
if (match != null) {
|
|
464
|
+
if (record.buildFromSource == null && hasPrecompiledArtifact(lookup)) {
|
|
465
|
+
record.buildFromSource = match;
|
|
466
|
+
}
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
const framework = resolveFlavoredFramework({ ...lookup, cacheDir });
|
|
470
|
+
if (framework == null) {
|
|
471
|
+
if (fallbackPods.has(identity.podName)) {
|
|
472
|
+
const entry = fallbackPods.get(identity.podName);
|
|
473
|
+
record.buildFromSource = { entry, exact: false, precompiledIncomplete: true };
|
|
474
|
+
}
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
379
477
|
Object.assign(record, { identity, linkedAs: 'precompiled', framework });
|
|
380
478
|
linked.push(record);
|
|
381
479
|
}
|
|
382
480
|
return linked;
|
|
383
481
|
}
|
|
384
482
|
|
|
483
|
+
const SOURCE_LABELS = {
|
|
484
|
+
env: 'EXPO_PRECOMPILED_MODULES_PATH',
|
|
485
|
+
monorepo: 'the Expo monorepo prebuild output',
|
|
486
|
+
bundled: 'its npm package',
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
const describeSource = (source) => `${SOURCE_LABELS[source.kind]} (${source.dir})`;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Compares the kind of place, not the directory: every package has its own directory in
|
|
493
|
+
* each of them. Returns the `pluginError` parts describing the mix, or null when there is
|
|
494
|
+
* none.
|
|
495
|
+
*
|
|
496
|
+
* @param subjects `{ label, packageName, source }` for each precompiled artifact to check.
|
|
497
|
+
*/
|
|
498
|
+
function mixedSourcesReport(coreSource, subjects) {
|
|
499
|
+
const mixed = subjects.filter((subject) => subject.source?.kind !== coreSource?.kind);
|
|
500
|
+
if (mixed.length === 0) return null;
|
|
501
|
+
const packages = [...new Set(mixed.map((subject) => subject.packageName))].join(' ');
|
|
502
|
+
return {
|
|
503
|
+
what: `${mixed
|
|
504
|
+
.map(
|
|
505
|
+
(subject) =>
|
|
506
|
+
`${subject.label} (${subject.packageName}) comes from ${describeSource(subject.source)}`
|
|
507
|
+
)
|
|
508
|
+
.join('; ')}, but ExpoModulesCore comes from ${describeSource(coreSource)}.`,
|
|
509
|
+
why: 'Precompiled Expo modules, and the headers Expo modules compile against, are bound to the exact ExpoModulesCore build they were made with, so mixing builds from different places can crash the app at launch on a missing symbol.',
|
|
510
|
+
how: `Take every precompiled module from one place: unset EXPO_PRECOMPILED_MODULES_PATH if it is set; from the Expo repository root, build the packages into the same place as ExpoModulesCore with \`node tools/bin/expotools.js prebuild ${packages}\`; otherwise reinstall your JavaScript dependencies so every package uses the build it ships. ${rerunSpmUpdate()}`,
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
|
|
385
514
|
/**
|
|
386
|
-
*
|
|
387
|
-
*
|
|
515
|
+
* The ExpoModulesCore headers xcframework, for direct modules to compile against. It must
|
|
516
|
+
* come from the same kind of place as the ExpoModulesCore binary.
|
|
517
|
+
*/
|
|
518
|
+
function resolveCoreHeaders(core, coreSource, cacheDir) {
|
|
519
|
+
const { packageName, moduleRoot, productName } = core;
|
|
520
|
+
const lookup = { packageName, moduleRoot, productName };
|
|
521
|
+
const lookupRank = (source) => PRECOMPILED_SOURCE_KINDS.indexOf(source.kind);
|
|
522
|
+
const builtLocally = coreSource?.kind === 'env' || coreSource?.kind === 'monorepo';
|
|
523
|
+
// Headers past the place a local ExpoModulesCore build comes from cannot match it, so the
|
|
524
|
+
// lookup ends there: a broken copy further on would fail first, with advice that cannot
|
|
525
|
+
// fix the missing headers. No headers up to that place mean the build produced none.
|
|
526
|
+
const headers = resolveHeadersXCFrameworkWithSource({
|
|
527
|
+
...lookup,
|
|
528
|
+
cacheDir,
|
|
529
|
+
lastKind: builtLocally ? coreSource.kind : undefined,
|
|
530
|
+
});
|
|
531
|
+
if (builtLocally && (headers == null || lookupRank(headers.source) > lookupRank(coreSource))) {
|
|
532
|
+
const prebuild = '`node tools/bin/expotools.js prebuild expo-modules-core expo-modules-jsi`';
|
|
533
|
+
throw pluginError({
|
|
534
|
+
what: `${productName}Headers.xcframework is missing under ${coreSource.dir}, where ${productName} comes from (${SOURCE_LABELS[coreSource.kind]}).`,
|
|
535
|
+
why: `Expo modules built from their own Package.swift compile against these headers, and the headers must come from the same build as ${productName}. That build did not produce them.`,
|
|
536
|
+
how:
|
|
537
|
+
coreSource.kind === 'env'
|
|
538
|
+
? `Unset EXPO_PRECOMPILED_MODULES_PATH, or point it at a directory that holds a complete prebuild of expo-modules-core and expo-modules-jsi, including their headers. ${rerunSpmUpdate()}`
|
|
539
|
+
: `From the Expo repository root, run ${prebuild}. ${rerunSpmUpdate()}`,
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
if (headers == null) {
|
|
543
|
+
throw pluginError({
|
|
544
|
+
what: `Expo modules built from their own Package.swift compile against ${productName}Headers.xcframework, which was not found (searched ${headersXCFrameworkSearchPaths(lookup).join(', ')}).`,
|
|
545
|
+
why: `The installed ${packageName} was published without a headers xcframework, or the local prebuild has not produced it yet.`,
|
|
546
|
+
how: `From the Expo repository root, run \`node tools/bin/expotools.js prebuild ${packageName}\`. Otherwise upgrade ${packageName} to a version that ships a headers xcframework. ${rerunSpmUpdate()}`,
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
const mixed = mixedSourcesReport(coreSource, [
|
|
550
|
+
{ label: `${productName}Headers.xcframework`, packageName, source: headers.source },
|
|
551
|
+
]);
|
|
552
|
+
if (mixed != null) throw pluginError(mixed);
|
|
553
|
+
return headers.xcframework;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Emits the source package of the module whose first pod is `identity`: its checked-in
|
|
558
|
+
* manifest as it stands when that depends on ExpoModulesCoreHeaders (`direct` is then
|
|
559
|
+
* set), else that manifest mirrored, or else one Swift target over its sources. A
|
|
388
560
|
* pure-Swift module is refused when its podspec declares linkage, because the
|
|
389
561
|
* emitted package would link less than the podspec does. Returns null for a module
|
|
390
562
|
* with no sources: the pod's own `no-apple-sources` report covers it.
|
|
563
|
+
*
|
|
564
|
+
* @param dumpManifest `dumpModuleManifest`, run at most once per real module root.
|
|
391
565
|
*/
|
|
392
|
-
function emitSourceModule(identity, hasManifest, emitContext) {
|
|
393
|
-
const { moduleRoot, podName, iosDeploymentTarget, spmPackages, sources, podspec } =
|
|
394
|
-
|
|
566
|
+
function emitSourceModule(identity, hasManifest, emitContext, dumpManifest) {
|
|
567
|
+
const { moduleRoot, packageName, podName, iosDeploymentTarget, spmPackages, sources, podspec } =
|
|
568
|
+
identity;
|
|
569
|
+
if (hasManifest) {
|
|
570
|
+
const { json, manifest } = dumpManifest(moduleRoot, packageName);
|
|
571
|
+
if (!dependsOnCoreHeaders(manifest)) {
|
|
572
|
+
return emitSourceManifestPackage(moduleRoot, emitContext, json);
|
|
573
|
+
}
|
|
574
|
+
const emission = emitDirectPackage({
|
|
575
|
+
moduleRoot,
|
|
576
|
+
packageName,
|
|
577
|
+
outDir: emitContext.outDir,
|
|
578
|
+
coreHeadersXCFramework: emitContext.coreHeadersXCFramework,
|
|
579
|
+
jsiHeadersPkgPath: emitContext.jsiHeadersPkgPath,
|
|
580
|
+
macroTool: emitContext.macroTool,
|
|
581
|
+
manifest,
|
|
582
|
+
});
|
|
583
|
+
return { ...emission, direct: true };
|
|
584
|
+
}
|
|
395
585
|
if (podspec.linkage != null) {
|
|
396
586
|
return { refusal: { reason: 'needs-manifest-for-linkage', ...podspec.linkage } };
|
|
397
587
|
}
|
|
@@ -407,12 +597,14 @@ function emitSourceModule(identity, hasManifest, emitContext) {
|
|
|
407
597
|
* headers/module-interface tree and leave runtime linking entirely to RN.
|
|
408
598
|
*
|
|
409
599
|
* @param emitContext what every emitted package is generated against.
|
|
410
|
-
* @
|
|
411
|
-
*
|
|
600
|
+
* @param dumpManifest `manifestDumper`'s result.
|
|
601
|
+
* @returns `emitted`, one `{ identity, linkedAs, direct, emission }` per package it emitted,
|
|
602
|
+
* in emission order, `identity` being the pod it was emitted for and `direct` whether a
|
|
603
|
+
* checked-in manifest is built as it stands; and `refusals`, by
|
|
412
604
|
* module root and then reason, each a function from an uncovered pod's identity to
|
|
413
605
|
* its refusal.
|
|
414
606
|
*/
|
|
415
|
-
function linkSourceModules(modules, identities, records, emitContext) {
|
|
607
|
+
function linkSourceModules(modules, identities, records, emitContext, dumpManifest) {
|
|
416
608
|
const emitted = [];
|
|
417
609
|
const refusals = new Map();
|
|
418
610
|
// What the branches below read comes from the first pod's module root, so a
|
|
@@ -459,15 +651,15 @@ function linkSourceModules(modules, identities, records, emitContext) {
|
|
|
459
651
|
// emitSourceModule for the podspec linkage check that outranks it.
|
|
460
652
|
if (!hasManifest && !sources.pureSwift) continue;
|
|
461
653
|
|
|
462
|
-
const emission = emitSourceModule(first, hasManifest, emitContext);
|
|
654
|
+
const emission = emitSourceModule(first, hasManifest, emitContext, dumpManifest);
|
|
463
655
|
if (emission == null) continue;
|
|
464
|
-
const { refusal, ok } = emission;
|
|
656
|
+
const { refusal, ok, direct = false } = emission;
|
|
465
657
|
if (refusal != null) {
|
|
466
658
|
refuse(moduleRoot, refusal.reason, () => refusal);
|
|
467
659
|
continue;
|
|
468
660
|
}
|
|
469
661
|
const kind = hasManifest ? 'manifest' : 'pure-swift';
|
|
470
|
-
emitted.push({ identity: first, linkedAs: kind, emission: ok });
|
|
662
|
+
emitted.push({ identity: first, linkedAs: kind, direct, emission: ok });
|
|
471
663
|
if (!hasManifest) {
|
|
472
664
|
Object.assign(records.get(first.podName), { identity: first, linkedAs: kind });
|
|
473
665
|
continue;
|
|
@@ -491,6 +683,124 @@ function linkSourceModules(modules, identities, records, emitContext) {
|
|
|
491
683
|
return { emitted, refusals };
|
|
492
684
|
}
|
|
493
685
|
|
|
686
|
+
/** `dumpModuleManifest`, run at most once per real module root. */
|
|
687
|
+
function manifestDumper() {
|
|
688
|
+
// By real path: listings can reach one manifest through different symlinks.
|
|
689
|
+
const dumpsByRealRoot = new Map();
|
|
690
|
+
return (moduleRoot, packageName) => {
|
|
691
|
+
const realRoot = fs.realpathSync(moduleRoot);
|
|
692
|
+
if (!dumpsByRealRoot.has(realRoot)) {
|
|
693
|
+
dumpsByRealRoot.set(realRoot, dumpModuleManifest(moduleRoot, packageName));
|
|
694
|
+
}
|
|
695
|
+
return dumpsByRealRoot.get(realRoot);
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Both passes, over fresh pod records, with the pods in `fallbackPods` linked precompiled
|
|
701
|
+
* though a buildFromSource pattern matches them.
|
|
702
|
+
*
|
|
703
|
+
* @param sourceContext `{ react, outDir, codegenPkgPath, jsiHeadersPkgPath }`: what every
|
|
704
|
+
* emitted package is generated against, besides what pass 1 decides.
|
|
705
|
+
*/
|
|
706
|
+
function linkPasses(
|
|
707
|
+
fallbackPods,
|
|
708
|
+
{ modules, identities, cacheDir, matchBuildFromSource, dumpManifest, sourceContext }
|
|
709
|
+
) {
|
|
710
|
+
const records = podRecords(identities);
|
|
711
|
+
const precompiled = linkPrecompiledPods(
|
|
712
|
+
identities,
|
|
713
|
+
records,
|
|
714
|
+
cacheDir,
|
|
715
|
+
matchBuildFromSource,
|
|
716
|
+
fallbackPods
|
|
717
|
+
);
|
|
718
|
+
// The SwiftPM packages those modules link ship as their own XCFrameworks, and
|
|
719
|
+
// RN takes them in the same flat array. They join before the interface tree is
|
|
720
|
+
// built, so source modules compile against their headers too.
|
|
721
|
+
const dependencyFrameworks = resolveSpmDependencyFrameworks(
|
|
722
|
+
precompiled.map(({ identity: { podName, moduleRoot, spmPackages } }) => ({
|
|
723
|
+
podName,
|
|
724
|
+
moduleRoot,
|
|
725
|
+
spmDependencies: spmPackages.map((pkg) => pkg.productName),
|
|
726
|
+
}))
|
|
727
|
+
);
|
|
728
|
+
const flavoredFrameworks = [...precompiled.map((r) => r.framework), ...dependencyFrameworks].sort(
|
|
729
|
+
(a, b) => byteOrder(a.id, b.id)
|
|
730
|
+
);
|
|
731
|
+
assertDistinctFlavoredFrameworks(flavoredFrameworks);
|
|
732
|
+
const coreRecord = precompiled.find((r) => r.identity.podName === CORE_POD) ?? null;
|
|
733
|
+
const coreSource = coreRecord && frameworkSource(coreRecord.framework);
|
|
734
|
+
const satisfiedDependencies = new Set(dependencyFrameworks.map((f) => f.frameworkName));
|
|
735
|
+
const frameworkSearchPath =
|
|
736
|
+
precompiled.length > 0
|
|
737
|
+
? prepareCompileInterfaces(
|
|
738
|
+
flavoredFrameworks,
|
|
739
|
+
path.join(sourceContext.outDir, 'compile-interfaces')
|
|
740
|
+
)
|
|
741
|
+
: null;
|
|
742
|
+
|
|
743
|
+
const core = coreRecord?.identity ?? null;
|
|
744
|
+
const coreAvailable = core != null && frameworkSearchPath != null;
|
|
745
|
+
let sourceModules = { emitted: [], refusals: new Map() };
|
|
746
|
+
if (coreAvailable) {
|
|
747
|
+
let resolvedMacroFlags = null;
|
|
748
|
+
let resolvedCoreHeadersXCFramework = null;
|
|
749
|
+
sourceModules = linkSourceModules(
|
|
750
|
+
modules,
|
|
751
|
+
identities,
|
|
752
|
+
records,
|
|
753
|
+
{
|
|
754
|
+
...sourceContext,
|
|
755
|
+
frameworkSearchPath,
|
|
756
|
+
minimumIosDeploymentTarget: core.iosDeploymentTarget,
|
|
757
|
+
satisfiedDependencies,
|
|
758
|
+
// Every emitted target may use the macros (CocoaPods' "is core or depends on core" gate).
|
|
759
|
+
// Lazy: an install that emits no source package needs no macro plugin.
|
|
760
|
+
get macroFlags() {
|
|
761
|
+
return (resolvedMacroFlags ??= macroPluginFlags(core.moduleRoot));
|
|
762
|
+
},
|
|
763
|
+
get macroTool() {
|
|
764
|
+
return macroPluginTool(core.moduleRoot);
|
|
765
|
+
},
|
|
766
|
+
// Lazy: only a direct module needs the headers, and only then must they exist.
|
|
767
|
+
get coreHeadersXCFramework() {
|
|
768
|
+
return (resolvedCoreHeadersXCFramework ??= resolveCoreHeaders(
|
|
769
|
+
core,
|
|
770
|
+
coreSource,
|
|
771
|
+
cacheDir
|
|
772
|
+
));
|
|
773
|
+
},
|
|
774
|
+
},
|
|
775
|
+
dumpManifest
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
return {
|
|
779
|
+
records,
|
|
780
|
+
precompiled,
|
|
781
|
+
flavoredFrameworks,
|
|
782
|
+
coreRecord,
|
|
783
|
+
coreSource,
|
|
784
|
+
satisfiedDependencies,
|
|
785
|
+
coreAvailable,
|
|
786
|
+
sourceModules,
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Removes the packages an earlier round of `linkPasses` emitted that the last round did not,
|
|
792
|
+
* so no package the sync dropped is left beside the ones it links.
|
|
793
|
+
*
|
|
794
|
+
* @param emittedByRound `sourceModules.emitted` of each round, the last round last.
|
|
795
|
+
*/
|
|
796
|
+
function removeDiscardedEmissions(emittedByRound) {
|
|
797
|
+
const packagePath = ({ emission }) => emission.packageDep.path;
|
|
798
|
+
const kept = new Set(emittedByRound.at(-1).map(packagePath));
|
|
799
|
+
for (const discarded of new Set(emittedByRound.slice(0, -1).flat().map(packagePath))) {
|
|
800
|
+
if (!kept.has(discarded)) fs.rmSync(discarded, { recursive: true, force: true });
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|
|
494
804
|
/**
|
|
495
805
|
* The emitted products React Native links, and a label for each one an unmet
|
|
496
806
|
* `autolinkWhen` condition withholds. Only a checked-in manifest's products are
|
|
@@ -548,7 +858,11 @@ function summarizeRecords(
|
|
|
548
858
|
);
|
|
549
859
|
const pending = [...records.values()]
|
|
550
860
|
.filter((r) => r.linkedAs == null)
|
|
551
|
-
.map(({ identity }) =>
|
|
861
|
+
.map(({ identity, buildFromSource }) => ({
|
|
862
|
+
...uncoveredPod(identity, ...refusalsFor(identity)),
|
|
863
|
+
buildFromSourceEntry: buildFromSource?.entry,
|
|
864
|
+
precompiledIncomplete: buildFromSource?.precompiledIncomplete,
|
|
865
|
+
}));
|
|
552
866
|
|
|
553
867
|
// What the resolved dependencies already carry is not uncovered, their subspecs
|
|
554
868
|
// included.
|
|
@@ -588,6 +902,8 @@ function summarizeRecords(
|
|
|
588
902
|
...(react != null ? emitted : []),
|
|
589
903
|
];
|
|
590
904
|
const podNames = (list) => list.map((r) => r.identity.podName);
|
|
905
|
+
const packageNames = (list) => list.map((r) => r.identity.packageName);
|
|
906
|
+
const fromManifests = emitted.filter((r) => r.linkedAs === 'manifest');
|
|
591
907
|
|
|
592
908
|
return {
|
|
593
909
|
packageDependencies: emitted.map((r) => r.emission.packageDep),
|
|
@@ -602,9 +918,8 @@ function summarizeRecords(
|
|
|
602
918
|
),
|
|
603
919
|
xcconfigLinkage,
|
|
604
920
|
precompiledPods: podNames(precompiled),
|
|
605
|
-
manifestPackages:
|
|
606
|
-
|
|
607
|
-
.map((r) => r.identity.packageName),
|
|
921
|
+
manifestPackages: packageNames(fromManifests),
|
|
922
|
+
directPackages: packageNames(fromManifests.filter((r) => r.direct)),
|
|
608
923
|
pureSwiftPods: podNames(pureSwift),
|
|
609
924
|
reactWiredPods: podNames(reactWired),
|
|
610
925
|
};
|
|
@@ -631,7 +946,7 @@ function watchPaths(identities, { entitlementPath, podfilePropertiesPath }) {
|
|
|
631
946
|
// Swift macros need the prebuilt plugin executable; mirrors
|
|
632
947
|
// project_integrator.rb#resolve_macros_plugin_dir.
|
|
633
948
|
// It declares no SwiftPM products, so it travels as a compiler flag, not a dependency.
|
|
634
|
-
function
|
|
949
|
+
function macroPluginTool(coreModuleRoot) {
|
|
635
950
|
const macroPluginFault = (
|
|
636
951
|
what,
|
|
637
952
|
missing,
|
|
@@ -662,6 +977,11 @@ function macroPluginFlags(coreModuleRoot) {
|
|
|
662
977
|
macroPluginFault(`The Expo Swift macro plugin is missing its executable at ${tool}.`, 'it')
|
|
663
978
|
);
|
|
664
979
|
}
|
|
980
|
+
return tool;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
function macroPluginFlags(coreModuleRoot) {
|
|
984
|
+
const tool = macroPluginTool(coreModuleRoot);
|
|
665
985
|
return ['-Xfrontend', '-load-plugin-executable', '-Xfrontend', `${tool}#ExpoModulesMacros`];
|
|
666
986
|
}
|
|
667
987
|
|
|
@@ -685,7 +1005,8 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
685
1005
|
// us that root directly.
|
|
686
1006
|
const appRoot = context.projectRoot;
|
|
687
1007
|
configureSpmUpdateCommand({ appRoot, reactNativeRoot: appReactNativeRoot(context, appRoot) });
|
|
688
|
-
const { modules, extraDependencies } = resolveExpoModules(appRoot);
|
|
1008
|
+
const { modules, extraDependencies, buildFromSource = [] } = resolveExpoModules(appRoot);
|
|
1009
|
+
const matchBuildFromSource = buildFromSourceMatcher(buildFromSource);
|
|
689
1010
|
const metadata = readPrebuiltMetadata(appRoot);
|
|
690
1011
|
const autolinkedRoots = collectAutolinkedRoots(autolinking);
|
|
691
1012
|
const identities = resolvePodIdentities(modules, metadata, autolinkedRoots);
|
|
@@ -722,48 +1043,65 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
722
1043
|
? codegenCandidate
|
|
723
1044
|
: null;
|
|
724
1045
|
|
|
725
|
-
const
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
);
|
|
741
|
-
|
|
742
|
-
const
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
1046
|
+
const jsiHeadersPkgPath = linkExpoModulesJSI(identities, outDir, artifactCacheDir, appRoot);
|
|
1047
|
+
const passOptions = {
|
|
1048
|
+
modules,
|
|
1049
|
+
identities,
|
|
1050
|
+
cacheDir: artifactCacheDir,
|
|
1051
|
+
matchBuildFromSource,
|
|
1052
|
+
dumpManifest: manifestDumper(),
|
|
1053
|
+
sourceContext: { react, outDir, codegenPkgPath, jsiHeadersPkgPath },
|
|
1054
|
+
};
|
|
1055
|
+
// A pod a buildFromSource pattern matches is linked precompiled when no source route takes
|
|
1056
|
+
// it, as ExpoModulesCore never is. Linking one changes what pass 2 decides — a sibling pod's
|
|
1057
|
+
// route, the products already satisfied, the interface tree — so both passes run again until
|
|
1058
|
+
// no other pod falls back. Transitional: needed until every Expo module, ExpoModulesCore
|
|
1059
|
+
// included, has a checked-in Package.swift that SwiftPM can build from source.
|
|
1060
|
+
const fallbackEntries = new Map();
|
|
1061
|
+
const coreMatch = matchBuildFromSource({ podName: CORE_POD, packageName: CORE_PACKAGE });
|
|
1062
|
+
if (coreMatch != null) fallbackEntries.set(CORE_POD, coreMatch.entry);
|
|
1063
|
+
const emittedByRound = [];
|
|
1064
|
+
let passes;
|
|
1065
|
+
let fallingBack;
|
|
1066
|
+
do {
|
|
1067
|
+
passes = linkPasses(fallbackEntries, passOptions);
|
|
1068
|
+
emittedByRound.push(passes.sourceModules.emitted);
|
|
1069
|
+
fallingBack = [...passes.records.values()].filter(
|
|
1070
|
+
(r) =>
|
|
1071
|
+
r.linkedAs == null &&
|
|
1072
|
+
r.buildFromSource?.exact === false &&
|
|
1073
|
+
!fallbackEntries.has(r.identity.podName)
|
|
1074
|
+
);
|
|
1075
|
+
for (const { identity, buildFromSource } of fallingBack) {
|
|
1076
|
+
fallbackEntries.set(identity.podName, buildFromSource.entry);
|
|
1077
|
+
}
|
|
1078
|
+
} while (fallingBack.length > 0);
|
|
1079
|
+
removeDiscardedEmissions(emittedByRound);
|
|
1080
|
+
const {
|
|
1081
|
+
records,
|
|
1082
|
+
precompiled,
|
|
1083
|
+
flavoredFrameworks,
|
|
1084
|
+
coreRecord,
|
|
1085
|
+
coreSource,
|
|
1086
|
+
satisfiedDependencies,
|
|
1087
|
+
coreAvailable,
|
|
1088
|
+
sourceModules,
|
|
1089
|
+
} = passes;
|
|
1090
|
+
const mixedModules =
|
|
1091
|
+
coreRecord &&
|
|
1092
|
+
mixedSourcesReport(
|
|
1093
|
+
coreSource,
|
|
1094
|
+
precompiled
|
|
1095
|
+
.filter((r) => r !== coreRecord)
|
|
1096
|
+
.map(({ identity, framework }) => ({
|
|
1097
|
+
label: identity.productName,
|
|
1098
|
+
packageName: identity.packageName,
|
|
1099
|
+
source: frameworkSource(framework),
|
|
1100
|
+
}))
|
|
1101
|
+
);
|
|
1102
|
+
if (mixedModules != null) {
|
|
1103
|
+
const { what, why, how } = mixedModules;
|
|
1104
|
+
console.warn(`[expo-spm-plugin] WARNING: ${what} ${why} ${how}`);
|
|
767
1105
|
}
|
|
768
1106
|
|
|
769
1107
|
// Anything still uncovered has no xcframework and no way to be built from
|
|
@@ -783,6 +1121,7 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
783
1121
|
logListed('built by an app build phase', jsiHeadersPkgPath != null ? [JSI_POD] : []);
|
|
784
1122
|
logListed('paired runtime frameworks', summary.precompiledPods);
|
|
785
1123
|
logListed('source via checked-in manifest', summary.manifestPackages);
|
|
1124
|
+
logListed('source via direct checked-in manifest', summary.directPackages);
|
|
786
1125
|
logListed('source pure-Swift', summary.pureSwiftPods);
|
|
787
1126
|
logListed('React wired into', summary.reactWiredPods);
|
|
788
1127
|
logListed('gated off', summary.gatedOffProducts);
|
|
@@ -790,6 +1129,16 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
790
1129
|
'not supported',
|
|
791
1130
|
summary.pending.map((p) => p.podName)
|
|
792
1131
|
);
|
|
1132
|
+
const fellBack = precompiled
|
|
1133
|
+
.filter((r) => fallbackEntries.has(r.identity.podName))
|
|
1134
|
+
.map(({ identity: { podName, packageName } }) => ({
|
|
1135
|
+
podName,
|
|
1136
|
+
packageName,
|
|
1137
|
+
entry: fallbackEntries.get(podName),
|
|
1138
|
+
}));
|
|
1139
|
+
if (fellBack.length > 0) {
|
|
1140
|
+
console.warn(renderBuildFromSourceFallbackWarning(fellBack));
|
|
1141
|
+
}
|
|
793
1142
|
if (summary.unmappedDeps.length > 0) {
|
|
794
1143
|
console.warn(renderUnmappedDependencyWarning(summary.unmappedDeps));
|
|
795
1144
|
}
|
|
@@ -882,12 +1231,13 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
882
1231
|
);
|
|
883
1232
|
}
|
|
884
1233
|
|
|
1234
|
+
const directWatchPaths = prepareDirectWatchPaths(summary.directPackages, outDir);
|
|
885
1235
|
return {
|
|
886
1236
|
packageDependencies: summary.packageDependencies,
|
|
887
1237
|
productDependencies: summary.productDependencies,
|
|
888
1238
|
generatedSources,
|
|
889
1239
|
flavoredFrameworks,
|
|
890
|
-
watchPaths: watchPaths(identities, appTarget),
|
|
1240
|
+
watchPaths: [...watchPaths(identities, appTarget), ...directWatchPaths],
|
|
891
1241
|
scriptPhases,
|
|
892
1242
|
};
|
|
893
1243
|
};
|