expo 58.0.0 → 58.0.1
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/proguard-rules.pro +4 -0
- package/android/src/main/java/expo/modules/fetch/NativeResponse.kt +5 -1
- package/android/src/main/java/expo/modules/fetch/OkHttpFileUrlInterceptor.kt +5 -1
- package/build/winter/runtime.native.js +0 -2
- package/build/winter/runtime.native.js.map +1 -1
- package/bundledNativeModules.json +21 -21
- package/package.json +7 -7
- package/scripts/spm/README.md +0 -3
- package/scripts/spm/__tests__/cli.test.js +57 -1
- package/scripts/spm/__tests__/diagnostics.test.js +181 -131
- package/scripts/spm/__tests__/flavored-frameworks.test.js +9 -0
- package/scripts/spm/__tests__/helpers.js +88 -0
- package/scripts/spm/__tests__/manifests.test.js +289 -74
- package/scripts/spm/__tests__/plugin.test.js +1101 -111
- package/scripts/spm/__tests__/podspec.test.js +27 -138
- package/scripts/spm/__tests__/spm-dependencies.test.js +344 -0
- package/scripts/spm/classify.js +28 -6
- package/scripts/spm/cli.js +23 -9
- package/scripts/spm/diagnostics.js +111 -91
- package/scripts/spm/flavored-frameworks.js +233 -21
- package/scripts/spm/manifests.js +85 -34
- package/scripts/spm/plugin.js +214 -55
- package/scripts/spm/podspec.js +10 -160
- package/src/winter/runtime.native.ts +0 -2
- package/template.tgz +0 -0
- package/build/winter/AbortSignal.d.ts +0 -3
- package/build/winter/AbortSignal.js +0 -96
- package/build/winter/AbortSignal.js.map +0 -1
- package/src/winter/AbortSignal.ts +0 -132
- package/src/winter/__tests__/AbortSignal.test.native.ts +0 -163
package/scripts/spm/manifests.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
|
-
const { collectIgnoredDirs } = require('./classify');
|
|
12
|
+
const { appleSourceDir, collectIgnoredDirs } = require('./classify');
|
|
13
13
|
const { reactProductDependencies, reactPackageDeclarations } = require('./react-descriptor');
|
|
14
14
|
const { runDumpPackage } = require('./cli');
|
|
15
15
|
|
|
@@ -304,7 +304,13 @@ function renderFileRules(target) {
|
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
/** Source-with-manifest: mirror the parsed targets/products, inject the given deps. */
|
|
307
|
-
function renderSourceManifest(
|
|
307
|
+
function renderSourceManifest({
|
|
308
|
+
manifest,
|
|
309
|
+
pkgDeps = [],
|
|
310
|
+
injectedTargetDeps = [],
|
|
311
|
+
frameworkSearchPath,
|
|
312
|
+
extraSwiftFlags = [],
|
|
313
|
+
}) {
|
|
308
314
|
const targetsSwift = manifest.targets
|
|
309
315
|
.map((t) => {
|
|
310
316
|
if (t.path == null) {
|
|
@@ -314,7 +320,7 @@ function renderSourceManifest(manifest, pkgDeps, injected, frameworkSearchPath)
|
|
|
314
320
|
'would point at nothing. Resolve target paths with resolveTargetPaths before rendering.'
|
|
315
321
|
);
|
|
316
322
|
}
|
|
317
|
-
const deps = [...t.siblingDeps.map(renderSiblingDependency), ...
|
|
323
|
+
const deps = [...t.siblingDeps.map(renderSiblingDependency), ...injectedTargetDeps];
|
|
318
324
|
const depsSwift = deps.length
|
|
319
325
|
? `\n${deps.map((dep) => ` ${dep},`).join('\n')}\n `
|
|
320
326
|
: '';
|
|
@@ -324,7 +330,7 @@ function renderSourceManifest(manifest, pkgDeps, injected, frameworkSearchPath)
|
|
|
324
330
|
return ` .target(
|
|
325
331
|
name: "${t.name}",
|
|
326
332
|
dependencies: [${depsSwift}],
|
|
327
|
-
path: "root/${t.path}",${renderFileRules(t)}${headers}${renderTargetSettings(frameworkSearchPath, t.settings, t.name)}
|
|
333
|
+
path: "root/${t.path}",${renderFileRules(t)}${headers}${renderTargetSettings(frameworkSearchPath, t.settings, t.name, extraSwiftFlags)}
|
|
328
334
|
)`;
|
|
329
335
|
})
|
|
330
336
|
.join(',\n');
|
|
@@ -347,7 +353,7 @@ import PackageDescription
|
|
|
347
353
|
|
|
348
354
|
let package = Package(
|
|
349
355
|
name: "${manifest.name}",
|
|
350
|
-
platforms: ${renderPlatforms(manifest.iosDeploymentTarget
|
|
356
|
+
platforms: ${renderPlatforms(manifest.iosDeploymentTarget)},
|
|
351
357
|
products: [
|
|
352
358
|
${productsSwift}
|
|
353
359
|
],
|
|
@@ -368,16 +374,17 @@ const PRIVACY_MANIFEST = 'PrivacyInfo.xcprivacy';
|
|
|
368
374
|
* Pure-Swift source: single Swift target over the module's `ios`/`apple` sources, on
|
|
369
375
|
* the deployment floor the plugin read from the module's podspec.
|
|
370
376
|
*/
|
|
371
|
-
function renderPureSwiftManifest(
|
|
377
|
+
function renderPureSwiftManifest({
|
|
372
378
|
product,
|
|
373
379
|
srcRel,
|
|
374
|
-
pkgDeps,
|
|
375
|
-
targetDeps,
|
|
380
|
+
pkgDeps = [],
|
|
381
|
+
targetDeps = [],
|
|
376
382
|
frameworkSearchPath,
|
|
377
383
|
excludes = [],
|
|
378
384
|
iosDeploymentTarget = null,
|
|
379
|
-
hasPrivacyManifest = false
|
|
380
|
-
|
|
385
|
+
hasPrivacyManifest = false,
|
|
386
|
+
extraSwiftFlags = [],
|
|
387
|
+
}) {
|
|
381
388
|
const packageDepsSwift = pkgDeps.length
|
|
382
389
|
? `\n${pkgDeps.map((dep) => ` ${dep},`).join('\n')}\n `
|
|
383
390
|
: '';
|
|
@@ -409,7 +416,7 @@ let package = Package(
|
|
|
409
416
|
.target(
|
|
410
417
|
name: "${product}",
|
|
411
418
|
dependencies: [${targetDepsSwift}],
|
|
412
|
-
path: "root/${srcRel}",${excludeSwift}${resourcesSwift}${renderTargetSettings(frameworkSearchPath, [], product)}
|
|
419
|
+
path: "root/${srcRel}",${excludeSwift}${resourcesSwift}${renderTargetSettings(frameworkSearchPath, [], product, extraSwiftFlags)}
|
|
413
420
|
),
|
|
414
421
|
],
|
|
415
422
|
swiftLanguageModes: [.v5],
|
|
@@ -426,8 +433,12 @@ function escapeSwiftString(value) {
|
|
|
426
433
|
* A target's `*Settings:` arguments: Expo's binary-free interface tree first, then
|
|
427
434
|
* whatever the module itself declared, in its own order.
|
|
428
435
|
*/
|
|
429
|
-
function renderTargetSettings(frameworkSearchPath, settings, targetName) {
|
|
430
|
-
const
|
|
436
|
+
function renderTargetSettings(frameworkSearchPath, settings, targetName, extraSwiftFlags = []) {
|
|
437
|
+
const unsafeFlags = (flags) =>
|
|
438
|
+
`.unsafeFlags([${flags.map((f) => `"${escapeSwiftString(f)}"`).join(', ')}])`;
|
|
439
|
+
const interfaceFlags = unsafeFlags(['-F', frameworkSearchPath]);
|
|
440
|
+
// `-Xfrontend` is a Swift driver flag; clang rejects it, so it stays out of c/cxxSettings.
|
|
441
|
+
const swiftInterfaceFlags = unsafeFlags(['-F', frameworkSearchPath, ...extraSwiftFlags]);
|
|
431
442
|
for (const setting of settings ?? []) {
|
|
432
443
|
if (!SETTING_TOOLS.has(setting.tool)) {
|
|
433
444
|
throw new Error(
|
|
@@ -442,7 +453,8 @@ function renderTargetSettings(frameworkSearchPath, settings, targetName) {
|
|
|
442
453
|
const own = (settings ?? [])
|
|
443
454
|
.filter((s) => s.tool === tool)
|
|
444
455
|
.map((s) => renderSetting(s, targetName));
|
|
445
|
-
const
|
|
456
|
+
const injected = tool === 'swift' ? swiftInterfaceFlags : interfaceFlags;
|
|
457
|
+
const values = tool === 'linker' ? own : [injected, ...own];
|
|
446
458
|
return values.length ? `\n ${label}: [${values.join(', ')}],` : '';
|
|
447
459
|
}).join('');
|
|
448
460
|
}
|
|
@@ -452,6 +464,26 @@ function renderPlatforms(iosDeploymentTarget) {
|
|
|
452
464
|
return iosDeploymentTarget != null ? `[.iOS("${iosDeploymentTarget}")]` : '[.iOS(.v15)]';
|
|
453
465
|
}
|
|
454
466
|
|
|
467
|
+
/**
|
|
468
|
+
* The higher of two iOS floors, or null when neither side declares one.
|
|
469
|
+
*
|
|
470
|
+
* CocoaPods raises every Expo pod to ExpoModulesCore's deployment target after
|
|
471
|
+
* install (`reconcile_expo_module_deployment_targets`). Under SwiftPM the
|
|
472
|
+
* generated manifest is the only place to do that, because importing a module
|
|
473
|
+
* built for a higher floor than the importer is a compile error.
|
|
474
|
+
*/
|
|
475
|
+
function raiseFloor(declared, minimum) {
|
|
476
|
+
if (declared == null) return minimum ?? null;
|
|
477
|
+
if (minimum == null) return declared;
|
|
478
|
+
const components = (version) => version.split('.').map(Number);
|
|
479
|
+
const [left, right] = [components(declared), components(minimum)];
|
|
480
|
+
for (let i = 0; i < Math.max(left.length, right.length); i++) {
|
|
481
|
+
const delta = (left[i] ?? 0) - (right[i] ?? 0);
|
|
482
|
+
if (delta !== 0) return delta > 0 ? declared : minimum;
|
|
483
|
+
}
|
|
484
|
+
return declared;
|
|
485
|
+
}
|
|
486
|
+
|
|
455
487
|
// ---------------------------------------------------------------------------
|
|
456
488
|
// I/O: emit a package dir (write manifest + `root` symlink) and return deps
|
|
457
489
|
// ---------------------------------------------------------------------------
|
|
@@ -523,15 +555,15 @@ function linkRoot(pkgDir, moduleRoot) {
|
|
|
523
555
|
* ExpoModulesCore loads its Clang module map, which declares `use React`.
|
|
524
556
|
*/
|
|
525
557
|
function sourceDependencies(react, codegenPkgPath) {
|
|
526
|
-
|
|
558
|
+
if (react == null) return { targetDeps: [], pkgDeps: [] };
|
|
527
559
|
return {
|
|
528
|
-
targetDeps:
|
|
529
|
-
pkgDeps:
|
|
560
|
+
targetDeps: reactProductDependencies(react),
|
|
561
|
+
pkgDeps: reactPackageDeclarations(react, codegenPkgPath),
|
|
530
562
|
};
|
|
531
563
|
}
|
|
532
564
|
|
|
533
565
|
/**
|
|
534
|
-
*
|
|
566
|
+
* Emit a CONSUMPTION Package.swift for a source module that ships a
|
|
535
567
|
* checked-in Package.swift. Re-declares its library targets against the real source
|
|
536
568
|
* (via a `root` symlink), injects RN's invariant React product set, and points
|
|
537
569
|
* compilation at Expo's binary-free framework interface tree. RN owns the merge;
|
|
@@ -542,12 +574,24 @@ function sourceDependencies(react, codegenPkgPath) {
|
|
|
542
574
|
* sources cannot be located — the module is then skipped and diagnosed rather than
|
|
543
575
|
* emitted broken.
|
|
544
576
|
*/
|
|
545
|
-
function emitSourceManifestPackage(
|
|
577
|
+
function emitSourceManifestPackage({
|
|
578
|
+
moduleRoot,
|
|
579
|
+
react = null,
|
|
580
|
+
frameworkSearchPath,
|
|
581
|
+
outDir,
|
|
582
|
+
codegenPkgPath = null,
|
|
583
|
+
minimumIosDeploymentTarget = null,
|
|
584
|
+
macroFlags = [],
|
|
585
|
+
}) {
|
|
546
586
|
const { unsupportedTargetDeps, ...dumped } = parseDumpedManifest(runDumpPackage(moduleRoot));
|
|
547
587
|
if (unsupportedTargetDeps.length) return { unsupportedTargetDeps };
|
|
548
588
|
const { targets, unresolvedTargets } = resolveTargetPaths(dumped.targets, moduleRoot);
|
|
549
589
|
if (unresolvedTargets.length) return { unresolvedTargets };
|
|
550
|
-
const manifest = {
|
|
590
|
+
const manifest = {
|
|
591
|
+
...dumped,
|
|
592
|
+
targets,
|
|
593
|
+
iosDeploymentTarget: raiseFloor(dumped.iosDeploymentTarget, minimumIosDeploymentTarget),
|
|
594
|
+
};
|
|
551
595
|
const pkgDir = path.join(outDir, 'expo-source', manifest.name);
|
|
552
596
|
fs.mkdirSync(pkgDir, { recursive: true });
|
|
553
597
|
linkRoot(pkgDir, moduleRoot);
|
|
@@ -555,7 +599,13 @@ function emitSourceManifestPackage(moduleRoot, react, frameworkSearchPath, outDi
|
|
|
555
599
|
const { targetDeps, pkgDeps } = sourceDependencies(react, codegenPkgPath);
|
|
556
600
|
fs.writeFileSync(
|
|
557
601
|
path.join(pkgDir, 'Package.swift'),
|
|
558
|
-
renderSourceManifest(
|
|
602
|
+
renderSourceManifest({
|
|
603
|
+
manifest,
|
|
604
|
+
pkgDeps,
|
|
605
|
+
injectedTargetDeps: targetDeps,
|
|
606
|
+
frameworkSearchPath,
|
|
607
|
+
extraSwiftFlags: macroFlags,
|
|
608
|
+
})
|
|
559
609
|
);
|
|
560
610
|
|
|
561
611
|
return {
|
|
@@ -567,21 +617,20 @@ function emitSourceManifestPackage(moduleRoot, react, frameworkSearchPath, outDi
|
|
|
567
617
|
/**
|
|
568
618
|
* Emit a source consumption package for a module WITHOUT a checked-in Package.swift,
|
|
569
619
|
* from its resolved descriptor. Pure-Swift modules only (single Swift target over the
|
|
570
|
-
* module's `ios` sources). It compiles against Expo's invariant interface tree,
|
|
620
|
+
* module's `ios` or `apple` sources). It compiles against Expo's invariant interface tree,
|
|
571
621
|
* plus RN's invariant React products.
|
|
572
622
|
*/
|
|
573
|
-
function emitPureSwiftSourcePackage(
|
|
623
|
+
function emitPureSwiftSourcePackage({
|
|
574
624
|
moduleRoot,
|
|
575
625
|
product,
|
|
576
|
-
react,
|
|
626
|
+
react = null,
|
|
577
627
|
frameworkSearchPath,
|
|
578
628
|
outDir,
|
|
579
|
-
codegenPkgPath,
|
|
580
|
-
iosDeploymentTarget = null
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
.find((d) => fs.existsSync(d));
|
|
629
|
+
codegenPkgPath = null,
|
|
630
|
+
iosDeploymentTarget = null,
|
|
631
|
+
macroFlags = [],
|
|
632
|
+
}) {
|
|
633
|
+
const srcDir = appleSourceDir(moduleRoot);
|
|
585
634
|
if (srcDir == null) return null;
|
|
586
635
|
const srcRel = path.relative(moduleRoot, srcDir); // e.g. "ios"
|
|
587
636
|
const pkgDir = path.join(outDir, 'expo-source', product);
|
|
@@ -591,16 +640,17 @@ function emitPureSwiftSourcePackage(
|
|
|
591
640
|
const { targetDeps, pkgDeps } = sourceDependencies(react, codegenPkgPath);
|
|
592
641
|
fs.writeFileSync(
|
|
593
642
|
path.join(pkgDir, 'Package.swift'),
|
|
594
|
-
renderPureSwiftManifest(
|
|
643
|
+
renderPureSwiftManifest({
|
|
595
644
|
product,
|
|
596
645
|
srcRel,
|
|
597
646
|
pkgDeps,
|
|
598
647
|
targetDeps,
|
|
599
648
|
frameworkSearchPath,
|
|
600
|
-
collectIgnoredDirs(srcDir),
|
|
649
|
+
excludes: collectIgnoredDirs(srcDir),
|
|
601
650
|
iosDeploymentTarget,
|
|
602
|
-
fs.existsSync(path.join(srcDir, PRIVACY_MANIFEST))
|
|
603
|
-
|
|
651
|
+
hasPrivacyManifest: fs.existsSync(path.join(srcDir, PRIVACY_MANIFEST)),
|
|
652
|
+
extraSwiftFlags: macroFlags,
|
|
653
|
+
})
|
|
604
654
|
);
|
|
605
655
|
|
|
606
656
|
return {
|
|
@@ -614,6 +664,7 @@ module.exports = {
|
|
|
614
664
|
resolveTargetPaths,
|
|
615
665
|
renderSourceManifest,
|
|
616
666
|
renderPureSwiftManifest,
|
|
667
|
+
raiseFloor,
|
|
617
668
|
emitSourceManifestPackage,
|
|
618
669
|
emitPureSwiftSourcePackage,
|
|
619
670
|
};
|
package/scripts/spm/plugin.js
CHANGED
|
@@ -26,8 +26,11 @@
|
|
|
26
26
|
* everything shells out via `execFileSync` (see cli.js) rather than awaiting.
|
|
27
27
|
*
|
|
28
28
|
* The logic is split across sibling modules — cli.js (I/O), classify.js
|
|
29
|
-
* (discovery),
|
|
30
|
-
*
|
|
29
|
+
* (discovery), app-target.js (the app's Xcode target), flavored-frameworks.js
|
|
30
|
+
* (precompiled frameworks), react-descriptor.js + manifests.js (rendering),
|
|
31
|
+
* podspec.js (podspec reading),
|
|
32
|
+
* script-phases.js (build script phases), diagnostics.js (errors and
|
|
33
|
+
* warnings) — with unit tests in __tests__/. This file is just the orchestrator.
|
|
31
34
|
*/
|
|
32
35
|
|
|
33
36
|
'use strict';
|
|
@@ -36,23 +39,138 @@ const fs = require('fs');
|
|
|
36
39
|
const path = require('path');
|
|
37
40
|
|
|
38
41
|
const { resolveAppTarget } = require('./app-target');
|
|
39
|
-
const { resolveExpoModules, generateModulesProvider } = require('./cli');
|
|
40
|
-
const {
|
|
42
|
+
const { resolveExpoModules, prebuiltMetadata, generateModulesProvider } = require('./cli');
|
|
43
|
+
const {
|
|
44
|
+
APPLE_SOURCE_DIRS,
|
|
45
|
+
appleSourceDir,
|
|
46
|
+
collectWatchPaths,
|
|
47
|
+
documentedPackageRoot,
|
|
48
|
+
findModuleRoot,
|
|
49
|
+
moduleNeedsReact,
|
|
50
|
+
isPureSwift,
|
|
51
|
+
} = require('./classify');
|
|
41
52
|
const {
|
|
42
53
|
classifyUnsupported,
|
|
54
|
+
collectRootConflicts,
|
|
43
55
|
collectUnmappedDependencies,
|
|
56
|
+
renderExtraPodsWarning,
|
|
57
|
+
renderRootConflictWarning,
|
|
44
58
|
renderUnmappedDependencyWarning,
|
|
45
59
|
renderXcconfigLinkerWarning,
|
|
46
60
|
reportUnsupported,
|
|
47
|
-
spmConfigProduct,
|
|
48
61
|
} = require('./diagnostics');
|
|
49
|
-
const {
|
|
50
|
-
|
|
51
|
-
|
|
62
|
+
const {
|
|
63
|
+
assertDistinctFlavoredFrameworks,
|
|
64
|
+
byteOrder,
|
|
65
|
+
prepareCompileInterfaces,
|
|
66
|
+
resolveFlavoredFramework,
|
|
67
|
+
resolveSpmDependencyFrameworks,
|
|
68
|
+
} = require('./flavored-frameworks');
|
|
69
|
+
const {
|
|
70
|
+
emitSourceManifestPackage,
|
|
71
|
+
emitPureSwiftSourcePackage,
|
|
72
|
+
raiseFloor,
|
|
73
|
+
} = require('./manifests');
|
|
74
|
+
const { readPodspecs } = require('./podspec');
|
|
52
75
|
const { scriptPhasesForModules } = require('./script-phases');
|
|
53
76
|
|
|
77
|
+
/**
|
|
78
|
+
* The module roots React Native resolved, keyed by npm package name, from the
|
|
79
|
+
* autolinking.json it passes as `context.autolinking`. React Native passes `{}`
|
|
80
|
+
* when it has no autolinking data, and a root it recorded can be gone after a
|
|
81
|
+
* reinstall, so only roots that are on disk are kept.
|
|
82
|
+
*/
|
|
83
|
+
function collectAutolinkedRoots(autolinking) {
|
|
84
|
+
const roots = new Map();
|
|
85
|
+
for (const [packageName, dependency] of Object.entries(autolinking?.dependencies ?? {})) {
|
|
86
|
+
if (dependency?.root != null && fs.existsSync(dependency.root)) {
|
|
87
|
+
roots.set(packageName, dependency.root);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return roots;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A pod's identity — where its npm package lives, what its product is called,
|
|
95
|
+
* and whether the Expo prebuild pipeline can build it into an XCFramework.
|
|
96
|
+
*
|
|
97
|
+
* The document covers only packages that ship an spm.config.json; React Native's
|
|
98
|
+
* autolinked root answers for the rest, and the filesystem walk stays as the
|
|
99
|
+
* fallback for a sync that gets no autolinking data. A documented root that is
|
|
100
|
+
* gone falls back too — a stale entry is not identity — but its product name
|
|
101
|
+
* still holds.
|
|
102
|
+
*
|
|
103
|
+
* The pod name is NOT the product name — react-native-skia ships RNSkia — so
|
|
104
|
+
* the product is what artifacts and prebuild diagnostics are named after.
|
|
105
|
+
*/
|
|
106
|
+
function podIdentity(entry, pod, packageName, autolinkedRoot) {
|
|
107
|
+
const documentedRoot = documentedPackageRoot(entry);
|
|
108
|
+
return {
|
|
109
|
+
entry,
|
|
110
|
+
packageName,
|
|
111
|
+
documentedRoot,
|
|
112
|
+
autolinkedRoot,
|
|
113
|
+
moduleRoot: documentedRoot ?? autolinkedRoot ?? findModuleRoot(pod.podspecDir),
|
|
114
|
+
productName: entry?.productName ?? pod.podName,
|
|
115
|
+
prebuildProduct:
|
|
116
|
+
entry != null ? { name: entry.productName, sourceOnly: entry.sourceOnly === true } : null,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Every pod's identity, keyed by the pod, resolved once so every pass agrees on it. */
|
|
121
|
+
function resolvePodIdentities(modules, metadata, autolinkedRoots) {
|
|
122
|
+
const identities = new Map();
|
|
123
|
+
for (const mod of modules) {
|
|
124
|
+
for (const pod of mod.pods ?? []) {
|
|
125
|
+
identities.set(
|
|
126
|
+
pod,
|
|
127
|
+
podIdentity(
|
|
128
|
+
metadata[pod.podName],
|
|
129
|
+
pod,
|
|
130
|
+
mod.packageName,
|
|
131
|
+
autolinkedRoots.get(mod.packageName)
|
|
132
|
+
)
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return identities;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Expo modules use Swift macros (@Field, @Record, @OptimizedFunction). A macro expands
|
|
140
|
+
// only when the compiler is handed the macro plugin executable, which ships prebuilt and
|
|
141
|
+
// declares no SwiftPM products — so it travels as a compiler flag, not a dependency.
|
|
142
|
+
// CocoaPods resolves the same binary the same way in
|
|
143
|
+
// `expo-modules-autolinking/scripts/ios/project_integrator.rb#resolve_macros_plugin_dir`.
|
|
144
|
+
function macroPluginFlags(coreModuleRoot) {
|
|
145
|
+
let pkgJsonPath;
|
|
146
|
+
try {
|
|
147
|
+
pkgJsonPath = require.resolve('expo-modules-macros/package.json', {
|
|
148
|
+
paths: [coreModuleRoot],
|
|
149
|
+
});
|
|
150
|
+
} catch {
|
|
151
|
+
throw new Error(
|
|
152
|
+
`[expo-spm-plugin] Could not resolve "expo-modules-macros" from ${coreModuleRoot}. ` +
|
|
153
|
+
'Expo modules are compiled from source here, and their Swift macros cannot expand without ' +
|
|
154
|
+
'this plugin — the build would fail with "external macro implementation could not be found". ' +
|
|
155
|
+
'"expo-modules-core" must be a version that depends on "expo-modules-macros", the new name of ' +
|
|
156
|
+
'"@expo/expo-modules-macros-plugin". Run `npx expo install --fix` to align the Expo package ' +
|
|
157
|
+
'versions, then build again.'
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
const tool = path.join(path.dirname(pkgJsonPath), 'apple', 'ExpoModulesMacros');
|
|
161
|
+
if (!fs.existsSync(tool)) {
|
|
162
|
+
throw new Error(
|
|
163
|
+
`[expo-spm-plugin] The Expo Swift macro plugin is missing its executable at ${tool}. ` +
|
|
164
|
+
'Expo modules are compiled from source here, and their Swift macros cannot expand without ' +
|
|
165
|
+
'it — the build would fail with "external macro implementation could not be found". ' +
|
|
166
|
+
'Reinstall your JavaScript dependencies and build again.'
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
return ['-Xfrontend', '-load-plugin-executable', '-Xfrontend', `${tool}#ExpoModulesMacros`];
|
|
170
|
+
}
|
|
171
|
+
|
|
54
172
|
module.exports = function expoSpmPlugin(context) {
|
|
55
|
-
const { react, outputDir } = context;
|
|
173
|
+
const { autolinking, react, outputDir } = context;
|
|
56
174
|
// `context.appRoot` is the Xcode project dir (`<app>/ios`); the autolinking
|
|
57
175
|
// CLI's --app-root must be the app PACKAGE root, because
|
|
58
176
|
// `generate-modules-provider` filters modules against that dir's package.json
|
|
@@ -60,7 +178,10 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
60
178
|
// provider, with no Expo modules registering at runtime. RN's contract hands
|
|
61
179
|
// us that root directly.
|
|
62
180
|
const appRoot = context.projectRoot;
|
|
63
|
-
const modules = resolveExpoModules(appRoot);
|
|
181
|
+
const { modules, extraDependencies } = resolveExpoModules(appRoot);
|
|
182
|
+
const metadata = prebuiltMetadata(appRoot);
|
|
183
|
+
const autolinkedRoots = collectAutolinkedRoots(autolinking);
|
|
184
|
+
const identities = resolvePodIdentities(modules, metadata, autolinkedRoots);
|
|
64
185
|
const outDir = path.join(outputDir, 'expo');
|
|
65
186
|
// The old contract generated mutable binaryTarget packages here. They are
|
|
66
187
|
// invalid under automatic configuration selection and must never survive a
|
|
@@ -84,7 +205,6 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
84
205
|
const xcconfigLinkage = []; // emitted pods whose podspec xcconfig sets linker flags
|
|
85
206
|
const unresolvedTargets = new Map(); // module root → manifest targets with no sources on disk
|
|
86
207
|
const unsupportedTargetDeps = new Map(); // module root → deps the generated package cannot declare
|
|
87
|
-
const podspecErrors = new Map(); // module root → podspec line the reader refused
|
|
88
208
|
const podspecLinkage = new Map(); // module root → podspec line declaring native linkage
|
|
89
209
|
|
|
90
210
|
// Pass 1 — precompiled runtime frameworks. The declaration is all-or-nothing:
|
|
@@ -92,26 +212,54 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
92
212
|
// receives the plugin result. No runtime binary enters the SwiftPM graph.
|
|
93
213
|
const precompiledFrameworks = new Map();
|
|
94
214
|
const flavoredFrameworks = [];
|
|
215
|
+
const precompiledPods = [];
|
|
216
|
+
let coreModuleRoot = null;
|
|
95
217
|
for (const mod of modules) {
|
|
96
218
|
for (const pod of mod.pods ?? []) {
|
|
97
219
|
if (emitted.has(pod.podName)) continue;
|
|
98
|
-
const moduleRoot =
|
|
220
|
+
const { entry, moduleRoot, productName } = identities.get(pod);
|
|
221
|
+
if (pod.podName === 'ExpoModulesCore') coreModuleRoot = moduleRoot;
|
|
99
222
|
const needsReact = moduleNeedsReact(pod.podName, moduleRoot);
|
|
100
223
|
const framework = resolveFlavoredFramework({
|
|
101
224
|
packageName: mod.packageName,
|
|
102
225
|
moduleRoot,
|
|
103
|
-
frameworkName:
|
|
226
|
+
frameworkName: productName,
|
|
104
227
|
cacheDir: artifactCacheDir,
|
|
105
228
|
});
|
|
106
229
|
if (framework != null) {
|
|
107
230
|
precompiledFrameworks.set(pod.podName, framework);
|
|
108
231
|
flavoredFrameworks.push(framework);
|
|
232
|
+
precompiledPods.push({
|
|
233
|
+
packageName: mod.packageName,
|
|
234
|
+
podName: pod.podName,
|
|
235
|
+
podspecDir: pod.podspecDir,
|
|
236
|
+
moduleRoot,
|
|
237
|
+
spmDependencies: entry?.spmDependencies,
|
|
238
|
+
});
|
|
109
239
|
emitted.add(pod.podName);
|
|
110
240
|
if (needsReact) reactWired.push(pod.podName);
|
|
111
241
|
}
|
|
112
242
|
}
|
|
113
243
|
}
|
|
114
|
-
|
|
244
|
+
// The SwiftPM packages those modules link ship as their own XCFrameworks, and
|
|
245
|
+
// RN takes them in the same flat array. They join before the interface tree is
|
|
246
|
+
// built, so source modules compile against their headers too.
|
|
247
|
+
const dependencyFrameworks = resolveSpmDependencyFrameworks(precompiledPods);
|
|
248
|
+
flavoredFrameworks.push(...dependencyFrameworks);
|
|
249
|
+
flavoredFrameworks.sort((a, b) => byteOrder(a.id, b.id));
|
|
250
|
+
assertDistinctFlavoredFrameworks(flavoredFrameworks);
|
|
251
|
+
|
|
252
|
+
// Pass 2 reports this for the modules it emits, which a precompiled pod reaches
|
|
253
|
+
// only when a sibling pod of its package is not precompiled — so the report for
|
|
254
|
+
// precompiled pods belongs here. What the resolved dependencies already carry is
|
|
255
|
+
// not uncovered, their subspecs included.
|
|
256
|
+
const satisfiedDependencies = new Set(dependencyFrameworks.map((f) => f.frameworkName));
|
|
257
|
+
for (const { packageName, podName, podspecDir } of precompiledPods) {
|
|
258
|
+
const unmapped = collectUnmappedDependencies(podspecDir, satisfiedDependencies);
|
|
259
|
+
if (unmapped.length > 0) {
|
|
260
|
+
unmappedDeps.push({ packageName, podName, pods: unmapped });
|
|
261
|
+
}
|
|
262
|
+
}
|
|
115
263
|
const frameworkSearchPath =
|
|
116
264
|
precompiledFrameworks.size > 0
|
|
117
265
|
? prepareCompileInterfaces(flavoredFrameworks, path.join(outDir, 'compile-interfaces'))
|
|
@@ -120,22 +268,33 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
120
268
|
// Pass 2 — invariant source modules. They compile against the generated
|
|
121
269
|
// headers/module-interface tree and leave runtime linking entirely to RN.
|
|
122
270
|
const coreAvailable = precompiledFrameworks.has('ExpoModulesCore') && frameworkSearchPath != null;
|
|
271
|
+
// Every module imports ExpoModulesCore, so none may be built below its floor —
|
|
272
|
+
// the CocoaPods installer raises them the same way, after install.
|
|
273
|
+
const coreDeploymentTarget = metadata['ExpoModulesCore']?.iosDeploymentTarget ?? null;
|
|
123
274
|
if (coreAvailable) {
|
|
275
|
+
// Every emitted source target compiles against the same ExpoModulesCore interface tree,
|
|
276
|
+
// so every one of them may use the macros — the set CocoaPods reaches through its
|
|
277
|
+
// "is core or depends on core" gate. Resolved on first use so an install that emits
|
|
278
|
+
// no source package at all does not need the macro plugin present.
|
|
279
|
+
let resolvedMacroFlags = null;
|
|
280
|
+
const macroFlags = () => (resolvedMacroFlags ??= macroPluginFlags(coreModuleRoot));
|
|
124
281
|
for (const mod of modules) {
|
|
125
282
|
const pods = mod.pods ?? [];
|
|
126
283
|
if (!pods.length || pods.every((p) => emitted.has(p.podName))) continue;
|
|
127
284
|
const pod = pods[0];
|
|
128
|
-
const moduleRoot =
|
|
285
|
+
const { entry, moduleRoot } = identities.get(pod);
|
|
129
286
|
|
|
130
287
|
if (fs.existsSync(path.join(moduleRoot, 'Package.swift'))) {
|
|
131
|
-
//
|
|
132
|
-
const e = emitSourceManifestPackage(
|
|
288
|
+
// Module ships a checked-in Package.swift → mirror its targets + inject deps.
|
|
289
|
+
const e = emitSourceManifestPackage({
|
|
133
290
|
moduleRoot,
|
|
134
291
|
react,
|
|
135
292
|
frameworkSearchPath,
|
|
136
293
|
outDir,
|
|
137
|
-
codegenPkgPath
|
|
138
|
-
|
|
294
|
+
codegenPkgPath,
|
|
295
|
+
minimumIosDeploymentTarget: coreDeploymentTarget,
|
|
296
|
+
macroFlags: macroFlags(),
|
|
297
|
+
});
|
|
139
298
|
if (e.unsupportedTargetDeps != null) {
|
|
140
299
|
unsupportedTargetDeps.set(moduleRoot, e.unsupportedTargetDeps);
|
|
141
300
|
} else if (e.unresolvedTargets != null) {
|
|
@@ -148,37 +307,31 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
148
307
|
if (react != null) reactWired.push(pod.podName);
|
|
149
308
|
}
|
|
150
309
|
} else if (isPureSwift(moduleRoot)) {
|
|
151
|
-
// Pure-Swift module → single Swift target over its ios sources. Its podspec
|
|
152
|
-
//
|
|
153
|
-
// podspec declares is skipped and diagnosed, never emitted half-linked.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
pod.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
].filter(Boolean)
|
|
164
|
-
);
|
|
165
|
-
} catch (error) {
|
|
166
|
-
if (!(error instanceof PodspecSyntaxError)) throw error;
|
|
167
|
-
podspecErrors.set(moduleRoot, error);
|
|
168
|
-
}
|
|
169
|
-
if (podspecs?.linkage != null) podspecLinkage.set(moduleRoot, podspecs.linkage);
|
|
310
|
+
// Pure-Swift module → single Swift target over its ios sources. Its podspec is
|
|
311
|
+
// only read for what would make the emission wrong: a module whose linkage only
|
|
312
|
+
// the podspec declares is skipped and diagnosed, never emitted half-linked.
|
|
313
|
+
const podspecs = readPodspecs(
|
|
314
|
+
pod.podName,
|
|
315
|
+
[
|
|
316
|
+
pod.podspecDir,
|
|
317
|
+
...APPLE_SOURCE_DIRS.map((dir) => path.join(moduleRoot, dir)),
|
|
318
|
+
moduleRoot,
|
|
319
|
+
].filter(Boolean)
|
|
320
|
+
);
|
|
321
|
+
if (podspecs.linkage != null) podspecLinkage.set(moduleRoot, podspecs.linkage);
|
|
170
322
|
const e =
|
|
171
|
-
podspecs
|
|
323
|
+
podspecs.linkage != null
|
|
172
324
|
? null
|
|
173
|
-
: emitPureSwiftSourcePackage(
|
|
325
|
+
: emitPureSwiftSourcePackage({
|
|
174
326
|
moduleRoot,
|
|
175
|
-
pod.podName,
|
|
327
|
+
product: pod.podName,
|
|
176
328
|
react,
|
|
177
329
|
frameworkSearchPath,
|
|
178
330
|
outDir,
|
|
179
331
|
codegenPkgPath,
|
|
180
|
-
|
|
181
|
-
|
|
332
|
+
iosDeploymentTarget: raiseFloor(entry?.iosDeploymentTarget, coreDeploymentTarget),
|
|
333
|
+
macroFlags: macroFlags(),
|
|
334
|
+
});
|
|
182
335
|
if (e != null) {
|
|
183
336
|
packageDependencies.push(e.packageDep);
|
|
184
337
|
productDependencies.push(e.productDep);
|
|
@@ -195,8 +348,11 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
195
348
|
}
|
|
196
349
|
}
|
|
197
350
|
|
|
198
|
-
|
|
199
|
-
|
|
351
|
+
// A precompiled pod was already diagnosed in pass 1. It still reaches here
|
|
352
|
+
// when a sibling pod of the same package is not precompiled, and warning
|
|
353
|
+
// again would print the identical block twice.
|
|
354
|
+
if (emitted.has(pod.podName) && !precompiledFrameworks.has(pod.podName)) {
|
|
355
|
+
const unmapped = collectUnmappedDependencies(pod.podspecDir, satisfiedDependencies);
|
|
200
356
|
if (unmapped.length > 0) {
|
|
201
357
|
unmappedDeps.push({
|
|
202
358
|
packageName: mod.packageName,
|
|
@@ -216,18 +372,17 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
216
372
|
for (const mod of modules) {
|
|
217
373
|
for (const pod of mod.pods ?? []) {
|
|
218
374
|
if (emitted.has(pod.podName)) continue;
|
|
219
|
-
const moduleRoot =
|
|
375
|
+
const { moduleRoot, prebuildProduct } = identities.get(pod);
|
|
220
376
|
pending.push({
|
|
221
377
|
podName: pod.podName,
|
|
222
378
|
packageName: mod.packageName,
|
|
223
379
|
moduleRoot,
|
|
224
380
|
pureSwift: isPureSwift(moduleRoot),
|
|
225
|
-
hasSources:
|
|
381
|
+
hasSources: appleSourceDir(moduleRoot) != null,
|
|
226
382
|
unsupportedTargetDeps: unsupportedTargetDeps.get(moduleRoot) ?? null,
|
|
227
383
|
unresolvedTargets: unresolvedTargets.get(moduleRoot) ?? null,
|
|
228
|
-
podspecError: podspecErrors.get(moduleRoot) ?? null,
|
|
229
384
|
podspecLinkage: podspecLinkage.get(moduleRoot) ?? null,
|
|
230
|
-
prebuildProduct
|
|
385
|
+
prebuildProduct,
|
|
231
386
|
});
|
|
232
387
|
}
|
|
233
388
|
}
|
|
@@ -253,6 +408,13 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
253
408
|
if (xcconfigLinkage.length > 0) {
|
|
254
409
|
console.warn(renderXcconfigLinkerWarning(xcconfigLinkage));
|
|
255
410
|
}
|
|
411
|
+
const rootConflicts = collectRootConflicts(identities);
|
|
412
|
+
if (rootConflicts.length > 0) {
|
|
413
|
+
console.warn(renderRootConflictWarning(rootConflicts));
|
|
414
|
+
}
|
|
415
|
+
if (extraDependencies.length > 0) {
|
|
416
|
+
console.warn(renderExtraPodsWarning(extraDependencies));
|
|
417
|
+
}
|
|
256
418
|
if (react == null) {
|
|
257
419
|
console.warn(
|
|
258
420
|
'[expo-spm-plugin] WARNING: context.react is null — no React dependency available.'
|
|
@@ -318,12 +480,7 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
318
480
|
// Package.swift and expo-module.config.json. Editing either must trip RN's
|
|
319
481
|
// in-build re-sync — the manifests drive the generated wrapper packages, the
|
|
320
482
|
// configs drive module resolution.
|
|
321
|
-
const moduleRoots = new Set();
|
|
322
|
-
for (const mod of modules) {
|
|
323
|
-
for (const pod of mod.pods ?? []) {
|
|
324
|
-
moduleRoots.add(findModuleRoot(pod.podspecDir));
|
|
325
|
-
}
|
|
326
|
-
}
|
|
483
|
+
const moduleRoots = new Set([...identities.values()].map((identity) => identity.moduleRoot));
|
|
327
484
|
// The registry's other inputs: app groups come from the entitlements file and
|
|
328
485
|
// inline-module registration from Podfile.properties.json, so editing either
|
|
329
486
|
// must trip the re-sync as well. Known gap: repointing CODE_SIGN_ENTITLEMENTS
|
|
@@ -350,3 +507,5 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
350
507
|
scriptPhases,
|
|
351
508
|
};
|
|
352
509
|
};
|
|
510
|
+
|
|
511
|
+
module.exports.resolvePodIdentities = resolvePodIdentities;
|