expo 58.0.0 → 58.0.2
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 +76 -76
- package/ios/Expo/ExpoReactNativeFactory.swift +2 -2
- package/ios/ExpoObjC/AppDelegates/EXReactRootViewFactory.mm +16 -2
- package/ios/ExpoObjC/include/Expo/EXReactRootViewFactory.h +2 -1
- package/package.json +13 -13
- package/scripts/spm/README.md +0 -3
- package/scripts/spm/__tests__/app-target.test.js +105 -1
- package/scripts/spm/__tests__/autolink-gate.test.js +188 -0
- package/scripts/spm/__tests__/classify.test.js +17 -19
- package/scripts/spm/__tests__/cli.test.js +57 -1
- package/scripts/spm/__tests__/diagnostics.test.js +806 -183
- 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 +1330 -104
- package/scripts/spm/__tests__/metadata.test.js +120 -0
- package/scripts/spm/__tests__/plugin.test.js +3304 -111
- package/scripts/spm/__tests__/podspec.test.js +27 -138
- package/scripts/spm/__tests__/spm-dependencies.test.js +344 -0
- package/scripts/spm/app-target.js +42 -1
- package/scripts/spm/autolink-gate.js +40 -0
- package/scripts/spm/classify.js +78 -79
- package/scripts/spm/cli.js +23 -9
- package/scripts/spm/diagnostics.js +605 -192
- package/scripts/spm/flavored-frameworks.js +231 -64
- package/scripts/spm/manifests.js +565 -196
- package/scripts/spm/metadata.js +152 -0
- package/scripts/spm/plugin.js +679 -205
- package/scripts/spm/podspec.js +57 -170
- 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
|
@@ -16,8 +16,6 @@
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
const fs = require('fs');
|
|
19
|
-
const path = require('path');
|
|
20
|
-
const { podspecBodyLines } = require('./podspec');
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
21
|
* Pod-name families already covered by the SwiftPM graph: Expo's own modules
|
|
@@ -51,12 +49,18 @@ const COVERED_POD_PREFIXES = [
|
|
|
51
49
|
*/
|
|
52
50
|
const UNMAPPED_POD_ALLOWLIST = new Set(['sqlite3']);
|
|
53
51
|
|
|
52
|
+
/**
|
|
53
|
+
* An error the plugin fails the sync with, namespaced so the failure is
|
|
54
|
+
* attributable to it: what failed, then why and what to do next when known.
|
|
55
|
+
* `options` goes to the Error, so a `cause` passed there is kept.
|
|
56
|
+
*/
|
|
57
|
+
function pluginError({ what, why, how }, options) {
|
|
58
|
+
return new Error(`[expo-spm-plugin] ${[what, why, how].filter(Boolean).join(' ')}`, options);
|
|
59
|
+
}
|
|
60
|
+
|
|
54
61
|
class UnsupportedModulesError extends Error {
|
|
55
62
|
constructor(entries) {
|
|
56
|
-
const count = entries.reduce(
|
|
57
|
-
(n, e) => n + (e.reason === 'core-unavailable' ? e.pods.length : 1),
|
|
58
|
-
0
|
|
59
|
-
);
|
|
63
|
+
const count = entries.reduce((n, e) => n + REFUSALS.get(e.reason).count(e), 0);
|
|
60
64
|
super(
|
|
61
65
|
`${count} Expo native ${count === 1 ? 'module' : 'modules'} cannot be built with ` +
|
|
62
66
|
'Swift Package Manager. See the errors above for the fix for each one.'
|
|
@@ -67,148 +71,160 @@ class UnsupportedModulesError extends Error {
|
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
config = JSON.parse(fs.readFileSync(path.join(moduleRoot, 'spm.config.json'), 'utf8'));
|
|
79
|
-
} catch {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
const product = (config.products ?? []).find((p) => (p.podName ?? p.name) === podName);
|
|
83
|
-
if (product == null) return null;
|
|
84
|
-
return { name: product.name, sourceOnly: product.sourceOnly === true };
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Why each uncovered pod is uncovered. A missing interface tree is a single
|
|
89
|
-
* project-level fault that would otherwise be reported once per module, so it
|
|
90
|
-
* collapses into one entry naming the modules it took down.
|
|
74
|
+
* Why each uncovered pod is uncovered: the most specific of the refusals it
|
|
75
|
+
* collected. A missing interface tree is a single project-level fault that would
|
|
76
|
+
* otherwise be reported once per module, so it collapses into one entry naming
|
|
77
|
+
* the modules it took down.
|
|
78
|
+
*
|
|
79
|
+
* @param pending `{ podName, packageName, moduleRoot, refusals }` per uncovered pod,
|
|
80
|
+
* each refusal a `{ reason, ...facts }` whose reason `REFUSALS` registers.
|
|
91
81
|
*/
|
|
92
82
|
function classifyUnsupported({ pending, coreAvailable }) {
|
|
93
83
|
if (!pending.length) return [];
|
|
94
84
|
if (!coreAvailable) {
|
|
95
85
|
return [{ reason: 'core-unavailable', pods: pending.map((p) => p.podName) }];
|
|
96
86
|
}
|
|
97
|
-
return pending.map((
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
packageName: p.packageName,
|
|
104
|
-
moduleRoot: p.moduleRoot,
|
|
105
|
-
productName: p.prebuildProduct.name,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
if (p.podspecError != null) {
|
|
109
|
-
const { file, line, snippet, reason } = p.podspecError;
|
|
110
|
-
return {
|
|
111
|
-
reason: 'unsupported-podspec-syntax',
|
|
112
|
-
podName: p.podName,
|
|
113
|
-
packageName: p.packageName,
|
|
114
|
-
moduleRoot: p.moduleRoot,
|
|
115
|
-
file,
|
|
116
|
-
line,
|
|
117
|
-
snippet,
|
|
118
|
-
problem: reason,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
if (p.podspecLinkage != null) {
|
|
122
|
-
const { file, line, snippet } = p.podspecLinkage;
|
|
123
|
-
return {
|
|
124
|
-
reason: 'needs-manifest-for-linkage',
|
|
125
|
-
podName: p.podName,
|
|
126
|
-
packageName: p.packageName,
|
|
127
|
-
moduleRoot: p.moduleRoot,
|
|
128
|
-
file,
|
|
129
|
-
line,
|
|
130
|
-
snippet,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
if (p.unsupportedTargetDeps?.length) {
|
|
134
|
-
return {
|
|
135
|
-
reason: 'unsupported-target-dependency',
|
|
136
|
-
podName: p.podName,
|
|
137
|
-
packageName: p.packageName,
|
|
138
|
-
moduleRoot: p.moduleRoot,
|
|
139
|
-
dependencies: p.unsupportedTargetDeps,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
if (p.unresolvedTargets?.length) {
|
|
143
|
-
return {
|
|
144
|
-
reason: 'unresolvable-target-path',
|
|
145
|
-
podName: p.podName,
|
|
146
|
-
packageName: p.packageName,
|
|
147
|
-
moduleRoot: p.moduleRoot,
|
|
148
|
-
targetNames: p.unresolvedTargets,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
reason: p.hasSources === false ? 'no-apple-sources' : 'mixed-no-manifest',
|
|
153
|
-
podName: p.podName,
|
|
154
|
-
packageName: p.packageName,
|
|
155
|
-
moduleRoot: p.moduleRoot,
|
|
156
|
-
productName: p.prebuildProduct?.name ?? null,
|
|
157
|
-
};
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/** Pod names a podspec depends on, ignoring `test_spec` blocks. Text-only. */
|
|
162
|
-
function podspecDependencies(text) {
|
|
163
|
-
const deps = [];
|
|
164
|
-
for (const { text: line } of podspecBodyLines(text)) {
|
|
165
|
-
const match = line.match(/\.dependency\s+['"]([^'"]+)['"]/);
|
|
166
|
-
if (match) deps.push(match[1]);
|
|
167
|
-
}
|
|
168
|
-
return deps;
|
|
87
|
+
return pending.map(({ refusals, ...subject }) => ({ ...subject, ...mostSpecific(refusals) }));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function mostSpecific(refusals) {
|
|
91
|
+
const priority = (refusal) => REFUSALS.get(refusal.reason).priority;
|
|
92
|
+
return refusals.reduce((best, refusal) => (priority(refusal) < priority(best) ? refusal : best));
|
|
169
93
|
}
|
|
170
94
|
|
|
171
|
-
/**
|
|
172
|
-
|
|
95
|
+
/**
|
|
96
|
+
* The subset of pod dependencies with no SwiftPM counterpart. `satisfied` holds
|
|
97
|
+
* the SwiftPM packages already declared as frameworks, matched on the root of the
|
|
98
|
+
* pod name so that a subspec (`libavif/libdav1d`) is covered by its package —
|
|
99
|
+
* the match CocoaPods makes in `precompiled_modules.rb#strip_matching_dependencies`.
|
|
100
|
+
*/
|
|
101
|
+
function unmappedPodDependencies(deps, satisfied = new Set()) {
|
|
173
102
|
return deps.filter(
|
|
174
103
|
(dep) =>
|
|
175
104
|
!UNMAPPED_POD_ALLOWLIST.has(dep) &&
|
|
105
|
+
!satisfied.has(dep.split('/')[0]) &&
|
|
176
106
|
!COVERED_POD_PREFIXES.some((prefix) => dep.startsWith(prefix))
|
|
177
107
|
);
|
|
178
108
|
}
|
|
179
109
|
|
|
180
|
-
/**
|
|
181
|
-
|
|
182
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Two paths that name different real directories. A path that cannot be resolved
|
|
112
|
+
* — a broken symlink, an unreadable parent — counts as no difference: a symlinked
|
|
113
|
+
* layout is the normal case here, and a diagnostic is never worth failing on.
|
|
114
|
+
*/
|
|
115
|
+
function resolveToDifferentDirectories(left, right) {
|
|
183
116
|
try {
|
|
184
|
-
|
|
117
|
+
return fs.realpathSync(left) !== fs.realpathSync(right);
|
|
185
118
|
} catch {
|
|
186
|
-
return
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Packages whose documented and autolinked roots are different REAL directories (a
|
|
125
|
+
* symlinked path is not a conflict); any pod may document the second copy.
|
|
126
|
+
* The plugin builds the copy the app's JavaScript does not import.
|
|
127
|
+
*/
|
|
128
|
+
function collectRootConflicts(identities) {
|
|
129
|
+
const conflicts = new Map();
|
|
130
|
+
for (const { packageName, documentedRoot, autolinkedRoot } of identities.values()) {
|
|
131
|
+
if (conflicts.has(packageName) || documentedRoot == null || autolinkedRoot == null) continue;
|
|
132
|
+
if (resolveToDifferentDirectories(documentedRoot, autolinkedRoot)) {
|
|
133
|
+
conflicts.set(packageName, { packageName, moduleRoot: documentedRoot, autolinkedRoot });
|
|
134
|
+
}
|
|
187
135
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
136
|
+
return [...conflicts.values()];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A `duplicate-pod-name` entry for every pod name that separate copies declare:
|
|
141
|
+
* different packages in different directories. SwiftPM, like CocoaPods, links a
|
|
142
|
+
* pod name once, so which copy the app got would depend on the order the plugin
|
|
143
|
+
* reached them in. Listings that share a package or a real directory are one copy,
|
|
144
|
+
* and so is everything joined to them that way, whatever order they come in; each
|
|
145
|
+
* copy is shown by its lowest root, and the copies are listed in that order. A root
|
|
146
|
+
* that cannot be resolved is its own directory: two missing roots are not shown to be
|
|
147
|
+
* one.
|
|
148
|
+
*
|
|
149
|
+
* @param identities every pod's identity, from `plugin.js#resolvePodIdentities`.
|
|
150
|
+
*/
|
|
151
|
+
function collectDuplicatePods(identities) {
|
|
152
|
+
const copiesByPod = new Map();
|
|
153
|
+
for (const { podName, packageName, declaringRoot } of identities.values()) {
|
|
154
|
+
const listing = { packageName, moduleRoot: declaringRoot };
|
|
155
|
+
const keys = [`package:${packageName}`, `directory:${realPathOrSelf(declaringRoot)}`];
|
|
156
|
+
const copies = copiesByPod.get(podName) ?? [];
|
|
157
|
+
const joined = copies.filter((copy) => keys.some((key) => copy.keys.has(key)));
|
|
158
|
+
if (!joined.length) {
|
|
159
|
+
copiesByPod.set(podName, [...copies, { listings: [listing], keys: new Set(keys) }]);
|
|
194
160
|
continue;
|
|
195
161
|
}
|
|
196
|
-
|
|
162
|
+
// This listing can bridge copies that looked separate until now; they merge
|
|
163
|
+
// into the earliest one.
|
|
164
|
+
const [copy, ...merged] = joined;
|
|
165
|
+
for (const key of keys) copy.keys.add(key);
|
|
166
|
+
copy.listings.push(listing);
|
|
167
|
+
for (const other of merged) {
|
|
168
|
+
for (const key of other.keys) copy.keys.add(key);
|
|
169
|
+
copy.listings.push(...other.listings);
|
|
170
|
+
}
|
|
171
|
+
copiesByPod.set(
|
|
172
|
+
podName,
|
|
173
|
+
copies.filter((other) => !merged.includes(other))
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
return [...copiesByPod]
|
|
177
|
+
.filter(([, copies]) => copies.length > 1)
|
|
178
|
+
.map(([podName, copies]) => ({
|
|
179
|
+
reason: 'duplicate-pod-name',
|
|
180
|
+
podName,
|
|
181
|
+
copies: copies.map(({ listings }) => lowestListing(listings)).sort(byListingOrder),
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const listingOrder = ({ moduleRoot, packageName }) => `${moduleRoot}\0${packageName}`;
|
|
186
|
+
const byListingOrder = (a, b) =>
|
|
187
|
+
listingOrder(a) < listingOrder(b) ? -1 : listingOrder(a) > listingOrder(b) ? 1 : 0;
|
|
188
|
+
const lowestListing = (listings) =>
|
|
189
|
+
listings.reduce((lowest, listing) => (byListingOrder(listing, lowest) < 0 ? listing : lowest));
|
|
190
|
+
|
|
191
|
+
function realPathOrSelf(dir) {
|
|
192
|
+
try {
|
|
193
|
+
return fs.realpathSync(dir);
|
|
194
|
+
} catch {
|
|
195
|
+
return dir;
|
|
197
196
|
}
|
|
198
|
-
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const excludeSnippet = (...packageNames) =>
|
|
200
|
+
`"expo": { "autolinking": { "exclude": ["${packageNames.join('", "')}"] } }`;
|
|
201
|
+
|
|
202
|
+
/** Next steps that several diagnostics end on, worded once. */
|
|
203
|
+
const remedy = {
|
|
204
|
+
patchPackage: (packageName, file = 'that file') =>
|
|
205
|
+
`If you do not own ${packageName}, persist ${file} with \`npx patch-package ${packageName}\` and commit the patch — node_modules is not committed, so without it this error returns on every fresh install and in CI.`,
|
|
206
|
+
exclude: (packageName) =>
|
|
207
|
+
`To build without this module for now, exclude it in your app's package.json: ${excludeSnippet(packageName)} — its native module will then be unavailable at runtime.`,
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/** One diagnostic: its header line, the lines indented under it, and the module it is about. */
|
|
211
|
+
function renderBlock(header, lines, moduleRoot) {
|
|
212
|
+
return [header, ...lines.map((line) => ` ${line}`), ` Module path: ${moduleRoot}`].join('\n');
|
|
199
213
|
}
|
|
200
214
|
|
|
201
215
|
function renderMixedNoManifest({ podName, packageName, moduleRoot }) {
|
|
202
|
-
return
|
|
216
|
+
return renderBlock(
|
|
203
217
|
`error: Expo module "${packageName}" (pod ${podName}) mixes Swift and Objective-C/C++ sources but ships neither a Package.swift nor an spm.config.json, so it cannot be built with Swift Package Manager.`,
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
218
|
+
[
|
|
219
|
+
`Swift Package Manager compiles Swift and Objective-C in separate targets, and only the module can declare where its split goes. Either route makes it consumable:`,
|
|
220
|
+
`1. Add an spm.config.json to ${packageName} so the Expo prebuild pipeline can build it into an XCFramework — it compiles mixed-language targets, so no source split is needed. packages/expo-sensors is a worked example.`,
|
|
221
|
+
`2. Or add a Package.swift to ${packageName} that splits its sources into a Swift target and an Objective-C target. packages/expo-constants is a worked example, splitting into EXConstants and EXConstantsObjC.`,
|
|
222
|
+
`3. ${remedy.patchPackage(packageName, 'either manifest')}`,
|
|
223
|
+
`4. Ask ${packageName}'s maintainer to ship it upstream, or open a PR adding it, so every consumer gets Swift Package Manager support.`,
|
|
224
|
+
`5. ${remedy.exclude(packageName)}`,
|
|
225
|
+
],
|
|
226
|
+
moduleRoot
|
|
227
|
+
);
|
|
212
228
|
}
|
|
213
229
|
|
|
214
230
|
/**
|
|
@@ -217,34 +233,84 @@ function renderMixedNoManifest({ podName, packageName, moduleRoot }) {
|
|
|
217
233
|
* both flavors are mandatory because the plugin declares immutable pairs.
|
|
218
234
|
*/
|
|
219
235
|
function renderPrebuildAvailable({ podName, packageName, moduleRoot, productName }) {
|
|
220
|
-
return
|
|
236
|
+
return renderBlock(
|
|
221
237
|
`error: Expo module "${packageName}" (pod ${podName}) has no prebuilt XCFramework, so it is not in the Swift Package Manager graph.`,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
238
|
+
[
|
|
239
|
+
`It declares "${productName}" in its spm.config.json, so it does not need a Package.swift — the Expo prebuild pipeline builds it. The artifact is just missing.`,
|
|
240
|
+
`Build it — omit --flavor so both Debug and Release are built, since the plugin declares an immutable pair and rejects a half-built one:`,
|
|
241
|
+
` et prebuild ${packageName}`,
|
|
242
|
+
`Then re-run \`npx react-native spm update\`. A published ${packageName} that ships prebuilds/output/<flavor>/xcframeworks is picked up with no local build.`,
|
|
243
|
+
],
|
|
244
|
+
moduleRoot
|
|
245
|
+
);
|
|
228
246
|
}
|
|
229
247
|
|
|
230
248
|
function renderNoAppleSources({ podName, packageName, moduleRoot }) {
|
|
231
|
-
return
|
|
249
|
+
return renderBlock(
|
|
232
250
|
`error: Expo module "${packageName}" (pod ${podName}) has no \`ios\` or \`apple\` source directory, so Swift Package Manager has nothing to compile.`,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
251
|
+
[
|
|
252
|
+
`Its podspec points at sources the plugin cannot locate — either the package is incomplete (a partial install) or it keeps its Apple sources somewhere non-standard and needs a checked-in Package.swift naming their real path.`,
|
|
253
|
+
`Reinstall the package first. If the layout is intentional, add a Package.swift to ${packageName} and persist it with \`npx patch-package ${packageName}\`, then upstream it.`,
|
|
254
|
+
],
|
|
255
|
+
moduleRoot
|
|
256
|
+
);
|
|
237
257
|
}
|
|
238
258
|
|
|
239
259
|
function renderUnresolvableTargetPath({ podName, packageName, moduleRoot, targetNames }) {
|
|
240
260
|
const quoted = targetNames.map((n) => `"${n}"`).join(', ');
|
|
241
261
|
const plural = targetNames.length === 1 ? 'target' : 'targets';
|
|
242
|
-
return
|
|
262
|
+
return renderBlock(
|
|
243
263
|
`error: Expo module "${packageName}" (pod ${podName}) ships a Package.swift whose ${plural} ${quoted} declare no \`path:\` and have no sources on disk, so it was skipped.`,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
264
|
+
[
|
|
265
|
+
`A target without \`path:\` takes its sources from Sources/<target name> (or Source/, src/, srcs/). None of those directories exist in the module, so the generated package would point at nothing — usually a partial install, or a manifest naming targets whose sources live elsewhere.`,
|
|
266
|
+
`Reinstall ${packageName} first. If its layout is intentional, add an explicit \`path:\` to each target in its Package.swift, persist it with \`npx patch-package ${packageName}\`, and upstream it.`,
|
|
267
|
+
],
|
|
268
|
+
moduleRoot
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function renderNotExportedByManifest({
|
|
273
|
+
podName,
|
|
274
|
+
packageName,
|
|
275
|
+
moduleRoot,
|
|
276
|
+
productName,
|
|
277
|
+
exportedProducts,
|
|
278
|
+
}) {
|
|
279
|
+
return renderBlock(
|
|
280
|
+
`error: Expo module "${packageName}" (pod ${podName}) is built from the Package.swift at its module root, but that manifest does not export "${productName}", so the pod cannot be linked.`,
|
|
281
|
+
[
|
|
282
|
+
`The manifest exports ${exportedProducts.map((name) => `"${name}"`).join(', ') || 'no library products'}. A pod is linked through the library product of the same name.`,
|
|
283
|
+
`Add a \`.library(name: "${productName}", …)\` product to that Package.swift, or remove the pod from ${packageName}. ${remedy.patchPackage(packageName)}`,
|
|
284
|
+
remedy.exclude(packageName),
|
|
285
|
+
],
|
|
286
|
+
moduleRoot
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* The module is linked through its checked-in manifest, which leaves out a companion
|
|
292
|
+
* CocoaPods links for this app. Linking the rest would build an app without it.
|
|
293
|
+
*/
|
|
294
|
+
function renderCompanionNotExportedByManifest({
|
|
295
|
+
packageName,
|
|
296
|
+
moduleRoot,
|
|
297
|
+
productName,
|
|
298
|
+
autolinkWhen,
|
|
299
|
+
}) {
|
|
300
|
+
const { because, turnOff } = companionCondition(autolinkWhen);
|
|
301
|
+
return renderBlock(
|
|
302
|
+
`error: Expo module "${packageName}" does not export its companion product "${productName}" in its Package.swift, although the product's autolinkWhen condition is met: ${because}.`,
|
|
303
|
+
[
|
|
304
|
+
`CocoaPods links "${productName}" for this app. Swift Package Manager would leave it out, and its feature would be missing at runtime, so the sync stops instead.`,
|
|
305
|
+
`Add a \`.library(name: "${productName}", …)\` product to ${moduleRoot}/Package.swift, or ask the maintainer of ${packageName} to add it. ${remedy.patchPackage(packageName)}`,
|
|
306
|
+
...(turnOff != null
|
|
307
|
+
? [
|
|
308
|
+
`If the app does not need "${productName}", ${turnOff}. If ios/ is generated by npx expo prebuild, set the matching option in the module's config plugin instead.`,
|
|
309
|
+
]
|
|
310
|
+
: []),
|
|
311
|
+
],
|
|
312
|
+
moduleRoot
|
|
313
|
+
);
|
|
248
314
|
}
|
|
249
315
|
|
|
250
316
|
// Map, not an object: the kind comes from a dumped manifest, and an inherited key like
|
|
@@ -271,54 +337,262 @@ function renderUnsupportedTargetDependency({ podName, packageName, moduleRoot, d
|
|
|
271
337
|
dependencies.length === 1
|
|
272
338
|
? 'whose source target depends on a target'
|
|
273
339
|
: 'whose source targets depend on targets';
|
|
274
|
-
return
|
|
340
|
+
return renderBlock(
|
|
275
341
|
`error: Expo module "${packageName}" (pod ${podName}) ships a Package.swift ${wiring} the generated package cannot declare, so it was skipped.`,
|
|
276
|
-
|
|
277
|
-
(
|
|
278
|
-
|
|
279
|
-
)
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
342
|
+
[
|
|
343
|
+
...dependencies.map(
|
|
344
|
+
({ target, dependsOn, kind }) =>
|
|
345
|
+
` target "${target}" depends on "${dependsOn}", ${targetKindPhrase(kind)}`
|
|
346
|
+
),
|
|
347
|
+
`The generated package mirrors only the module's regular source targets. A target of any other kind is built by Swift Package Manager from the module's own manifest, so the generated package has nothing to depend on. Emitting the target without that dependency would compile and then fail at link time with undefined symbols, far from the manifest that declared it.`,
|
|
348
|
+
`Add an spm.config.json to ${packageName} so the Expo prebuild pipeline builds the whole module into an XCFramework instead — it compiles the package as checked in, these targets included. packages/expo-sensors is a worked example.`,
|
|
349
|
+
remedy.patchPackage(packageName),
|
|
350
|
+
],
|
|
351
|
+
moduleRoot
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** What a fault is about, when it is a package the manifest declares. */
|
|
356
|
+
function packageSubject(identity, target) {
|
|
357
|
+
const named = identity != null ? `package "${identity}"` : 'an unnamed package';
|
|
358
|
+
return target != null ? `${named}, used by target "${target}",` : named;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** What a fault is about, when it is one target's dependency rather than a package. */
|
|
362
|
+
const dependencySubject = (identity, target) =>
|
|
363
|
+
`the dependency on "${identity}" in target "${target}"`;
|
|
364
|
+
|
|
365
|
+
const conditionStep = (packageName) =>
|
|
366
|
+
`Condition it on platforms alone in ${packageName}'s Package.swift. Rendering it without the rest would apply the dependency more widely than the module declared.`;
|
|
367
|
+
|
|
368
|
+
const byUrlStep = (packageName) =>
|
|
369
|
+
`Declare it by remote URL in ${packageName}'s Package.swift instead.`;
|
|
370
|
+
|
|
371
|
+
// One fault, one cause and one next step: the causes have nothing in common but the
|
|
372
|
+
// module they skip.
|
|
373
|
+
const PACKAGE_DEPENDENCY_FAULTS = {
|
|
374
|
+
'local-path': {
|
|
375
|
+
fault: 'is declared at a local path, which this plugin does not resolve',
|
|
376
|
+
step: (packageName) =>
|
|
377
|
+
`Declare it by remote URL in ${packageName}'s Package.swift — the generated package is written into the app's build directory, and a path declared relative to the module does not reach from there.`,
|
|
378
|
+
},
|
|
379
|
+
registry: {
|
|
380
|
+
fault: 'is declared through a package registry, which this plugin does not declare',
|
|
381
|
+
step: byUrlStep,
|
|
382
|
+
},
|
|
383
|
+
'unsupported-location': {
|
|
384
|
+
fault: 'is declared from a source-control location that is not a remote URL',
|
|
385
|
+
step: byUrlStep,
|
|
386
|
+
},
|
|
387
|
+
'unsupported-requirement': {
|
|
388
|
+
fault: 'names a version requirement this plugin cannot render',
|
|
389
|
+
step: () =>
|
|
390
|
+
'Pin it to an exact version, a branch, a revision or a version range, which are the requirements the generated package can declare.',
|
|
391
|
+
},
|
|
392
|
+
'unknown-form': {
|
|
393
|
+
fault: 'is declared in a form this plugin does not recognize',
|
|
394
|
+
step: (packageName) =>
|
|
395
|
+
`Declare it by remote URL in ${packageName}'s Package.swift. A newer Swift Package Manager form needs support added in expo/scripts/spm/manifests.js.`,
|
|
396
|
+
},
|
|
397
|
+
'undeclared-package': {
|
|
398
|
+
fault: 'is not declared by the manifest, so the product that names it resolves to nothing',
|
|
399
|
+
step: (packageName) =>
|
|
400
|
+
`Declare that package in ${packageName}'s Package.swift, or correct the package name on the dependency — Swift Package Manager matches it against the package's identity, which is the repository name.`,
|
|
401
|
+
},
|
|
402
|
+
'collides-with-injected': {
|
|
403
|
+
fault:
|
|
404
|
+
'has the same identity as a package React Native already contributes, and Swift Package Manager resolves one identity to one package',
|
|
405
|
+
step: () =>
|
|
406
|
+
"Depend on the product React Native's package already provides and remove the declaration, or declare a package whose repository name differs from React Native's.",
|
|
407
|
+
},
|
|
408
|
+
'module-aliases': {
|
|
409
|
+
fault: 'is renamed with moduleAliases, which this plugin does not render',
|
|
410
|
+
step: (packageName) =>
|
|
411
|
+
`Drop the alias in ${packageName}'s Package.swift and import the module under its own name. An alias that resolves a duplicate module name has no equivalent here.`,
|
|
412
|
+
},
|
|
413
|
+
'unsupported-condition': {
|
|
414
|
+
fault: 'is conditioned on more than platforms, and this plugin renders only platforms',
|
|
415
|
+
step: conditionStep,
|
|
416
|
+
},
|
|
417
|
+
'unsupported-target-condition': {
|
|
418
|
+
subject: dependencySubject,
|
|
419
|
+
fault: 'is conditioned on more than platforms, and this plugin renders only platforms',
|
|
420
|
+
step: conditionStep,
|
|
421
|
+
},
|
|
422
|
+
'ambiguous-package-name': {
|
|
423
|
+
subject: (identity) => `"${identity}"`,
|
|
424
|
+
fault:
|
|
425
|
+
'is claimed by two of the packages the manifest declares, so a dependency naming it has no single answer',
|
|
426
|
+
step: (packageName) =>
|
|
427
|
+
`Give them distinct names in ${packageName}'s Package.swift. A package answers to its identity — the repository name — and to the name a deprecated \`.package(name:url:)\` gives it.`,
|
|
428
|
+
},
|
|
429
|
+
'unsupported-traits': {
|
|
430
|
+
fault: 'is declared with a trait set other than the default, which this plugin does not render',
|
|
431
|
+
step: (packageName) =>
|
|
432
|
+
`Declare it with its default traits in ${packageName}'s Package.swift. Traits select which of a package's code builds, so the generated package would build something else.`,
|
|
433
|
+
},
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
const UNKNOWN_PACKAGE_FAULT = {
|
|
437
|
+
fault: 'cannot be declared by the generated package',
|
|
438
|
+
step: (packageName) => `Declare it as a remote package in ${packageName}'s Package.swift.`,
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
function renderPackageDependencyLines({ form, identity, target }, packageName) {
|
|
442
|
+
const {
|
|
443
|
+
subject = packageSubject,
|
|
444
|
+
fault,
|
|
445
|
+
step,
|
|
446
|
+
} = Object.hasOwn(PACKAGE_DEPENDENCY_FAULTS, form)
|
|
447
|
+
? PACKAGE_DEPENDENCY_FAULTS[form]
|
|
448
|
+
: UNKNOWN_PACKAGE_FAULT;
|
|
449
|
+
return [` ${subject(identity, target)} ${fault}.`, ` ${step(packageName)}`];
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* The module's manifest declares a Swift package the generated package cannot mirror.
|
|
454
|
+
* Emitting the module without it would compile until its first import of that package,
|
|
455
|
+
* with nothing naming the manifest that declared it.
|
|
456
|
+
*/
|
|
457
|
+
function renderUnsupportedPackageDependency({ podName, packageName, moduleRoot, dependencies }) {
|
|
458
|
+
return renderBlock(
|
|
459
|
+
`error: Expo module "${packageName}" (pod ${podName}) ships a Package.swift the generated package cannot mirror, so it was skipped.`,
|
|
460
|
+
[
|
|
461
|
+
...dependencies.flatMap((dependency) =>
|
|
462
|
+
renderPackageDependencyLines(dependency, packageName)
|
|
463
|
+
),
|
|
464
|
+
`The generated package re-declares what the module's own manifest declares, so its sources compile against the same packages under Swift Package Manager as under CocoaPods.`,
|
|
465
|
+
`Adding an spm.config.json to ${packageName} is the other route: the Expo prebuild pipeline then builds the whole module into an XCFramework, resolving the module's packages as they are checked in. packages/expo-sensors is a worked example.`,
|
|
466
|
+
remedy.patchPackage(packageName),
|
|
467
|
+
],
|
|
468
|
+
moduleRoot
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function renderNeedsManifestForLinkage({ podName, packageName, moduleRoot, file, line, snippet }) {
|
|
473
|
+
return renderBlock(
|
|
474
|
+
`error: Expo module "${packageName}" (pod ${podName}) declares native linkage in its podspec, which the Swift Package Manager plugin does not read, so it was skipped.`,
|
|
475
|
+
[
|
|
476
|
+
`${file}:${line} declares it:`,
|
|
477
|
+
` ${snippet}`,
|
|
478
|
+
`A podspec is Ruby: reading it without running it means guessing, and a guessed link line does not fail here — it fails in a shipped app with a missing symbol. Swift Package Manager needs the linkage stated exactly.`,
|
|
479
|
+
`Add a Package.swift to ${packageName} declaring the module's target with \`linkerSettings: [.linkedFramework("Photos"), .linkedLibrary("sqlite3")]\` — the plugin mirrors those verbatim. Or add an spm.config.json, so the Expo prebuild pipeline builds the module into an XCFramework instead. packages/expo-constants shows the shape of a checked-in Package.swift, though it declares no linkage of its own; packages/expo-sensors is a worked spm.config.json.`,
|
|
480
|
+
remedy.patchPackage(packageName),
|
|
481
|
+
],
|
|
482
|
+
moduleRoot
|
|
483
|
+
);
|
|
285
484
|
}
|
|
286
485
|
|
|
287
486
|
/**
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
487
|
+
* Some of the module's pods resolved to prebuilt frameworks and the rest did not.
|
|
488
|
+
* Both source routes build the module whole, so emitting it would link the
|
|
489
|
+
* prebuilt pods twice — once as frameworks, once from source.
|
|
291
490
|
*/
|
|
292
|
-
function
|
|
491
|
+
function renderPartiallyPrecompiled({
|
|
293
492
|
podName,
|
|
294
493
|
packageName,
|
|
295
494
|
moduleRoot,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
495
|
+
precompiledSiblings,
|
|
496
|
+
precompiledProducts,
|
|
497
|
+
artifactDirs,
|
|
498
|
+
prebuildProduct,
|
|
300
499
|
}) {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
500
|
+
const siblings = precompiledSiblings.join(', ');
|
|
501
|
+
const one = precompiledSiblings.length === 1;
|
|
502
|
+
const artifacts = precompiledProducts
|
|
503
|
+
.map((product) => `${product}.xcframework or ${product}.tar.gz`)
|
|
504
|
+
.join(', ');
|
|
505
|
+
const sourceOnly = prebuildProduct?.sourceOnly === true;
|
|
506
|
+
const productStep =
|
|
507
|
+
prebuildProduct == null
|
|
508
|
+
? `add a product for ${podName} to ${packageName}'s spm.config.json, then build it`
|
|
509
|
+
: `build ${podName} too — ${packageName}'s spm.config.json already declares "${prebuildProduct.name}"`;
|
|
510
|
+
const precompile = [
|
|
511
|
+
`To precompile all of them, ${productStep}. Omit --flavor so both Debug and Release are built, since the plugin declares an immutable pair and rejects a half-built one:`,
|
|
512
|
+
` et prebuild ${packageName}`,
|
|
513
|
+
` Then re-run \`npx react-native spm update\`.`,
|
|
514
|
+
];
|
|
515
|
+
const remedies = [
|
|
516
|
+
...(sourceOnly ? [] : [precompile]),
|
|
517
|
+
[
|
|
518
|
+
`To build it from source instead, delete the prebuilt ${siblings} artifacts — ${artifacts}, under debug/xcframeworks and release/xcframeworks — from each directory below, then re-run \`npx react-native spm update\`. The plugin searches them in this order and uses the first one that has an artifact, so one left behind anywhere is picked up again:`,
|
|
519
|
+
...artifactDirs.map((dir) => ` ${dir}`),
|
|
520
|
+
],
|
|
521
|
+
[remedy.exclude(packageName)],
|
|
522
|
+
];
|
|
523
|
+
return renderBlock(
|
|
524
|
+
`error: Expo module "${packageName}" (pod ${podName}) has no prebuilt XCFramework, but its sibling ${one ? 'pod' : 'pods'} ${siblings} ${one ? 'does' : 'do'}, so the module cannot be built with Swift Package Manager.`,
|
|
525
|
+
[
|
|
526
|
+
`The plugin links ${siblings} as ${one ? 'a precompiled framework' : 'precompiled frameworks'}. It can build ${packageName} from source only as a whole module, every pod at once, so building ${podName} from source would link ${siblings} twice: once as ${one ? 'a framework' : 'frameworks'} and once from source.`,
|
|
527
|
+
sourceOnly
|
|
528
|
+
? `${packageName}'s spm.config.json marks ${podName} as sourceOnly, so it never gets an XCFramework and the module cannot be precompiled as a whole:`
|
|
529
|
+
: `A module must be precompiled for all of its pods or for none of them:`,
|
|
530
|
+
...remedies.flatMap(([first, ...rest], i) => [`${i + 1}. ${first}`, ...rest]),
|
|
531
|
+
],
|
|
532
|
+
moduleRoot
|
|
533
|
+
);
|
|
310
534
|
}
|
|
311
535
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
536
|
+
/**
|
|
537
|
+
* Why CocoaPods links a companion for this app, and the app-side switch that stops it,
|
|
538
|
+
* where one exists. The keys are read in `autolinkConditionMet`'s order.
|
|
539
|
+
*/
|
|
540
|
+
function companionCondition({ podName, npmPackage, podfileProperty, disabledValue } = {}) {
|
|
541
|
+
if (podName != null) return { because: `the app has the ${podName} pod` };
|
|
542
|
+
if (npmPackage != null) return { because: `the app depends on ${npmPackage}` };
|
|
543
|
+
if (podfileProperty != null) {
|
|
544
|
+
return disabledValue != null
|
|
545
|
+
? {
|
|
546
|
+
because: `the Podfile property "${podfileProperty}" is not "${disabledValue}"`,
|
|
547
|
+
turnOff: `set "${podfileProperty}" to "${disabledValue}" in ios/Podfile.properties.json`,
|
|
548
|
+
}
|
|
549
|
+
: {
|
|
550
|
+
because: `the Podfile property "${podfileProperty}" is set`,
|
|
551
|
+
turnOff: `remove "${podfileProperty}" from ios/Podfile.properties.json`,
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
return { because: 'its autolinkWhen condition is met' };
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
const linkedAsPhrase = (precompiled) =>
|
|
558
|
+
precompiled ? 'as a precompiled XCFramework' : 'from source without a checked-in Package.swift';
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* A gated pod is refused whether or not the condition is met: a link that never
|
|
562
|
+
* consults the condition is only right by coincidence, and the coincidence changes
|
|
563
|
+
* with the app's configuration. A companion (`linkedThrough`) is refused only where
|
|
564
|
+
* its module leaves it out while a Podfile property the app can switch off links it.
|
|
565
|
+
*/
|
|
566
|
+
function renderUncheckedAutolinkCondition({
|
|
567
|
+
podName,
|
|
568
|
+
packageName,
|
|
569
|
+
moduleRoot,
|
|
570
|
+
productName,
|
|
571
|
+
precompiled,
|
|
572
|
+
linkedThrough,
|
|
573
|
+
autolinkWhen,
|
|
574
|
+
}) {
|
|
575
|
+
const linkedAs = linkedAsPhrase(precompiled);
|
|
576
|
+
if (linkedThrough != null) {
|
|
577
|
+
const { because, turnOff } = companionCondition(autolinkWhen);
|
|
578
|
+
return renderBlock(
|
|
579
|
+
`error: Expo module "${packageName}" links its pod ${linkedThrough} ${linkedAs}, so its product "${productName}" would be left out of the app.`,
|
|
580
|
+
[
|
|
581
|
+
`CocoaPods links "${productName}" because ${because}. Swift Package Manager cannot link "${productName}" yet, so the sync stops instead of building the app without it.`,
|
|
582
|
+
`If the app does not need "${productName}", ${turnOff}. If ios/ is generated by npx expo prebuild, set the matching option in the module's config plugin instead.`,
|
|
583
|
+
`If the app needs "${productName}", report it at https://github.com/expo/expo/issues and include this error.`,
|
|
584
|
+
],
|
|
585
|
+
moduleRoot
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
return renderBlock(
|
|
589
|
+
`error: Expo module "${packageName}" declares an autolinkWhen condition for its product "${productName}" (pod ${podName}), but the product would be linked ${linkedAs}.`,
|
|
590
|
+
[
|
|
591
|
+
`The Swift Package Manager plugin checks autolinkWhen only for packages that ship a checked-in Package.swift. Linking "${productName}" any other way would ignore its condition, so the sync stops instead.`,
|
|
592
|
+
`Ship a checked-in Package.swift for ${packageName}, so the condition decides whether "${productName}" is linked. Or remove the ${podName} podspec from \`apple.podspecPath\` in ${packageName}'s expo-module.config.json, so the product is never linked this way. If "${productName}" should always be linked, drop its autolinkWhen from spm.config.json instead.`,
|
|
593
|
+
],
|
|
594
|
+
moduleRoot
|
|
595
|
+
);
|
|
322
596
|
}
|
|
323
597
|
|
|
324
598
|
function renderCoreUnavailable({ pods }) {
|
|
@@ -332,20 +606,42 @@ function renderCoreUnavailable({ pods }) {
|
|
|
332
606
|
].join('\n');
|
|
333
607
|
}
|
|
334
608
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
'
|
|
342
|
-
'
|
|
343
|
-
|
|
344
|
-
|
|
609
|
+
function renderDuplicatePodName({ podName, copies }) {
|
|
610
|
+
const others = copies.slice(1).map((copy) => copy.packageName);
|
|
611
|
+
return [
|
|
612
|
+
`error: The pod ${podName} is declared by ${copies.length} different packages, so none of them was linked:`,
|
|
613
|
+
...copies.map(({ packageName, moduleRoot }) => ` "${packageName}" at ${moduleRoot}`),
|
|
614
|
+
` Swift Package Manager, like CocoaPods, links a pod name only once, and these are separate copies of it — different packages in different directories — so which one the app got would depend on the order they were found in.`,
|
|
615
|
+
` Keep one of them: remove the others from your app, or exclude them in your app's package.json: ${excludeSnippet(...others)} — their native modules will then be unavailable at runtime.`,
|
|
616
|
+
].join('\n');
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Every reason the plugin refuses a pod, most specific first: a pod refused for
|
|
621
|
+
* several is reported for the first of them. `count` is how many modules one
|
|
622
|
+
* refusal stands for.
|
|
623
|
+
*/
|
|
624
|
+
const REFUSALS = new Map(
|
|
625
|
+
[
|
|
626
|
+
['duplicate-pod-name', { render: renderDuplicatePodName }],
|
|
627
|
+
['partially-precompiled', { render: renderPartiallyPrecompiled }],
|
|
628
|
+
['prebuild-available', { render: renderPrebuildAvailable }],
|
|
629
|
+
['needs-manifest-for-linkage', { render: renderNeedsManifestForLinkage }],
|
|
630
|
+
['unsupported-target-dependency', { render: renderUnsupportedTargetDependency }],
|
|
631
|
+
['unsupported-package-dependency', { render: renderUnsupportedPackageDependency }],
|
|
632
|
+
['unresolvable-target-path', { render: renderUnresolvableTargetPath }],
|
|
633
|
+
['not-exported-by-manifest', { render: renderNotExportedByManifest }],
|
|
634
|
+
['companion-not-exported-by-manifest', { render: renderCompanionNotExportedByManifest }],
|
|
635
|
+
['no-apple-sources', { render: renderNoAppleSources }],
|
|
636
|
+
['mixed-no-manifest', { render: renderMixedNoManifest }],
|
|
637
|
+
['unchecked-autolink-condition', { render: renderUncheckedAutolinkCondition }],
|
|
638
|
+
['core-unavailable', { render: renderCoreUnavailable, count: ({ pods }) => pods.length }],
|
|
639
|
+
].map(([reason, refusal], priority) => [reason, { priority, count: () => 1, ...refusal }])
|
|
640
|
+
);
|
|
345
641
|
|
|
346
642
|
/** The full report: one `error:`-prefixed block per entry. Pure. */
|
|
347
643
|
function renderUnsupportedReport(entries) {
|
|
348
|
-
return entries.map((entry) =>
|
|
644
|
+
return entries.map((entry) => REFUSALS.get(entry.reason).render(entry)).join('\n\n');
|
|
349
645
|
}
|
|
350
646
|
|
|
351
647
|
/**
|
|
@@ -360,12 +656,32 @@ function renderUnmappedDependencyWarning(entries) {
|
|
|
360
656
|
[
|
|
361
657
|
`warning: Expo module "${packageName}" (pod ${podName}) depends on ${pods.length} CocoaPods ${pods.length === 1 ? 'dependency' : 'dependencies'} with no Swift Package Manager counterpart: ${pods.join(', ')}.`,
|
|
362
658
|
` The module is in the build graph, but any source that uses one of those will fail to compile.`,
|
|
363
|
-
` Each dependency needs a SwiftPM package (or an xcframework) the module can declare. Until then, exclude "${packageName}" in your app's package.json:
|
|
659
|
+
` Each dependency needs a SwiftPM package (or an xcframework) the module can declare. Until then, exclude "${packageName}" in your app's package.json: ${excludeSnippet(packageName)}.`,
|
|
364
660
|
].join('\n')
|
|
365
661
|
)
|
|
366
662
|
.join('\n\n');
|
|
367
663
|
}
|
|
368
664
|
|
|
665
|
+
/**
|
|
666
|
+
* Gated companions left out where CocoaPods would link them. Their condition names a
|
|
667
|
+
* pod or an npm package the app installs for its own reasons, so failing the sync
|
|
668
|
+
* would block the app over a feature it may not use.
|
|
669
|
+
*/
|
|
670
|
+
function renderLeftOutCompanionWarning(entries) {
|
|
671
|
+
return entries
|
|
672
|
+
.map(({ packageName, moduleRoot, productName, precompiled, linkedThrough, autolinkWhen }) =>
|
|
673
|
+
renderBlock(
|
|
674
|
+
`warning: Expo module "${packageName}" links its pod ${linkedThrough} ${linkedAsPhrase(precompiled)}, so its product "${productName}" is left out of the app.`,
|
|
675
|
+
[
|
|
676
|
+
`CocoaPods links "${productName}" because ${companionCondition(autolinkWhen).because}. The sync continues without it, so the feature "${productName}" provides is unavailable at runtime.`,
|
|
677
|
+
`Swift Package Manager links "${productName}" only when ${packageName} is built from a checked-in Package.swift that exports it as a \`.library(name: "${productName}", …)\` product. Otherwise, if the app needs "${productName}", build the app with CocoaPods.`,
|
|
678
|
+
],
|
|
679
|
+
moduleRoot
|
|
680
|
+
)
|
|
681
|
+
)
|
|
682
|
+
.join('\n\n');
|
|
683
|
+
}
|
|
684
|
+
|
|
369
685
|
/**
|
|
370
686
|
* Modules that ARE emitted but set linker flags in their podspec xcconfig. Swift
|
|
371
687
|
* autolinks what its sources import, so these are usually redundant; when one is not,
|
|
@@ -385,6 +701,98 @@ function renderXcconfigLinkerWarning(entries) {
|
|
|
385
701
|
.join('\n\n');
|
|
386
702
|
}
|
|
387
703
|
|
|
704
|
+
/** The sync does not fail, so this warning is the only place the mismatch shows. */
|
|
705
|
+
function renderRootConflictWarning(entries) {
|
|
706
|
+
if (!entries.length) return '';
|
|
707
|
+
return entries
|
|
708
|
+
.map(({ packageName, moduleRoot, autolinkedRoot }) =>
|
|
709
|
+
[
|
|
710
|
+
`warning: Expo module "${packageName}" is installed twice, so its native code and your JavaScript can come from different copies of the package:`,
|
|
711
|
+
` built by this plugin: ${moduleRoot}`,
|
|
712
|
+
` imported by your app: ${autolinkedRoot}`,
|
|
713
|
+
` Both are real directories, not one directory reached through a symlink, so the copies can be different versions. The plugin builds the first one; your app's JavaScript imports the second. When the two disagree it usually surfaces at runtime, as a missing method or "Cannot find native module" — and two copies of different versions can fail the build instead.`,
|
|
714
|
+
` Run \`npm ls ${packageName}\` (or \`yarn why\` / \`pnpm why\`) to find what pulls in the second copy, deduplicate it with \`npm dedupe\` (or \`yarn dedupe\` / \`pnpm dedupe\`), then re-run \`npx react-native spm update\`.`,
|
|
715
|
+
].join('\n')
|
|
716
|
+
)
|
|
717
|
+
.join('\n\n');
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Packages a source module still declares after the products a precompiled framework
|
|
722
|
+
* provides were left out. Whether a kept product depends on a provided one inside the
|
|
723
|
+
* package is invisible to the plugin, so this warns rather than fails.
|
|
724
|
+
*/
|
|
725
|
+
function renderPartlyProvidedPackageWarning(entries) {
|
|
726
|
+
if (!entries.length) return '';
|
|
727
|
+
const quoted = (names, separator = ', ') => names.map((name) => `"${name}"`).join(separator);
|
|
728
|
+
return entries
|
|
729
|
+
.map((entry) => {
|
|
730
|
+
const { packageName, moduleRoot, url, providedProducts, keptProducts, keptPackages } = entry;
|
|
731
|
+
const provided = quoted(providedProducts);
|
|
732
|
+
const one = providedProducts.length === 1;
|
|
733
|
+
const fix = (used) =>
|
|
734
|
+
`If it does, stop using ${used} in "${packageName}", or build the Expo module that links the precompiled ${provided} from source too, so both use one copy of the package.`;
|
|
735
|
+
if (url == null) {
|
|
736
|
+
const packages = keptPackages.join(', ');
|
|
737
|
+
const source = keptPackages.length === 1 ? packages : `one of ${packages}`;
|
|
738
|
+
return renderBlock(
|
|
739
|
+
`warning: Expo module "${packageName}" names ${provided} without a package, and ${one ? 'it comes' : 'they come'} from a precompiled framework.`,
|
|
740
|
+
[
|
|
741
|
+
`Swift Package Manager may still build ${one ? 'it' : 'them'} from ${source}, which the module still declares, and the app would then link a second copy.`,
|
|
742
|
+
fix(packages),
|
|
743
|
+
],
|
|
744
|
+
moduleRoot
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
const unattributedNames = entry.unattributedNames ?? [];
|
|
748
|
+
const users = [...new Set([...keptProducts, ...unattributedNames])];
|
|
749
|
+
const kept = keptProducts.length ? ` for ${quoted(keptProducts)}` : '';
|
|
750
|
+
return renderBlock(
|
|
751
|
+
`warning: Expo module "${packageName}" still declares ${url}${kept}, while ${provided} ${one ? 'comes' : 'come'} from a precompiled framework.`,
|
|
752
|
+
[
|
|
753
|
+
...(unattributedNames.length
|
|
754
|
+
? [
|
|
755
|
+
`The module ${kept ? 'also ' : ''}names ${quoted(unattributedNames)} without a package, which may come from it.`,
|
|
756
|
+
]
|
|
757
|
+
: []),
|
|
758
|
+
`If ${quoted(users, ' or ')} depends on ${provided} inside that package, Swift Package Manager builds a second copy of ${one ? 'it' : 'them'} from source, and the app links both.`,
|
|
759
|
+
fix(quoted(users, ' or ')),
|
|
760
|
+
],
|
|
761
|
+
moduleRoot
|
|
762
|
+
);
|
|
763
|
+
})
|
|
764
|
+
.join('\n\n');
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// CocoaPods accepts only one ref; a pod carrying two is named by the most specific.
|
|
768
|
+
const GIT_REFS = ['commit', 'tag', 'branch'];
|
|
769
|
+
|
|
770
|
+
// A git pod is named by its ref, not a version; a local path pod by neither.
|
|
771
|
+
function extraPodOrigin(pod) {
|
|
772
|
+
const versioned = (origin) =>
|
|
773
|
+
pod.version != null ? `${origin}, version ${pod.version}` : origin;
|
|
774
|
+
if (pod.path != null) return `local path: ${pod.path}`;
|
|
775
|
+
if (pod.git != null) {
|
|
776
|
+
const ref = GIT_REFS.find((key) => pod[key] != null);
|
|
777
|
+
return ref != null ? `git: ${pod.git}, ${ref} ${pod[ref]}` : versioned(`git: ${pod.git}`);
|
|
778
|
+
}
|
|
779
|
+
if (pod.podspec != null) return versioned(`podspec: ${pod.podspec}`);
|
|
780
|
+
if (pod.source != null) return versioned(`spec repo: ${pod.source}`);
|
|
781
|
+
return versioned('published pod');
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function renderExtraPodsWarning(pods) {
|
|
785
|
+
if (!pods.length) return '';
|
|
786
|
+
const one = pods.length === 1;
|
|
787
|
+
return [
|
|
788
|
+
`warning: This app declares ${pods.length} extra CocoaPods ${one ? 'dependency' : 'dependencies'}, and the Swift Package Manager plugin does not install ${one ? 'it' : 'them'}:`,
|
|
789
|
+
...pods.map((pod) => ` ${pod.name} (${extraPodOrigin(pod)})`),
|
|
790
|
+
` ${one ? 'It comes' : 'They come'} from \`extraPods\` in your app config, which expo-build-properties writes into ios/Podfile.properties.json. The plugin reads that file — that is how ${one ? 'the pod is' : 'these pods are'} named here — but it contributes no CocoaPods dependency to the Swift Package Manager graph, whatever ${one ? 'it is' : 'they are'} installed from.`,
|
|
791
|
+
` Native code that imports ${one ? 'it' : 'one of them'} fails to compile or link. Code that reaches a pod at runtime instead — a class looked up by name, an Objective-C category, a bundled resource — builds and then fails on device, so a pod nothing imports is not necessarily unused.`,
|
|
792
|
+
` There is no Swift Package Manager route for ${one ? 'it' : 'them'} today. Add a Swift package providing the same code to your Xcode project and drop the \`extraPods\` entry, or keep this app on CocoaPods.`,
|
|
793
|
+
].join('\n');
|
|
794
|
+
}
|
|
795
|
+
|
|
388
796
|
/** Print the report and return the error to throw, or null when nothing is uncovered. */
|
|
389
797
|
function reportUnsupported(entries) {
|
|
390
798
|
if (!entries.length) return null;
|
|
@@ -393,16 +801,21 @@ function reportUnsupported(entries) {
|
|
|
393
801
|
}
|
|
394
802
|
|
|
395
803
|
module.exports = {
|
|
804
|
+
pluginError,
|
|
396
805
|
UnsupportedModulesError,
|
|
397
806
|
COVERED_POD_PREFIXES,
|
|
398
807
|
UNMAPPED_POD_ALLOWLIST,
|
|
399
808
|
classifyUnsupported,
|
|
400
|
-
spmConfigProduct,
|
|
401
|
-
podspecDependencies,
|
|
402
809
|
unmappedPodDependencies,
|
|
403
|
-
|
|
810
|
+
collectDuplicatePods,
|
|
811
|
+
collectRootConflicts,
|
|
812
|
+
realPathOrSelf,
|
|
404
813
|
renderUnsupportedReport,
|
|
405
814
|
renderUnmappedDependencyWarning,
|
|
815
|
+
renderLeftOutCompanionWarning,
|
|
406
816
|
renderXcconfigLinkerWarning,
|
|
817
|
+
renderRootConflictWarning,
|
|
818
|
+
renderPartlyProvidedPackageWarning,
|
|
819
|
+
renderExtraPodsWarning,
|
|
407
820
|
reportUnsupported,
|
|
408
821
|
};
|