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
package/scripts/spm/manifests.js
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
|
-
const { appleSourceDir,
|
|
12
|
+
const { appleSourceDir, scanAppleSources } = require('./classify');
|
|
13
13
|
const { reactProductDependencies, reactPackageDeclarations } = require('./react-descriptor');
|
|
14
14
|
const { runDumpPackage } = require('./cli');
|
|
15
|
+
const { pluginError } = require('./diagnostics');
|
|
15
16
|
|
|
16
17
|
// ---------------------------------------------------------------------------
|
|
17
18
|
// Pure: parse `swift package dump-package` JSON → { name, products, targets }
|
|
@@ -19,8 +20,7 @@ const { runDumpPackage } = require('./cli');
|
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* A same-package target dependency: the bare target name, or `{ name, platforms }`
|
|
22
|
-
* when the manifest conditions it.
|
|
23
|
-
* deps — the injected React set covers those.
|
|
23
|
+
* when the manifest conditions it.
|
|
24
24
|
*/
|
|
25
25
|
function siblingDependency(dep) {
|
|
26
26
|
const [name, condition] = dep.byName ?? dep.target ?? [];
|
|
@@ -32,14 +32,239 @@ function siblingDependency(dep) {
|
|
|
32
32
|
const siblingName = (dep) => (typeof dep === 'string' ? dep : dep.name);
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
35
|
+
* The version a dumped source-control dependency is pinned at, or null when it names
|
|
36
|
+
* no form the generated package can declare. `.package(url:from:)` arrives here as a
|
|
37
|
+
* range — `dump-package` has already widened it — so there is no `from:` form to read.
|
|
37
38
|
*/
|
|
38
|
-
function
|
|
39
|
+
function packageRequirement(requirement) {
|
|
40
|
+
const [form, values] = Object.entries(requirement ?? {})[0] ?? [];
|
|
41
|
+
if (form === 'range') {
|
|
42
|
+
const { lowerBound, upperBound } = values?.[0] ?? {};
|
|
43
|
+
return lowerBound != null && upperBound != null
|
|
44
|
+
? { kind: 'range', lowerBound, upperBound }
|
|
45
|
+
: null;
|
|
46
|
+
}
|
|
47
|
+
if (form === 'exact' || form === 'branch' || form === 'revision') {
|
|
48
|
+
return typeof values?.[0] === 'string' ? { kind: form, value: values[0] } : null;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A prebuilt-metadata `spmPackages` entry in the shape a dumped manifest's packages
|
|
55
|
+
* take, `{ identity, url, requirement }`, plus the product the module links from it.
|
|
56
|
+
* The document publishes exactly one string requirement per entry, so its only key
|
|
57
|
+
* is the requirement's kind.
|
|
58
|
+
*/
|
|
59
|
+
function documentedPackage({ url, productName, version }) {
|
|
60
|
+
const [[kind, value]] = Object.entries(version);
|
|
61
|
+
return { identity: spmPackageIdentity({ url }), url, requirement: { kind, value }, productName };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Whether a trait set is anything but the default one every dumped dependency carries. */
|
|
65
|
+
function hasNonDefaultTraits(traits) {
|
|
66
|
+
if (traits == null) return false;
|
|
67
|
+
return traits.length !== 1 || traits[0]?.name !== 'default';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The packages the generated manifest mirrors, keyed by every name a target dependency
|
|
72
|
+
* may resolve them by, plus one entry per package it cannot declare. A dropped package
|
|
73
|
+
* is invisible until the module's first `import` of it, so every form this cannot
|
|
74
|
+
* render is collected rather than skipped.
|
|
75
|
+
*/
|
|
76
|
+
function parsePackageDependencies(dependencies, injectedNames) {
|
|
77
|
+
const packageDeps = [];
|
|
78
|
+
const packagesByName = new Map();
|
|
79
|
+
const unsupported = [];
|
|
80
|
+
// SwiftPM resolves a package by identity or `.package(name:)` name, case-insensitively; a
|
|
81
|
+
// reported package answers to both, so a target dependency on it joins that report.
|
|
82
|
+
const reportedByName = new Map();
|
|
83
|
+
const report = (form, identity, ...otherNames) => {
|
|
84
|
+
const entry = { form, identity: identity ?? null, target: null };
|
|
85
|
+
unsupported.push(entry);
|
|
86
|
+
for (const name of [identity, ...otherNames]) {
|
|
87
|
+
if (typeof name !== 'string' || reportedByName.has(name.toLowerCase())) continue;
|
|
88
|
+
reportedByName.set(name.toLowerCase(), entry);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
for (const dependency of dependencies ?? []) {
|
|
92
|
+
const [form, declarations] = Object.entries(dependency ?? {})[0] ?? [];
|
|
93
|
+
const declared = declarations?.[0] ?? {};
|
|
94
|
+
const reportDeclared = (fault) =>
|
|
95
|
+
report(fault, declared.identity, declared.nameForTargetDependencyResolutionOnly);
|
|
96
|
+
if (form === 'sourceControl') {
|
|
97
|
+
const url = declared.location?.remote?.[0]?.urlString;
|
|
98
|
+
const requirement = url != null ? packageRequirement(declared.requirement) : null;
|
|
99
|
+
if (url == null) {
|
|
100
|
+
reportDeclared('unsupported-location');
|
|
101
|
+
} else if (requirement == null) {
|
|
102
|
+
reportDeclared('unsupported-requirement');
|
|
103
|
+
} else {
|
|
104
|
+
// Traits select which of a package's code builds, and this renders none of them,
|
|
105
|
+
// so a non-default set would build something other than the module declared.
|
|
106
|
+
if (hasNonDefaultTraits(declared.traits)) report('unsupported-traits', declared.identity);
|
|
107
|
+
const pkg = { identity: declared.identity ?? null, url, requirement };
|
|
108
|
+
packageDeps.push(pkg);
|
|
109
|
+
for (const name of [declared.identity, declared.nameForTargetDependencyResolutionOnly]) {
|
|
110
|
+
if (typeof name !== 'string') continue;
|
|
111
|
+
// Two packages answering to one name would resolve to whichever was declared
|
|
112
|
+
// last — a silent choice between two different dependencies.
|
|
113
|
+
if ((packagesByName.get(name.toLowerCase()) ?? pkg) !== pkg) {
|
|
114
|
+
report('ambiguous-package-name', name);
|
|
115
|
+
}
|
|
116
|
+
packagesByName.set(name.toLowerCase(), pkg);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} else if (form === 'fileSystem') {
|
|
120
|
+
// Mirroring one would mean rewriting its path against the `root` symlink, which
|
|
121
|
+
// this plugin does not do.
|
|
122
|
+
reportDeclared('local-path');
|
|
123
|
+
} else if (form === 'registry') {
|
|
124
|
+
reportDeclared('registry');
|
|
125
|
+
} else {
|
|
126
|
+
reportDeclared('unknown-form');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// SwiftPM refuses a graph where two packages resolve to one identity, so a mirrored
|
|
130
|
+
// package may not take a name the injected declarations already occupy.
|
|
131
|
+
const injected = new Set(injectedNames.map((name) => name.toLowerCase()));
|
|
132
|
+
for (const { identity } of packageDeps) {
|
|
133
|
+
if (identity != null && injected.has(identity.toLowerCase())) {
|
|
134
|
+
report('collides-with-injected', identity);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return { packageDeps, packagesByName, reportedByName, unsupportedPackageDeps: unsupported };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Identities the injected RN declarations occupy (mirrors react-descriptor.js); a path
|
|
142
|
+
* package answers to its dir name and its `name:`.
|
|
143
|
+
*/
|
|
144
|
+
function injectedPackageNames(react) {
|
|
145
|
+
if (react == null) return [];
|
|
146
|
+
const ref = react.packageRef;
|
|
147
|
+
return [
|
|
148
|
+
ref.name,
|
|
149
|
+
ref.url != null ? spmPackageIdentity(ref) : null,
|
|
150
|
+
ref.path != null ? path.basename(ref.path) : null,
|
|
151
|
+
...react.products.map((p) => p.package),
|
|
152
|
+
].filter((name) => typeof name === 'string');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const hasEntries = (value) => value != null && Object.keys(value).length > 0;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Whether a target-dependency condition sets anything this renderer does not carry.
|
|
159
|
+
* Swift tools 6.1 added traits to it, and a condition rendered without them would
|
|
160
|
+
* apply the dependency more widely than the module declared.
|
|
161
|
+
*/
|
|
162
|
+
function unrenderableCondition(condition) {
|
|
163
|
+
return Object.entries(condition ?? {}).some(
|
|
164
|
+
([key, value]) =>
|
|
165
|
+
key !== 'platformNames' && value != null && (!Array.isArray(value) || value.length > 0)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Why a `.product` dependency cannot be mirrored, or null when it can. */
|
|
170
|
+
function productFault(declaredPackage, moduleAliases, condition) {
|
|
171
|
+
if (declaredPackage == null) return 'undeclared-package';
|
|
172
|
+
// An alias renames a dependency's modules. Rendering the dependency without it would
|
|
173
|
+
// leave the module importing a name nothing declares, or reintroduce the duplicate
|
|
174
|
+
// module name the alias exists to resolve.
|
|
175
|
+
if (hasEntries(moduleAliases)) return 'module-aliases';
|
|
176
|
+
if (unrenderableCondition(condition)) return 'unsupported-condition';
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The name a mirrored `.product` must give its package. The mirrored declaration carries
|
|
182
|
+
* no `name:`, so a dependency that named the package by a deprecated `.package(name:)`
|
|
183
|
+
* has to name the identity instead; a name that differs only in case resolves as written.
|
|
184
|
+
*/
|
|
185
|
+
function resolvablePackageName(written, declaredPackage) {
|
|
186
|
+
const { identity } = declaredPackage;
|
|
187
|
+
return identity != null && identity.toLowerCase() !== written.toLowerCase() ? identity : written;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Keep only regular targets and library products; resolve each target's dependencies
|
|
192
|
+
* against the targets and packages this package declares, in their declared order, and
|
|
193
|
+
* collect everything the generated package cannot re-declare.
|
|
194
|
+
*/
|
|
195
|
+
function parseDumpedManifest(json, injectedNames = []) {
|
|
39
196
|
const pkg = JSON.parse(json);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
197
|
+
const { packageDeps, packagesByName, reportedByName, unsupportedPackageDeps } =
|
|
198
|
+
parsePackageDependencies(pkg.dependencies, injectedNames);
|
|
199
|
+
const declaredTargets = pkg.targets ?? [];
|
|
200
|
+
const declaredKinds = new Map(declaredTargets.map((t) => [t.name, t.type]));
|
|
201
|
+
const regular = declaredTargets.filter((t) => t.type === 'regular');
|
|
202
|
+
const regularNames = new Set(regular.map((t) => t.name));
|
|
203
|
+
const unsupportedTargetDeps = [];
|
|
204
|
+
// The PRODUCT names the mirrored targets take from those packages. Dependency
|
|
205
|
+
// diagnostics match a pod name against these — `libavif/libdav1d` is covered by the
|
|
206
|
+
// `libavif` product, whatever the package it ships in is called.
|
|
207
|
+
const spmProductNames = [];
|
|
208
|
+
|
|
209
|
+
const targets = regular.map((t) => {
|
|
210
|
+
const dependencies = [];
|
|
211
|
+
for (const dep of t.dependencies ?? []) {
|
|
212
|
+
if (dep.product != null) {
|
|
213
|
+
const [name, packageName, moduleAliases, condition] = dep.product;
|
|
214
|
+
const declaredPackage =
|
|
215
|
+
packageName != null ? (packagesByName.get(packageName.toLowerCase()) ?? null) : null;
|
|
216
|
+
const fault = productFault(declaredPackage, moduleAliases, condition);
|
|
217
|
+
if (fault != null) {
|
|
218
|
+
// Already reported under its declaration; attach the target there.
|
|
219
|
+
const reported = reportedByName.get((packageName ?? '').toLowerCase());
|
|
220
|
+
if (fault === 'undeclared-package' && reported != null) reported.target ??= t.name;
|
|
221
|
+
else {
|
|
222
|
+
unsupportedPackageDeps.push({
|
|
223
|
+
form: fault,
|
|
224
|
+
identity: packageName ?? null,
|
|
225
|
+
target: t.name,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
dependencies.push({
|
|
231
|
+
product: name,
|
|
232
|
+
package: resolvablePackageName(packageName, declaredPackage),
|
|
233
|
+
platforms: condition?.platformNames ?? [],
|
|
234
|
+
});
|
|
235
|
+
spmProductNames.push(name);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const sibling = siblingDependency(dep);
|
|
239
|
+
if (sibling == null) continue;
|
|
240
|
+
const name = siblingName(sibling);
|
|
241
|
+
if (unrenderableCondition((dep.byName ?? dep.target)[1])) {
|
|
242
|
+
unsupportedPackageDeps.push({
|
|
243
|
+
form: 'unsupported-target-condition',
|
|
244
|
+
identity: name,
|
|
245
|
+
target: t.name,
|
|
246
|
+
});
|
|
247
|
+
} else if (regularNames.has(name)) {
|
|
248
|
+
dependencies.push(sibling);
|
|
249
|
+
} else if (declaredKinds.has(name)) {
|
|
250
|
+
// Only regular targets are mirrored, so a dependency on a target of any other
|
|
251
|
+
// kind names a target the generated package does not declare. Dropping it
|
|
252
|
+
// silently ends in an undefined symbol at link time, so it is collected.
|
|
253
|
+
unsupportedTargetDeps.push({
|
|
254
|
+
target: t.name,
|
|
255
|
+
dependsOn: name,
|
|
256
|
+
kind: declaredKinds.get(name),
|
|
257
|
+
});
|
|
258
|
+
} else if (dep.byName != null) {
|
|
259
|
+
// Resolves against the declared packages' PRODUCTS, which a dump does not list;
|
|
260
|
+
// rendered verbatim, SwiftPM names it if it resolves to nothing.
|
|
261
|
+
dependencies.push(
|
|
262
|
+
typeof sibling === 'string' ? name : { byName: name, platforms: sibling.platforms }
|
|
263
|
+
);
|
|
264
|
+
spmProductNames.push(name);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
43
268
|
name: t.name,
|
|
44
269
|
// An omitted `path:` is resolved against the filesystem by the emit layer.
|
|
45
270
|
path: t.path ?? null,
|
|
@@ -48,33 +273,26 @@ function parseDumpedManifest(json) {
|
|
|
48
273
|
sources: t.sources ?? [],
|
|
49
274
|
resources: t.resources ?? [],
|
|
50
275
|
settings: t.settings ?? [],
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// Only regular targets are mirrored, so a dependency on a target of any other kind
|
|
56
|
-
// would name a target the generated package does not declare.
|
|
57
|
-
const targets = regular.map((t) => ({
|
|
58
|
-
...t,
|
|
59
|
-
siblingDeps: t.siblingDeps.filter((d) => regularNames.has(siblingName(d))),
|
|
60
|
-
}));
|
|
61
|
-
// Dropping such a dependency silently ends in an undefined symbol at link time, so it
|
|
62
|
-
// is collected and reported. A name that is NO target of this package is a product of
|
|
63
|
-
// a dependency package — `.byName` resolves to that too — and is correctly dropped.
|
|
64
|
-
const declaredKinds = new Map((pkg.targets ?? []).map((t) => [t.name, t.type]));
|
|
65
|
-
const unsupportedTargetDeps = regular.flatMap((t) =>
|
|
66
|
-
t.siblingDeps
|
|
67
|
-
.map(siblingName)
|
|
68
|
-
.filter((name) => !regularNames.has(name) && declaredKinds.has(name))
|
|
69
|
-
.map((name) => ({ target: t.name, dependsOn: name, kind: declaredKinds.get(name) }))
|
|
70
|
-
);
|
|
276
|
+
dependencies,
|
|
277
|
+
};
|
|
278
|
+
});
|
|
279
|
+
|
|
71
280
|
const products = (pkg.products ?? [])
|
|
72
281
|
.filter((p) => Object.keys(p.type ?? {})[0] === 'library')
|
|
73
282
|
.map((p) => ({ name: p.name, targets: (p.targets ?? []).filter((n) => regularNames.has(n)) }))
|
|
74
283
|
.filter((p) => p.targets.length);
|
|
75
284
|
const iosDeploymentTarget =
|
|
76
285
|
(pkg.platforms ?? []).find((p) => p.platformName === 'ios')?.version ?? null;
|
|
77
|
-
return {
|
|
286
|
+
return {
|
|
287
|
+
name: pkg.name,
|
|
288
|
+
iosDeploymentTarget,
|
|
289
|
+
products,
|
|
290
|
+
targets,
|
|
291
|
+
packageDeps,
|
|
292
|
+
spmProductNames: [...new Set(spmProductNames)],
|
|
293
|
+
unsupportedTargetDeps,
|
|
294
|
+
unsupportedPackageDeps,
|
|
295
|
+
};
|
|
78
296
|
}
|
|
79
297
|
|
|
80
298
|
// ---------------------------------------------------------------------------
|
|
@@ -108,26 +326,36 @@ const SWIFT_PLATFORM_CASES = new Map([
|
|
|
108
326
|
function swiftPlatformCases(names, context) {
|
|
109
327
|
const declared = (names ?? []).map((p) => SWIFT_PLATFORM_CASES.get(p)).filter((p) => p != null);
|
|
110
328
|
if (declared.length === 0 && (names ?? []).length > 0) {
|
|
111
|
-
throw
|
|
112
|
-
`Cannot generate a consumption Package.swift for ${context}: its platform condition names only `
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
'platform Swift Package Manager supports.'
|
|
117
|
-
);
|
|
329
|
+
throw pluginError({
|
|
330
|
+
what: `Cannot generate a consumption Package.swift for ${context}: its platform condition names only ${names.map((n) => `"${n}"`).join(', ')}, which PackageDescription 6.0 does not declare.`,
|
|
331
|
+
why: 'Dropping the condition would apply the declaration on every platform, wider than the module declared.',
|
|
332
|
+
how: 'Add the platform to SWIFT_PLATFORM_CASES in expo/scripts/spm/manifests.js, or condition the declaration on a platform Swift Package Manager supports.',
|
|
333
|
+
});
|
|
118
334
|
}
|
|
119
335
|
return declared;
|
|
120
336
|
}
|
|
121
337
|
|
|
338
|
+
/** SwiftPM allows only `platforms:` in a target-dependency condition. */
|
|
339
|
+
function renderPlatformCondition(platforms, context) {
|
|
340
|
+
const cases = swiftPlatformCases(platforms, context);
|
|
341
|
+
return cases.length ? `, condition: .when(platforms: [${cases.join(', ')}])` : '';
|
|
342
|
+
}
|
|
343
|
+
|
|
122
344
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
345
|
+
* One target dependency — a sibling target, a mirrored package's product, or a
|
|
346
|
+
* `.byName` the module wrote against one of its packages — conditioned on platforms
|
|
347
|
+
* when the module declared it so.
|
|
125
348
|
*/
|
|
126
|
-
function
|
|
127
|
-
if (typeof dep === 'string') return `"${dep}"`;
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
349
|
+
function renderTargetDependency(dep) {
|
|
350
|
+
if (typeof dep === 'string') return `"${escapeSwiftString(dep)}"`;
|
|
351
|
+
const kind = dep.product != null ? 'product' : dep.byName != null ? 'byName' : 'target';
|
|
352
|
+
const dependsOn = dep.product ?? dep.byName ?? dep.name;
|
|
353
|
+
const condition = renderPlatformCondition(dep.platforms, `the dependency on "${dependsOn}"`);
|
|
354
|
+
const name = escapeSwiftString(dependsOn);
|
|
355
|
+
if (kind === 'product') {
|
|
356
|
+
return `.product(name: "${name}", package: "${escapeSwiftString(dep.package)}"${condition})`;
|
|
357
|
+
}
|
|
358
|
+
return condition ? `.${kind}(name: "${name}"${condition})` : `"${name}"`;
|
|
131
359
|
}
|
|
132
360
|
|
|
133
361
|
const RESOURCE_RULES = new Map([
|
|
@@ -151,12 +379,11 @@ function renderResource(resource, targetName) {
|
|
|
151
379
|
const localization =
|
|
152
380
|
options?.localization != null ? RESOURCE_LOCALIZATIONS.get(options.localization) : null;
|
|
153
381
|
if (call == null || (options?.localization != null && localization == null)) {
|
|
154
|
-
throw
|
|
155
|
-
`Cannot generate a consumption Package.swift for target "${targetName}": resource "${resource.path}"
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
382
|
+
throw pluginError({
|
|
383
|
+
what: `Cannot generate a consumption Package.swift for target "${targetName}": resource "${resource.path}" uses the unsupported rule \`${JSON.stringify(resource.rule)}\`.`,
|
|
384
|
+
why: 'This plugin renders .process, .copy and .embedInCode with .default/.base localizations; a newer Swift Package Manager rule needs support added in expo/scripts/spm/manifests.js.',
|
|
385
|
+
how: 'Declare the resource with one of the supported rules meanwhile.',
|
|
386
|
+
});
|
|
160
387
|
}
|
|
161
388
|
return localization != null
|
|
162
389
|
? `${call}("${resource.path}", localization: ${localization})`
|
|
@@ -191,10 +418,9 @@ const INTEROPERABILITY_MODES = new Map([
|
|
|
191
418
|
]);
|
|
192
419
|
|
|
193
420
|
function settingError(targetName, setting, explanation) {
|
|
194
|
-
return
|
|
195
|
-
`Cannot generate a consumption Package.swift for target "${targetName}": build setting
|
|
196
|
-
|
|
197
|
-
);
|
|
421
|
+
return pluginError({
|
|
422
|
+
what: `Cannot generate a consumption Package.swift for target "${targetName}": build setting \`${JSON.stringify(setting.kind)}\` ${explanation}`,
|
|
423
|
+
});
|
|
198
424
|
}
|
|
199
425
|
|
|
200
426
|
/**
|
|
@@ -303,7 +529,10 @@ function renderFileRules(target) {
|
|
|
303
529
|
);
|
|
304
530
|
}
|
|
305
531
|
|
|
306
|
-
/**
|
|
532
|
+
/**
|
|
533
|
+
* Mirror a manifest's targets, products and packages — a checked-in one as
|
|
534
|
+
* `parseDumpedManifest` read it, or a `pureSwiftManifest` — and inject the given deps.
|
|
535
|
+
*/
|
|
307
536
|
function renderSourceManifest({
|
|
308
537
|
manifest,
|
|
309
538
|
pkgDeps = [],
|
|
@@ -314,13 +543,13 @@ function renderSourceManifest({
|
|
|
314
543
|
const targetsSwift = manifest.targets
|
|
315
544
|
.map((t) => {
|
|
316
545
|
if (t.path == null) {
|
|
317
|
-
throw
|
|
318
|
-
`Cannot generate a consumption Package.swift for "${manifest.name}": target "${t.name}" has no source path
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
);
|
|
546
|
+
throw pluginError({
|
|
547
|
+
what: `Cannot generate a consumption Package.swift for "${manifest.name}": target "${t.name}" has no source path.`,
|
|
548
|
+
why: "Its path was neither declared in the module's manifest nor resolved on disk, so the generated target would point at nothing.",
|
|
549
|
+
how: 'Resolve target paths with resolveTargetPaths before rendering.',
|
|
550
|
+
});
|
|
322
551
|
}
|
|
323
|
-
const deps = [...t.
|
|
552
|
+
const deps = [...t.dependencies.map(renderTargetDependency), ...injectedTargetDeps];
|
|
324
553
|
const depsSwift = deps.length
|
|
325
554
|
? `\n${deps.map((dep) => ` ${dep},`).join('\n')}\n `
|
|
326
555
|
: '';
|
|
@@ -341,14 +570,19 @@ function renderSourceManifest({
|
|
|
341
570
|
` .library(name: "${p.name}", targets: [${p.targets.map((n) => `"${n}"`).join(', ')}])`
|
|
342
571
|
)
|
|
343
572
|
.join(',\n');
|
|
344
|
-
const
|
|
345
|
-
|
|
573
|
+
const declarations = [...pkgDeps, ...(manifest.packageDeps ?? []).map(packageDeclaration)];
|
|
574
|
+
const packageDepsSwift = declarations.length
|
|
575
|
+
? `\n${declarations.map((dep) => ` ${dep},`).join('\n')}\n `
|
|
346
576
|
: '';
|
|
347
577
|
|
|
578
|
+
const origin = manifest.pureSwift
|
|
579
|
+
? `// Pure-Swift source consumption package for "${manifest.name}".`
|
|
580
|
+
: `// Source consumption package for "${manifest.name}": mirrors the module's checked-in
|
|
581
|
+
// Package.swift targets and injects invariant React compile dependencies.`;
|
|
582
|
+
|
|
348
583
|
return `// swift-tools-version: 6.0
|
|
349
584
|
// AUTO-GENERATED by expo/scripts/spm/plugin.js — do not edit.
|
|
350
|
-
|
|
351
|
-
// Package.swift targets and injects invariant React compile dependencies.
|
|
585
|
+
${origin}
|
|
352
586
|
import PackageDescription
|
|
353
587
|
|
|
354
588
|
let package = Package(
|
|
@@ -371,58 +605,73 @@ ${targetsSwift}
|
|
|
371
605
|
const PRIVACY_MANIFEST = 'PrivacyInfo.xcprivacy';
|
|
372
606
|
|
|
373
607
|
/**
|
|
374
|
-
*
|
|
375
|
-
*
|
|
608
|
+
* The identity SwiftPM resolves a package URL to: its last path component, without
|
|
609
|
+
* trailing slashes or a `.git` suffix. It is the repository name, which differs
|
|
610
|
+
* from the product where a repository ships one under another name, as
|
|
611
|
+
* `libavif-Xcode` ships `libavif`.
|
|
376
612
|
*/
|
|
377
|
-
function
|
|
613
|
+
function spmPackageIdentity(pkg) {
|
|
614
|
+
return pkg.url
|
|
615
|
+
.replace(/\/+$/, '')
|
|
616
|
+
.split('/')
|
|
617
|
+
.pop()
|
|
618
|
+
.replace(/\.git$/, '');
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* `.package(url:)` for a package a checked-in manifest declares or one from
|
|
623
|
+
* `documentedPackage`. Only a dumped package has a range, and only a documented one
|
|
624
|
+
* has `from`, which `dump-package` widens into a range.
|
|
625
|
+
*/
|
|
626
|
+
function packageDeclaration({ url, requirement }) {
|
|
627
|
+
const quoted = (value) => `"${escapeSwiftString(value)}"`;
|
|
628
|
+
const pin =
|
|
629
|
+
requirement.kind === 'range'
|
|
630
|
+
? `${quoted(requirement.lowerBound)}..<${quoted(requirement.upperBound)}`
|
|
631
|
+
: `${requirement.kind}: ${quoted(requirement.value)}`;
|
|
632
|
+
return `.package(url: ${quoted(url)}, ${pin})`;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* A pure-Swift module as the manifest `renderSourceManifest` mirrors: one Swift target
|
|
637
|
+
* over its `ios`/`apple` sources, depending on the product of each documented package.
|
|
638
|
+
*
|
|
639
|
+
* @param packages `documentedPackage` entries.
|
|
640
|
+
*/
|
|
641
|
+
function pureSwiftManifest({
|
|
378
642
|
product,
|
|
379
643
|
srcRel,
|
|
380
|
-
pkgDeps = [],
|
|
381
|
-
targetDeps = [],
|
|
382
|
-
frameworkSearchPath,
|
|
383
644
|
excludes = [],
|
|
384
645
|
iosDeploymentTarget = null,
|
|
385
646
|
hasPrivacyManifest = false,
|
|
386
|
-
|
|
647
|
+
packages = [],
|
|
387
648
|
}) {
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
:
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
:
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
:
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
name:
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
dependencies: [${packageDepsSwift}],
|
|
415
|
-
targets: [
|
|
416
|
-
.target(
|
|
417
|
-
name: "${product}",
|
|
418
|
-
dependencies: [${targetDepsSwift}],
|
|
419
|
-
path: "root/${srcRel}",${excludeSwift}${resourcesSwift}${renderTargetSettings(frameworkSearchPath, [], product, extraSwiftFlags)}
|
|
420
|
-
),
|
|
421
|
-
],
|
|
422
|
-
swiftLanguageModes: [.v5],
|
|
423
|
-
cxxLanguageStandard: .cxx20
|
|
424
|
-
)
|
|
425
|
-
`;
|
|
649
|
+
const target = {
|
|
650
|
+
name: product,
|
|
651
|
+
path: srcRel,
|
|
652
|
+
publicHeadersPath: null,
|
|
653
|
+
// SwiftPM resolves exclude paths against the target path, not the package root.
|
|
654
|
+
exclude: excludes,
|
|
655
|
+
sources: [],
|
|
656
|
+
// `.copy`, not `.process`: Apple reads a privacy manifest by its exact name, and
|
|
657
|
+
// .process may rename or transform what it puts in the bundle.
|
|
658
|
+
resources: hasPrivacyManifest ? [{ path: PRIVACY_MANIFEST, rule: { copy: {} } }] : [],
|
|
659
|
+
settings: [],
|
|
660
|
+
dependencies: packages.map((pkg) => ({
|
|
661
|
+
product: pkg.productName,
|
|
662
|
+
package: pkg.identity,
|
|
663
|
+
platforms: [],
|
|
664
|
+
})),
|
|
665
|
+
};
|
|
666
|
+
return {
|
|
667
|
+
name: product,
|
|
668
|
+
pureSwift: true,
|
|
669
|
+
iosDeploymentTarget,
|
|
670
|
+
products: [{ name: product, targets: [product] }],
|
|
671
|
+
targets: [target],
|
|
672
|
+
packageDeps: packages,
|
|
673
|
+
spmProductNames: packages.map((pkg) => pkg.productName),
|
|
674
|
+
};
|
|
426
675
|
}
|
|
427
676
|
|
|
428
677
|
function escapeSwiftString(value) {
|
|
@@ -441,12 +690,10 @@ function renderTargetSettings(frameworkSearchPath, settings, targetName, extraSw
|
|
|
441
690
|
const swiftInterfaceFlags = unsafeFlags(['-F', frameworkSearchPath, ...extraSwiftFlags]);
|
|
442
691
|
for (const setting of settings ?? []) {
|
|
443
692
|
if (!SETTING_TOOLS.has(setting.tool)) {
|
|
444
|
-
throw
|
|
445
|
-
`Cannot generate a consumption Package.swift for target "${targetName}": build setting tool
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
'expo/scripts/spm/manifests.js.'
|
|
449
|
-
);
|
|
693
|
+
throw pluginError({
|
|
694
|
+
what: `Cannot generate a consumption Package.swift for target "${targetName}": build setting tool "${setting.tool}" has no arguments to be rendered into.`,
|
|
695
|
+
why: 'This plugin renders the c, cxx, swift and linker tools; a newer Swift Package Manager tool needs a family added in expo/scripts/spm/manifests.js.',
|
|
696
|
+
});
|
|
450
697
|
}
|
|
451
698
|
}
|
|
452
699
|
return SETTING_FAMILIES.map(([tool, label]) => {
|
|
@@ -540,13 +787,117 @@ function resolveTargetPaths(targets, moduleRoot) {
|
|
|
540
787
|
return { targets: resolved, unresolvedTargets };
|
|
541
788
|
}
|
|
542
789
|
|
|
543
|
-
/**
|
|
544
|
-
|
|
790
|
+
/**
|
|
791
|
+
* A precompiled framework already links these products; declaring them again would
|
|
792
|
+
* link a second copy. `spmProductNames` still names them, as the module links them
|
|
793
|
+
* all the same. SwiftPM can still build a provided product through a package kept for
|
|
794
|
+
* its other products, so `partlyProvidedPackages` returns each such package and, once,
|
|
795
|
+
* every package kept while the module named a provided product without a package.
|
|
796
|
+
*/
|
|
797
|
+
function withoutSatisfiedProducts(manifest, satisfiedDependencies) {
|
|
798
|
+
const targetNames = new Set(manifest.targets.map((t) => t.name));
|
|
799
|
+
// A byName that names no sibling target resolves to a product of a declared package.
|
|
800
|
+
const bareProductName = (dep) => {
|
|
801
|
+
const name = typeof dep === 'string' ? dep : dep.byName;
|
|
802
|
+
return name != null && !targetNames.has(name) ? name : null;
|
|
803
|
+
};
|
|
804
|
+
const isSatisfied = (dep) => satisfiedDependencies.has(dep.product ?? bareProductName(dep));
|
|
805
|
+
const skipped = manifest.targets.flatMap((t) => t.dependencies).filter(isSatisfied);
|
|
806
|
+
if (skipped.length === 0) return { manifest, partlyProvidedPackages: [] };
|
|
807
|
+
const targets = manifest.targets.map((t) => ({
|
|
808
|
+
...t,
|
|
809
|
+
dependencies: t.dependencies.filter((dep) => !isSatisfied(dep)),
|
|
810
|
+
}));
|
|
811
|
+
const remaining = targets.flatMap((t) => t.dependencies);
|
|
812
|
+
const unique = (names) => [...new Set(names)];
|
|
813
|
+
const productsFrom = (deps, key) =>
|
|
814
|
+
unique(
|
|
815
|
+
deps
|
|
816
|
+
.filter((dep) => dep.product != null && dep.package.toLowerCase() === key)
|
|
817
|
+
.map((dep) => dep.product)
|
|
818
|
+
);
|
|
819
|
+
const bareNamesIn = (deps) => unique(deps.map(bareProductName).filter((name) => name != null));
|
|
820
|
+
// Which package a bare name comes from is unknown: a skipped one may have been any
|
|
821
|
+
// package's last use, and a remaining one may still use any of them.
|
|
822
|
+
const skippedBareNames = bareNamesIn(skipped);
|
|
823
|
+
const remainingBareNames = bareNamesIn(remaining);
|
|
824
|
+
const packageDeps = [];
|
|
825
|
+
const partlyProvidedPackages = [];
|
|
826
|
+
for (const pkg of manifest.packageDeps) {
|
|
827
|
+
const key = pkg.identity?.toLowerCase();
|
|
828
|
+
const providedProducts = key != null ? productsFrom(skipped, key) : [];
|
|
829
|
+
const lost = key != null && (providedProducts.length > 0 || skippedBareNames.length > 0);
|
|
830
|
+
const keptProducts = productsFrom(remaining, key);
|
|
831
|
+
if (lost && !keptProducts.length && !remainingBareNames.length) continue;
|
|
832
|
+
packageDeps.push(pkg);
|
|
833
|
+
if (providedProducts.length) {
|
|
834
|
+
partlyProvidedPackages.push({
|
|
835
|
+
url: pkg.url,
|
|
836
|
+
providedProducts,
|
|
837
|
+
keptProducts,
|
|
838
|
+
...(remainingBareNames.length > 0 ? { unattributedNames: remainingBareNames } : {}),
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
if (skippedBareNames.length && packageDeps.length) {
|
|
843
|
+
partlyProvidedPackages.push({
|
|
844
|
+
providedProducts: skippedBareNames,
|
|
845
|
+
keptPackages: packageDeps.map((pkg) => pkg.url),
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
return { manifest: { ...manifest, targets, packageDeps }, partlyProvidedPackages };
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Render `manifest` against Expo's binary-free framework interface tree, with RN's
|
|
853
|
+
* invariant React products injected and its floor raised to the minimum, and write it
|
|
854
|
+
* to `<outDir>/expo-source/<name>` beside a `root` symlink to the real module source,
|
|
855
|
+
* so target `path:`s resolve to real files. Returns what React Native links from it.
|
|
856
|
+
*/
|
|
857
|
+
function emitPackage(
|
|
858
|
+
manifest,
|
|
859
|
+
moduleRoot,
|
|
860
|
+
{
|
|
861
|
+
react = null,
|
|
862
|
+
frameworkSearchPath,
|
|
863
|
+
outDir,
|
|
864
|
+
codegenPkgPath = null,
|
|
865
|
+
minimumIosDeploymentTarget = null,
|
|
866
|
+
macroFlags = [],
|
|
867
|
+
satisfiedDependencies = new Set(),
|
|
868
|
+
}
|
|
869
|
+
) {
|
|
870
|
+
const { targetDeps, pkgDeps } = sourceDependencies(react, codegenPkgPath);
|
|
871
|
+
const { manifest: linked, partlyProvidedPackages } = withoutSatisfiedProducts(
|
|
872
|
+
manifest,
|
|
873
|
+
satisfiedDependencies
|
|
874
|
+
);
|
|
875
|
+
const manifestSwift = renderSourceManifest({
|
|
876
|
+
manifest: {
|
|
877
|
+
...linked,
|
|
878
|
+
iosDeploymentTarget: raiseFloor(manifest.iosDeploymentTarget, minimumIosDeploymentTarget),
|
|
879
|
+
},
|
|
880
|
+
pkgDeps,
|
|
881
|
+
injectedTargetDeps: targetDeps,
|
|
882
|
+
frameworkSearchPath,
|
|
883
|
+
extraSwiftFlags: macroFlags,
|
|
884
|
+
});
|
|
885
|
+
const pkgDir = path.join(outDir, 'expo-source', manifest.name);
|
|
886
|
+
fs.mkdirSync(pkgDir, { recursive: true });
|
|
545
887
|
const rootLink = path.join(pkgDir, 'root');
|
|
546
888
|
try {
|
|
547
889
|
fs.rmSync(rootLink, { recursive: true, force: true });
|
|
548
890
|
} catch {}
|
|
549
891
|
fs.symlinkSync(moduleRoot, rootLink);
|
|
892
|
+
fs.writeFileSync(path.join(pkgDir, 'Package.swift'), manifestSwift);
|
|
893
|
+
return {
|
|
894
|
+
ok: {
|
|
895
|
+
packageDep: { name: manifest.name, path: pkgDir },
|
|
896
|
+
productDeps: manifest.products.map((p) => ({ name: p.name, package: manifest.name })),
|
|
897
|
+
spmProductNames: manifest.spmProductNames,
|
|
898
|
+
partlyProvidedPackages,
|
|
899
|
+
},
|
|
900
|
+
};
|
|
550
901
|
}
|
|
551
902
|
|
|
552
903
|
/**
|
|
@@ -563,107 +914,74 @@ function sourceDependencies(react, codegenPkgPath) {
|
|
|
563
914
|
}
|
|
564
915
|
|
|
565
916
|
/**
|
|
566
|
-
* Emit a CONSUMPTION Package.swift for a source module that ships a
|
|
567
|
-
*
|
|
568
|
-
*
|
|
569
|
-
* compilation at Expo's binary-free framework interface tree. RN owns the merge;
|
|
570
|
-
* the checked-in manifest stays for standalone dev/describe.
|
|
917
|
+
* Emit a CONSUMPTION Package.swift for a source module that ships a checked-in
|
|
918
|
+
* Package.swift, re-declaring its library targets. RN owns the merge; the checked-in
|
|
919
|
+
* manifest stays for standalone dev/describe.
|
|
571
920
|
*
|
|
572
|
-
* Returns `{
|
|
573
|
-
*
|
|
574
|
-
* sources cannot be located — the module is then skipped and
|
|
575
|
-
* emitted broken.
|
|
921
|
+
* Returns `{ ok }` with the emitted package, or `{ refusal }` when the manifest
|
|
922
|
+
* depends on a target or declares a Swift package the generated package cannot
|
|
923
|
+
* declare, or a target's sources cannot be located — the module is then skipped and
|
|
924
|
+
* diagnosed rather than emitted broken.
|
|
576
925
|
*/
|
|
577
|
-
function emitSourceManifestPackage({
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
outDir,
|
|
582
|
-
codegenPkgPath = null,
|
|
583
|
-
minimumIosDeploymentTarget = null,
|
|
584
|
-
macroFlags = [],
|
|
585
|
-
}) {
|
|
586
|
-
const { unsupportedTargetDeps, ...dumped } = parseDumpedManifest(runDumpPackage(moduleRoot));
|
|
587
|
-
if (unsupportedTargetDeps.length) return { unsupportedTargetDeps };
|
|
588
|
-
const { targets, unresolvedTargets } = resolveTargetPaths(dumped.targets, moduleRoot);
|
|
589
|
-
if (unresolvedTargets.length) return { unresolvedTargets };
|
|
590
|
-
const manifest = {
|
|
591
|
-
...dumped,
|
|
592
|
-
targets,
|
|
593
|
-
iosDeploymentTarget: raiseFloor(dumped.iosDeploymentTarget, minimumIosDeploymentTarget),
|
|
594
|
-
};
|
|
595
|
-
const pkgDir = path.join(outDir, 'expo-source', manifest.name);
|
|
596
|
-
fs.mkdirSync(pkgDir, { recursive: true });
|
|
597
|
-
linkRoot(pkgDir, moduleRoot);
|
|
598
|
-
|
|
599
|
-
const { targetDeps, pkgDeps } = sourceDependencies(react, codegenPkgPath);
|
|
600
|
-
fs.writeFileSync(
|
|
601
|
-
path.join(pkgDir, 'Package.swift'),
|
|
602
|
-
renderSourceManifest({
|
|
603
|
-
manifest,
|
|
604
|
-
pkgDeps,
|
|
605
|
-
injectedTargetDeps: targetDeps,
|
|
606
|
-
frameworkSearchPath,
|
|
607
|
-
extraSwiftFlags: macroFlags,
|
|
608
|
-
})
|
|
926
|
+
function emitSourceManifestPackage(moduleRoot, emitContext) {
|
|
927
|
+
const { unsupportedTargetDeps, unsupportedPackageDeps, ...dumped } = parseDumpedManifest(
|
|
928
|
+
runDumpPackage(moduleRoot),
|
|
929
|
+
injectedPackageNames(emitContext.react)
|
|
609
930
|
);
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
931
|
+
if (unsupportedTargetDeps.length) {
|
|
932
|
+
return {
|
|
933
|
+
refusal: { reason: 'unsupported-target-dependency', dependencies: unsupportedTargetDeps },
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
if (unsupportedPackageDeps.length) {
|
|
937
|
+
return {
|
|
938
|
+
refusal: { reason: 'unsupported-package-dependency', dependencies: unsupportedPackageDeps },
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
const { targets, unresolvedTargets } = resolveTargetPaths(dumped.targets, moduleRoot);
|
|
942
|
+
if (unresolvedTargets.length) {
|
|
943
|
+
return { refusal: { reason: 'unresolvable-target-path', targetNames: unresolvedTargets } };
|
|
944
|
+
}
|
|
945
|
+
return emitPackage({ ...dumped, targets }, moduleRoot, emitContext);
|
|
615
946
|
}
|
|
616
947
|
|
|
617
948
|
/**
|
|
618
|
-
* Emit a source consumption package for a module WITHOUT a checked-in
|
|
619
|
-
*
|
|
620
|
-
*
|
|
621
|
-
*
|
|
949
|
+
* Emit a source consumption package for a pure-Swift module WITHOUT a checked-in
|
|
950
|
+
* Package.swift: `pureSwiftManifest` over the module's `ios` or `apple` sources.
|
|
951
|
+
*
|
|
952
|
+
* Returns `{ ok }` with the emitted package. The module must have Apple sources;
|
|
953
|
+
* `plugin.js#emitSourceModule` checks that first.
|
|
622
954
|
*/
|
|
623
|
-
function emitPureSwiftSourcePackage(
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
955
|
+
function emitPureSwiftSourcePackage(
|
|
956
|
+
{
|
|
957
|
+
moduleRoot,
|
|
958
|
+
product,
|
|
959
|
+
iosDeploymentTarget = null,
|
|
960
|
+
spmPackages = [],
|
|
961
|
+
sources = scanAppleSources(moduleRoot),
|
|
962
|
+
},
|
|
963
|
+
emitContext
|
|
964
|
+
) {
|
|
633
965
|
const srcDir = appleSourceDir(moduleRoot);
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
renderPureSwiftManifest({
|
|
644
|
-
product,
|
|
645
|
-
srcRel,
|
|
646
|
-
pkgDeps,
|
|
647
|
-
targetDeps,
|
|
648
|
-
frameworkSearchPath,
|
|
649
|
-
excludes: collectIgnoredDirs(srcDir),
|
|
650
|
-
iosDeploymentTarget,
|
|
651
|
-
hasPrivacyManifest: fs.existsSync(path.join(srcDir, PRIVACY_MANIFEST)),
|
|
652
|
-
extraSwiftFlags: macroFlags,
|
|
653
|
-
})
|
|
654
|
-
);
|
|
655
|
-
|
|
656
|
-
return {
|
|
657
|
-
packageDep: { name: product, path: pkgDir },
|
|
658
|
-
productDep: { name: product, package: product },
|
|
659
|
-
};
|
|
966
|
+
const manifest = pureSwiftManifest({
|
|
967
|
+
product,
|
|
968
|
+
srcRel: path.relative(moduleRoot, srcDir),
|
|
969
|
+
excludes: sources.ignoredDirs,
|
|
970
|
+
iosDeploymentTarget,
|
|
971
|
+
hasPrivacyManifest: fs.existsSync(path.join(srcDir, PRIVACY_MANIFEST)),
|
|
972
|
+
packages: spmPackages.map(documentedPackage),
|
|
973
|
+
});
|
|
974
|
+
return emitPackage(manifest, moduleRoot, emitContext);
|
|
660
975
|
}
|
|
661
976
|
|
|
662
977
|
module.exports = {
|
|
663
978
|
parseDumpedManifest,
|
|
664
979
|
resolveTargetPaths,
|
|
665
980
|
renderSourceManifest,
|
|
666
|
-
|
|
981
|
+
pureSwiftManifest,
|
|
982
|
+
spmPackageIdentity,
|
|
983
|
+
documentedPackage,
|
|
984
|
+
packageDeclaration,
|
|
667
985
|
raiseFloor,
|
|
668
986
|
emitSourceManifestPackage,
|
|
669
987
|
emitPureSwiftSourcePackage,
|