expo 58.0.1 → 58.0.3
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/build/winter/runtime.native.js +0 -2
- package/build/winter/runtime.native.js.map +1 -1
- package/bundledNativeModules.json +77 -77
- 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 +17 -18
- 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__/diagnostics.test.js +705 -132
- package/scripts/spm/__tests__/manifests.test.js +1086 -75
- package/scripts/spm/__tests__/metadata.test.js +120 -0
- package/scripts/spm/__tests__/plugin.test.js +2549 -346
- package/scripts/spm/app-target.js +44 -1
- package/scripts/spm/autolink-gate.js +40 -0
- package/scripts/spm/classify.js +54 -77
- package/scripts/spm/diagnostics.js +540 -147
- package/scripts/spm/flavored-frameworks.js +80 -125
- package/scripts/spm/manifests.js +523 -205
- package/scripts/spm/metadata.js +152 -0
- package/scripts/spm/plugin.js +592 -277
- package/scripts/spm/podspec.js +56 -19
- package/src/async-require/__tests__/loadBundle.test.ios.ts +2 -2
- package/src/winter/__tests__/{TextDecoderStream.test.ios.ts → TextDecoderStream.test.native.ts} +23 -2
- package/src/winter/runtime.native.ts +0 -2
- package/template.tgz +0 -0
- package/build/winter/TextDecoder.d.ts +0 -13
- package/build/winter/TextDecoder.js +0 -357
- package/build/winter/TextDecoder.js.map +0 -1
- package/src/winter/TextDecoder.ts +0 -427
- package/src/winter/__tests__/TextDecoder.test.native.ts +0 -549
|
@@ -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,51 +71,25 @@ class UnsupportedModulesError extends Error {
|
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
/**
|
|
70
|
-
* Why each uncovered pod is uncovered
|
|
71
|
-
*
|
|
72
|
-
*
|
|
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.
|
|
73
81
|
*/
|
|
74
82
|
function classifyUnsupported({ pending, coreAvailable }) {
|
|
75
83
|
if (!pending.length) return [];
|
|
76
84
|
if (!coreAvailable) {
|
|
77
85
|
return [{ reason: 'core-unavailable', pods: pending.map((p) => p.podName) }];
|
|
78
86
|
}
|
|
79
|
-
return pending.map((
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (p.podspecLinkage != null) {
|
|
86
|
-
const { file, line, snippet } = p.podspecLinkage;
|
|
87
|
-
return { reason: 'needs-manifest-for-linkage', ...subject, file, line, snippet };
|
|
88
|
-
}
|
|
89
|
-
if (p.unsupportedTargetDeps?.length) {
|
|
90
|
-
return {
|
|
91
|
-
reason: 'unsupported-target-dependency',
|
|
92
|
-
...subject,
|
|
93
|
-
dependencies: p.unsupportedTargetDeps,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
if (p.unresolvedTargets?.length) {
|
|
97
|
-
return { reason: 'unresolvable-target-path', ...subject, targetNames: p.unresolvedTargets };
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
reason: p.hasSources === false ? 'no-apple-sources' : 'mixed-no-manifest',
|
|
101
|
-
...subject,
|
|
102
|
-
productName: p.prebuildProduct?.name ?? null,
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** Pod names a podspec depends on, ignoring `test_spec` blocks. Text-only. */
|
|
108
|
-
function podspecDependencies(text) {
|
|
109
|
-
const deps = [];
|
|
110
|
-
for (const { text: line } of podspecBodyLines(text)) {
|
|
111
|
-
const match = line.match(/\.dependency\s+['"]([^'"]+)['"]/);
|
|
112
|
-
if (match) deps.push(match[1]);
|
|
113
|
-
}
|
|
114
|
-
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));
|
|
115
93
|
}
|
|
116
94
|
|
|
117
95
|
/**
|
|
@@ -129,27 +107,6 @@ function unmappedPodDependencies(deps, satisfied = new Set()) {
|
|
|
129
107
|
);
|
|
130
108
|
}
|
|
131
109
|
|
|
132
|
-
/** Pods outside the SwiftPM graph that `podspecDir`'s podspecs depend on. */
|
|
133
|
-
function collectUnmappedDependencies(podspecDir, satisfied) {
|
|
134
|
-
let entries = [];
|
|
135
|
-
try {
|
|
136
|
-
entries = fs.readdirSync(podspecDir).filter((f) => f.endsWith('.podspec'));
|
|
137
|
-
} catch {
|
|
138
|
-
return [];
|
|
139
|
-
}
|
|
140
|
-
const deps = new Set();
|
|
141
|
-
for (const name of entries) {
|
|
142
|
-
let text = '';
|
|
143
|
-
try {
|
|
144
|
-
text = fs.readFileSync(path.join(podspecDir, name), 'utf8');
|
|
145
|
-
} catch {
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
unmappedPodDependencies(podspecDependencies(text), satisfied).forEach((d) => deps.add(d));
|
|
149
|
-
}
|
|
150
|
-
return [...deps];
|
|
151
|
-
}
|
|
152
|
-
|
|
153
110
|
/**
|
|
154
111
|
* Two paths that name different real directories. A path that cannot be resolved
|
|
155
112
|
* — a broken symlink, an unreadable parent — counts as no difference: a symlinked
|
|
@@ -164,17 +121,12 @@ function resolveToDifferentDirectories(left, right) {
|
|
|
164
121
|
}
|
|
165
122
|
|
|
166
123
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* copy the app's JavaScript does not import.
|
|
170
|
-
* — the routine pnpm and monorepo case — is not a conflict.
|
|
171
|
-
*
|
|
172
|
-
* @param identities every pod's identity, from `plugin.js#resolvePodIdentities`.
|
|
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.
|
|
173
127
|
*/
|
|
174
128
|
function collectRootConflicts(identities) {
|
|
175
129
|
const conflicts = new Map();
|
|
176
|
-
// A root is resolved per POD, so the module conflicts as soon as ANY pod
|
|
177
|
-
// documents another copy, not only the first pod that documents one.
|
|
178
130
|
for (const { packageName, documentedRoot, autolinkedRoot } of identities.values()) {
|
|
179
131
|
if (conflicts.has(packageName) || documentedRoot == null || autolinkedRoot == null) continue;
|
|
180
132
|
if (resolveToDifferentDirectories(documentedRoot, autolinkedRoot)) {
|
|
@@ -184,17 +136,95 @@ function collectRootConflicts(identities) {
|
|
|
184
136
|
return [...conflicts.values()];
|
|
185
137
|
}
|
|
186
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) }]);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
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;
|
|
196
|
+
}
|
|
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');
|
|
213
|
+
}
|
|
214
|
+
|
|
187
215
|
function renderMixedNoManifest({ podName, packageName, moduleRoot }) {
|
|
188
|
-
return
|
|
216
|
+
return renderBlock(
|
|
189
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.`,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
+
);
|
|
198
228
|
}
|
|
199
229
|
|
|
200
230
|
/**
|
|
@@ -203,34 +233,84 @@ function renderMixedNoManifest({ podName, packageName, moduleRoot }) {
|
|
|
203
233
|
* both flavors are mandatory because the plugin declares immutable pairs.
|
|
204
234
|
*/
|
|
205
235
|
function renderPrebuildAvailable({ podName, packageName, moduleRoot, productName }) {
|
|
206
|
-
return
|
|
236
|
+
return renderBlock(
|
|
207
237
|
`error: Expo module "${packageName}" (pod ${podName}) has no prebuilt XCFramework, so it is not in the Swift Package Manager graph.`,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
+
);
|
|
214
246
|
}
|
|
215
247
|
|
|
216
248
|
function renderNoAppleSources({ podName, packageName, moduleRoot }) {
|
|
217
|
-
return
|
|
249
|
+
return renderBlock(
|
|
218
250
|
`error: Expo module "${packageName}" (pod ${podName}) has no \`ios\` or \`apple\` source directory, so Swift Package Manager has nothing to compile.`,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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
|
+
);
|
|
223
257
|
}
|
|
224
258
|
|
|
225
259
|
function renderUnresolvableTargetPath({ podName, packageName, moduleRoot, targetNames }) {
|
|
226
260
|
const quoted = targetNames.map((n) => `"${n}"`).join(', ');
|
|
227
261
|
const plural = targetNames.length === 1 ? 'target' : 'targets';
|
|
228
|
-
return
|
|
262
|
+
return renderBlock(
|
|
229
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.`,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
+
);
|
|
234
314
|
}
|
|
235
315
|
|
|
236
316
|
// Map, not an object: the kind comes from a dumped manifest, and an inherited key like
|
|
@@ -257,29 +337,262 @@ function renderUnsupportedTargetDependency({ podName, packageName, moduleRoot, d
|
|
|
257
337
|
dependencies.length === 1
|
|
258
338
|
? 'whose source target depends on a target'
|
|
259
339
|
: 'whose source targets depend on targets';
|
|
260
|
-
return
|
|
340
|
+
return renderBlock(
|
|
261
341
|
`error: Expo module "${packageName}" (pod ${podName}) ships a Package.swift ${wiring} the generated package cannot declare, so it was skipped.`,
|
|
262
|
-
|
|
263
|
-
(
|
|
264
|
-
|
|
265
|
-
)
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
+
);
|
|
271
470
|
}
|
|
272
471
|
|
|
273
472
|
function renderNeedsManifestForLinkage({ podName, packageName, moduleRoot, file, line, snippet }) {
|
|
274
|
-
return
|
|
473
|
+
return renderBlock(
|
|
275
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.`,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
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
|
+
);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
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.
|
|
490
|
+
*/
|
|
491
|
+
function renderPartiallyPrecompiled({
|
|
492
|
+
podName,
|
|
493
|
+
packageName,
|
|
494
|
+
moduleRoot,
|
|
495
|
+
precompiledSiblings,
|
|
496
|
+
precompiledProducts,
|
|
497
|
+
artifactDirs,
|
|
498
|
+
prebuildProduct,
|
|
499
|
+
}) {
|
|
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
|
+
);
|
|
534
|
+
}
|
|
535
|
+
|
|
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
|
+
);
|
|
283
596
|
}
|
|
284
597
|
|
|
285
598
|
function renderCoreUnavailable({ pods }) {
|
|
@@ -293,19 +606,42 @@ function renderCoreUnavailable({ pods }) {
|
|
|
293
606
|
].join('\n');
|
|
294
607
|
}
|
|
295
608
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
'
|
|
303
|
-
'
|
|
304
|
-
}
|
|
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
|
+
);
|
|
305
641
|
|
|
306
642
|
/** The full report: one `error:`-prefixed block per entry. Pure. */
|
|
307
643
|
function renderUnsupportedReport(entries) {
|
|
308
|
-
return entries.map((entry) =>
|
|
644
|
+
return entries.map((entry) => REFUSALS.get(entry.reason).render(entry)).join('\n\n');
|
|
309
645
|
}
|
|
310
646
|
|
|
311
647
|
/**
|
|
@@ -320,12 +656,32 @@ function renderUnmappedDependencyWarning(entries) {
|
|
|
320
656
|
[
|
|
321
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(', ')}.`,
|
|
322
658
|
` The module is in the build graph, but any source that uses one of those will fail to compile.`,
|
|
323
|
-
` 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)}.`,
|
|
324
660
|
].join('\n')
|
|
325
661
|
)
|
|
326
662
|
.join('\n\n');
|
|
327
663
|
}
|
|
328
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
|
+
|
|
329
685
|
/**
|
|
330
686
|
* Modules that ARE emitted but set linker flags in their podspec xcconfig. Swift
|
|
331
687
|
* autolinks what its sources import, so these are usually redundant; when one is not,
|
|
@@ -345,11 +701,7 @@ function renderXcconfigLinkerWarning(entries) {
|
|
|
345
701
|
.join('\n\n');
|
|
346
702
|
}
|
|
347
703
|
|
|
348
|
-
/**
|
|
349
|
-
* Two installed copies of one module. The sync does not fail: the plugin builds
|
|
350
|
-
* one copy while the app imports the other, so the warning is the only place the
|
|
351
|
-
* mismatch is visible.
|
|
352
|
-
*/
|
|
704
|
+
/** The sync does not fail, so this warning is the only place the mismatch shows. */
|
|
353
705
|
function renderRootConflictWarning(entries) {
|
|
354
706
|
if (!entries.length) return '';
|
|
355
707
|
return entries
|
|
@@ -365,13 +717,57 @@ function renderRootConflictWarning(entries) {
|
|
|
365
717
|
.join('\n\n');
|
|
366
718
|
}
|
|
367
719
|
|
|
368
|
-
|
|
369
|
-
|
|
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.
|
|
370
768
|
const GIT_REFS = ['commit', 'tag', 'branch'];
|
|
371
769
|
|
|
372
|
-
// A pod
|
|
373
|
-
// identified by its ref rather than a version, and a local path pod by neither:
|
|
374
|
-
// CocoaPods takes that directory as it is.
|
|
770
|
+
// A git pod is named by its ref, not a version; a local path pod by neither.
|
|
375
771
|
function extraPodOrigin(pod) {
|
|
376
772
|
const versioned = (origin) =>
|
|
377
773
|
pod.version != null ? `${origin}, version ${pod.version}` : origin;
|
|
@@ -385,12 +781,6 @@ function extraPodOrigin(pod) {
|
|
|
385
781
|
return versioned('published pod');
|
|
386
782
|
}
|
|
387
783
|
|
|
388
|
-
/**
|
|
389
|
-
* Pods the app adds for CocoaPods — `extraPods` in its config, which
|
|
390
|
-
* expo-build-properties writes into Podfile.properties.json. `pod install`
|
|
391
|
-
* installs them and this plugin does not, so this names them before the compile,
|
|
392
|
-
* link or runtime failure that would otherwise be their first sign.
|
|
393
|
-
*/
|
|
394
784
|
function renderExtraPodsWarning(pods) {
|
|
395
785
|
if (!pods.length) return '';
|
|
396
786
|
const one = pods.length === 1;
|
|
@@ -411,18 +801,21 @@ function reportUnsupported(entries) {
|
|
|
411
801
|
}
|
|
412
802
|
|
|
413
803
|
module.exports = {
|
|
804
|
+
pluginError,
|
|
414
805
|
UnsupportedModulesError,
|
|
415
806
|
COVERED_POD_PREFIXES,
|
|
416
807
|
UNMAPPED_POD_ALLOWLIST,
|
|
417
808
|
classifyUnsupported,
|
|
418
|
-
podspecDependencies,
|
|
419
809
|
unmappedPodDependencies,
|
|
420
|
-
|
|
810
|
+
collectDuplicatePods,
|
|
421
811
|
collectRootConflicts,
|
|
812
|
+
realPathOrSelf,
|
|
422
813
|
renderUnsupportedReport,
|
|
423
814
|
renderUnmappedDependencyWarning,
|
|
815
|
+
renderLeftOutCompanionWarning,
|
|
424
816
|
renderXcconfigLinkerWarning,
|
|
425
817
|
renderRootConflictWarning,
|
|
818
|
+
renderPartlyProvidedPackageWarning,
|
|
426
819
|
renderExtraPodsWarning,
|
|
427
820
|
reportUnsupported,
|
|
428
821
|
};
|