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
|
@@ -4,15 +4,9 @@ const fs = require('fs');
|
|
|
4
4
|
const os = require('os');
|
|
5
5
|
const path = require('path');
|
|
6
6
|
|
|
7
|
-
const {
|
|
8
|
-
linkageDeclaration,
|
|
9
|
-
xcconfigLinkerFlags,
|
|
10
|
-
readIosFloor,
|
|
11
|
-
readPodspecs,
|
|
12
|
-
PodspecSyntaxError,
|
|
13
|
-
} = require('../podspec');
|
|
7
|
+
const { linkageDeclaration, xcconfigLinkerFlags, readPodspecs } = require('../podspec');
|
|
14
8
|
|
|
15
|
-
const spec = (
|
|
9
|
+
const { spec } = require('./helpers');
|
|
16
10
|
|
|
17
11
|
describe('linkageDeclaration', () => {
|
|
18
12
|
it.each([
|
|
@@ -53,85 +47,6 @@ describe('linkageDeclaration', () => {
|
|
|
53
47
|
});
|
|
54
48
|
});
|
|
55
49
|
|
|
56
|
-
describe('readIosFloor', () => {
|
|
57
|
-
const FILE = '/m/ios/ExpoThing.podspec';
|
|
58
|
-
const read = (...body) => readIosFloor(spec(...body), FILE);
|
|
59
|
-
const rejected = (...body) => {
|
|
60
|
-
let error = null;
|
|
61
|
-
try {
|
|
62
|
-
read(...body);
|
|
63
|
-
} catch (thrown) {
|
|
64
|
-
error = thrown;
|
|
65
|
-
}
|
|
66
|
-
expect(error).toBeInstanceOf(PodspecSyntaxError);
|
|
67
|
-
expect(error.file).toBe(FILE);
|
|
68
|
-
return error;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
it('reads the platforms hash, on one line or several', () => {
|
|
72
|
-
expect(read(" s.platforms = { :ios => '16.4', :osx => '13.4' }")).toBe('16.4');
|
|
73
|
-
expect(read(' s.platforms = {', " :ios => '16.4',", " :osx => '13.4'", ' }')).toBe(
|
|
74
|
-
'16.4'
|
|
75
|
-
);
|
|
76
|
-
expect(read(' s.platforms = { :ios => "16.4" } # the floor')).toBe('16.4');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('reads a single-line ios deployment target', () => {
|
|
80
|
-
expect(read(" s.ios.deployment_target = '16.4'")).toBe('16.4');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('takes the higher of the two forms, whichever comes first', () => {
|
|
84
|
-
expect(read(" s.platforms = { :ios => '15.1' }", " s.ios.deployment_target = '16.4'")).toBe(
|
|
85
|
-
'16.4'
|
|
86
|
-
);
|
|
87
|
-
expect(read(" s.ios.deployment_target = '15.1'", " s.platforms = { :ios => '16.4' }")).toBe(
|
|
88
|
-
'16.4'
|
|
89
|
-
);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('reads a CRLF podspec exactly like an LF one', () => {
|
|
93
|
-
const text = spec(' s.platforms = {', " :ios => '16.4'", ' }');
|
|
94
|
-
expect(readIosFloor(text.replace(/\n/g, '\r\n'), FILE)).toBe(readIosFloor(text, FILE));
|
|
95
|
-
expect(readIosFloor(text.replace(/\n/g, '\r\n'), FILE)).toBe('16.4');
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('returns no floor when the podspec declares none, or names other platforms only', () => {
|
|
99
|
-
expect(read(" s.source_files = 'ios/**/*.swift'")).toBeNull();
|
|
100
|
-
expect(read(" s.platforms = { :osx => '13.4' }")).toBeNull();
|
|
101
|
-
expect(read(" s.osx.deployment_target = '13.4'")).toBeNull();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it.each([
|
|
105
|
-
['a merged hash', " s.platforms = { :ios => '16.4' }.merge(EXTRA)"],
|
|
106
|
-
['a frozen hash', " s.platforms = { :ios => '16.4' }.freeze"],
|
|
107
|
-
['a hash built from a variable', ' s.platforms = PLATFORMS'],
|
|
108
|
-
['an interpolated version', ' s.platforms = { :ios => "#{MIN_IOS}" }'],
|
|
109
|
-
['a version held in a variable', ' s.platforms = { :ios => min_ios }'],
|
|
110
|
-
['a non-version value', " s.platforms = { :ios => 'sixteen' }"],
|
|
111
|
-
['a hash that never closes', ' s.platforms = { :ios =>'],
|
|
112
|
-
['an interpolated deployment target', ' s.ios.deployment_target = "#{MIN_IOS}"'],
|
|
113
|
-
['a computed deployment target', ' s.ios.deployment_target = min_ios'],
|
|
114
|
-
])('refuses %s', (_name, line) => {
|
|
115
|
-
expect(rejected(line).line).toBe(2);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('refuses two `:ios` keys in one hash', () => {
|
|
119
|
-
expect(rejected(" s.platforms = { :ios => '15.1', :ios => '16.4' }").line).toBe(2);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('refuses a second platforms statement, whose winner depends on evaluation order', () => {
|
|
123
|
-
expect(
|
|
124
|
-
rejected(" s.platforms = { :ios => '15.1' }", " s.platforms = { :ios => '16.4' }").line
|
|
125
|
-
).toBe(3);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('names the offending line in the error', () => {
|
|
129
|
-
const error = rejected(" s.platforms = { :ios => '16.4' }.freeze");
|
|
130
|
-
expect(error.snippet).toBe("s.platforms = { :ios => '16.4' }.freeze");
|
|
131
|
-
expect(error.message).toContain(`${FILE}:2`);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
50
|
describe('readPodspecs', () => {
|
|
136
51
|
const write = (dir, files) => {
|
|
137
52
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -149,20 +64,20 @@ describe('readPodspecs', () => {
|
|
|
149
64
|
'ExpoCamera.podspec': spec(" s.platforms = { :ios => '16.4' }"),
|
|
150
65
|
});
|
|
151
66
|
|
|
152
|
-
expect(readPodspecs('ExpoCamera', [dir])).toEqual({
|
|
153
|
-
linkage: null,
|
|
154
|
-
linkerFlags: null,
|
|
155
|
-
iosDeploymentTarget: '16.4',
|
|
156
|
-
});
|
|
67
|
+
expect(readPodspecs('ExpoCamera', [dir])).toEqual({ linkage: null, linkerFlags: null });
|
|
157
68
|
});
|
|
158
69
|
|
|
159
70
|
it('falls back to every podspec in the directories when none carries the pod name', () => {
|
|
160
71
|
const dir = write(path.join(tmp(), 'ios'), {
|
|
161
|
-
'Legacy.podspec': spec(" s.
|
|
162
|
-
'Other.podspec': spec(" s.
|
|
72
|
+
'Legacy.podspec': spec(" s.summary = 'Carries nothing the reader looks for'"),
|
|
73
|
+
'Other.podspec': spec(" s.frameworks = 'Photos'"),
|
|
163
74
|
});
|
|
164
75
|
|
|
165
|
-
expect(readPodspecs('ExpoCamera', [dir]).
|
|
76
|
+
expect(readPodspecs('ExpoCamera', [dir]).linkage).toEqual({
|
|
77
|
+
file: path.join(dir, 'Other.podspec'),
|
|
78
|
+
line: 2,
|
|
79
|
+
snippet: "s.frameworks = 'Photos'",
|
|
80
|
+
});
|
|
166
81
|
});
|
|
167
82
|
|
|
168
83
|
it('reports the linkage declaration with the file it came from', () => {
|
|
@@ -180,19 +95,27 @@ describe('readPodspecs', () => {
|
|
|
180
95
|
});
|
|
181
96
|
});
|
|
182
97
|
|
|
183
|
-
it('reports linkage without reading the floor, so one fix at a time is enough', () => {
|
|
184
|
-
const dir = write(path.join(tmp(), 'ios'), {
|
|
185
|
-
'ExpoThing.podspec': spec(' s.platforms = PLATFORMS', " s.frameworks = 'Photos'"),
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
expect(readPodspecs('ExpoThing', [dir]).linkage).not.toBeNull();
|
|
189
|
-
});
|
|
190
|
-
|
|
191
98
|
it('declares nothing for a module with no podspec at all', () => {
|
|
192
99
|
expect(readPodspecs('ExpoThing', ['/nonexistent'])).toEqual({
|
|
193
100
|
linkage: null,
|
|
194
101
|
linkerFlags: null,
|
|
195
|
-
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('reports linker flags from the second podspec when the first carries none', () => {
|
|
106
|
+
const dir = write(path.join(tmp(), 'ios'), {
|
|
107
|
+
'Legacy.podspec': spec(" s.summary = 'Carries nothing the reader looks for'"),
|
|
108
|
+
'Other.podspec': spec(
|
|
109
|
+
' s.pod_target_xcconfig = {',
|
|
110
|
+
" 'OTHER_LDFLAGS' => '$(inherited) -lc++'",
|
|
111
|
+
' }'
|
|
112
|
+
),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
expect(readPodspecs('ExpoCamera', [dir]).linkerFlags).toEqual({
|
|
116
|
+
file: path.join(dir, 'Other.podspec'),
|
|
117
|
+
line: 3,
|
|
118
|
+
snippet: "'OTHER_LDFLAGS' => '$(inherited) -lc++'",
|
|
196
119
|
});
|
|
197
120
|
});
|
|
198
121
|
|
|
@@ -286,24 +209,6 @@ describe('test_spec blocks', () => {
|
|
|
286
209
|
).toBeNull();
|
|
287
210
|
});
|
|
288
211
|
|
|
289
|
-
// The shape of packages/expo-dev-menu: a literal floor, and a test_spec that sets
|
|
290
|
-
// its own platforms. The second `platforms` is the test spec's, not a competitor.
|
|
291
|
-
it("reads the module's floor past a test_spec that sets its own platforms", () => {
|
|
292
|
-
expect(
|
|
293
|
-
readIosFloor(
|
|
294
|
-
spec(
|
|
295
|
-
" s.platforms = { :ios => '16.4', :tvos => '16.4' }",
|
|
296
|
-
" s.test_spec 'Tests' do |test_spec|",
|
|
297
|
-
' test_spec.platforms = {',
|
|
298
|
-
" :ios => '16.4'",
|
|
299
|
-
' }',
|
|
300
|
-
' end'
|
|
301
|
-
),
|
|
302
|
-
'/m/ios/ExpoDevMenu.podspec'
|
|
303
|
-
)
|
|
304
|
-
).toBe('16.4');
|
|
305
|
-
});
|
|
306
|
-
|
|
307
212
|
it.each([
|
|
308
213
|
['a linker flag', ' ts.pod_target_xcconfig = { "OTHER_LDFLAGS" => "-Wl,--end-group" }'],
|
|
309
214
|
['prose', ' ts.summary = "start to end here"'],
|
|
@@ -331,22 +236,6 @@ describe('test_spec blocks', () => {
|
|
|
331
236
|
});
|
|
332
237
|
|
|
333
238
|
describe('a `#` inside a quoted string', () => {
|
|
334
|
-
const FILE = '/m/ios/ExpoThing.podspec';
|
|
335
|
-
|
|
336
|
-
it('refuses an interpolated floor as interpolation, quoting the line intact', () => {
|
|
337
|
-
const line = ' s.platforms = { :ios => "#{MIN_IOS}" }';
|
|
338
|
-
let error = null;
|
|
339
|
-
try {
|
|
340
|
-
readIosFloor(spec(line), FILE);
|
|
341
|
-
} catch (thrown) {
|
|
342
|
-
error = thrown;
|
|
343
|
-
}
|
|
344
|
-
expect(error).toBeInstanceOf(PodspecSyntaxError);
|
|
345
|
-
expect(error.snippet).toBe(line.trim());
|
|
346
|
-
expect(error.reason).toMatch(/interpolation/);
|
|
347
|
-
expect(error.reason).not.toMatch(/never closed/);
|
|
348
|
-
});
|
|
349
|
-
|
|
350
239
|
it('quotes an interpolated linkage declaration intact', () => {
|
|
351
240
|
expect(linkageDeclaration(spec(' s.frameworks = "#{prefix}Kit"'))).toEqual({
|
|
352
241
|
number: 2,
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Every path here is virtual. The resolver searches the monorepo's own prebuild
|
|
7
|
+
* output, so a suite that touched the real filesystem would resolve whatever the
|
|
8
|
+
* developer last built — and would have to write into the repository to cover
|
|
9
|
+
* that base at all. `fs` is mocked instead, over paths this file declares.
|
|
10
|
+
*
|
|
11
|
+
* `plutil` is macOS-only, so `child_process` is mocked too; the fixtures store
|
|
12
|
+
* their plists as the JSON it would print, which is why these tests live apart
|
|
13
|
+
* from flavored-frameworks.test.js, whose tarball fixtures need a real `tar`.
|
|
14
|
+
*
|
|
15
|
+
* The plugin's Jest config applies no transform, so these `jest.mock` calls run
|
|
16
|
+
* in place rather than being hoisted, and may close over `volume`.
|
|
17
|
+
*/
|
|
18
|
+
const volume = new Map(); // absolute path → file contents, or null for a directory
|
|
19
|
+
const unreadable = new Set(); // paths `statSync` refuses with EACCES
|
|
20
|
+
|
|
21
|
+
jest.mock('fs', () => ({
|
|
22
|
+
existsSync: (target) => volume.has(target),
|
|
23
|
+
statSync: (target) => {
|
|
24
|
+
if (unreadable.has(target)) {
|
|
25
|
+
throw Object.assign(new Error(`EACCES: permission denied, stat '${target}'`), {
|
|
26
|
+
code: 'EACCES',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (!volume.has(target)) {
|
|
30
|
+
throw Object.assign(new Error(`ENOENT: ${target}`), { code: 'ENOENT' });
|
|
31
|
+
}
|
|
32
|
+
return { isDirectory: () => volume.get(target) === null };
|
|
33
|
+
},
|
|
34
|
+
}));
|
|
35
|
+
jest.mock('child_process', () => ({ execFileSync: jest.fn() }));
|
|
36
|
+
|
|
37
|
+
const { execFileSync } = require('child_process');
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
assertDistinctFlavoredFrameworks,
|
|
41
|
+
resolveSpmDependencyFrameworks,
|
|
42
|
+
} = require('../flavored-frameworks');
|
|
43
|
+
|
|
44
|
+
const OVERRIDE = path.join('/virtual', 'precompiled-modules');
|
|
45
|
+
const MONOREPO_SPM_DEPS = path.resolve(__dirname, '../../../../precompile/.build/.spm-deps');
|
|
46
|
+
const IMAGE_ROOT = '/virtual/expo-image';
|
|
47
|
+
|
|
48
|
+
const overrideBase = (depName) => path.join(OVERRIDE, '.spm-deps', depName);
|
|
49
|
+
const monorepoBase = (depName) => path.join(MONOREPO_SPM_DEPS, depName);
|
|
50
|
+
const bundledBase = (moduleRoot, depName) =>
|
|
51
|
+
path.join(moduleRoot, 'prebuilds', 'spm-deps', depName);
|
|
52
|
+
|
|
53
|
+
/** An XCFramework directory whose Info.plist is whatever `plutil` would print. */
|
|
54
|
+
function dependencyArtifact(baseDir, depName, flavor, plist) {
|
|
55
|
+
const xcframework = path.join(baseDir, flavor, `${depName}.xcframework`);
|
|
56
|
+
volume.set(xcframework, null);
|
|
57
|
+
volume.set(path.join(xcframework, 'Info.plist'), plist);
|
|
58
|
+
return xcframework;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function dependencyXcframework(baseDir, depName, flavor, libraryPaths = [`${depName}.framework`]) {
|
|
62
|
+
return dependencyArtifact(
|
|
63
|
+
baseDir,
|
|
64
|
+
depName,
|
|
65
|
+
flavor,
|
|
66
|
+
JSON.stringify({
|
|
67
|
+
AvailableLibraries: libraryPaths.map((libraryPath, index) => ({
|
|
68
|
+
LibraryIdentifier: `ios-arm64-${index}`,
|
|
69
|
+
...(libraryPath != null && { LibraryPath: libraryPath }),
|
|
70
|
+
})),
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const bothFlavors = (baseDir, depName, libraryPaths) => ({
|
|
76
|
+
debug: dependencyXcframework(baseDir, depName, 'debug', libraryPaths),
|
|
77
|
+
release: dependencyXcframework(baseDir, depName, 'release', libraryPaths),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
/** A leftover regular file where an XCFramework directory belongs. */
|
|
81
|
+
function dependencyFile(baseDir, depName, flavor) {
|
|
82
|
+
const target = path.join(baseDir, flavor, `${depName}.xcframework`);
|
|
83
|
+
volume.set(target, 'not a directory');
|
|
84
|
+
return target;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const consumer = (podName, moduleRoot, spmDependencies) => ({
|
|
88
|
+
podName,
|
|
89
|
+
moduleRoot,
|
|
90
|
+
spmDependencies,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const resolveLibavif = () =>
|
|
94
|
+
resolveSpmDependencyFrameworks([consumer('ExpoImage', IMAGE_ROOT, ['libavif'])]);
|
|
95
|
+
|
|
96
|
+
const declaration = (id, frameworkName) => ({
|
|
97
|
+
id,
|
|
98
|
+
frameworkName,
|
|
99
|
+
linkage: 'dynamic',
|
|
100
|
+
flavors: {
|
|
101
|
+
debug: `/virtual/${frameworkName}-debug/${frameworkName}.xcframework`,
|
|
102
|
+
release: `/virtual/${frameworkName}-release/${frameworkName}.xcframework`,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('shared SwiftPM dependency frameworks', () => {
|
|
107
|
+
let oldOverride;
|
|
108
|
+
|
|
109
|
+
beforeEach(() => {
|
|
110
|
+
volume.clear();
|
|
111
|
+
unreadable.clear();
|
|
112
|
+
oldOverride = process.env.EXPO_PRECOMPILED_MODULES_PATH;
|
|
113
|
+
process.env.EXPO_PRECOMPILED_MODULES_PATH = OVERRIDE;
|
|
114
|
+
execFileSync.mockImplementation((file, args) => volume.get(args[args.length - 1]));
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
afterEach(() => {
|
|
118
|
+
if (oldOverride == null) {
|
|
119
|
+
delete process.env.EXPO_PRECOMPILED_MODULES_PATH;
|
|
120
|
+
} else {
|
|
121
|
+
process.env.EXPO_PRECOMPILED_MODULES_PATH = oldOverride;
|
|
122
|
+
}
|
|
123
|
+
execFileSync.mockReset();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('declares one paired dynamic framework per dependency a precompiled module links', () => {
|
|
127
|
+
const web = bothFlavors(overrideBase('SDWebImage'), 'SDWebImage');
|
|
128
|
+
const avif = bothFlavors(overrideBase('libavif'), 'libavif');
|
|
129
|
+
|
|
130
|
+
// Declared in byte order, as CocoaPods sorts them, whatever order they arrive in.
|
|
131
|
+
expect(
|
|
132
|
+
resolveSpmDependencyFrameworks([consumer('ExpoImage', IMAGE_ROOT, ['libavif', 'SDWebImage'])])
|
|
133
|
+
).toEqual([
|
|
134
|
+
{ id: 'expo-sdweb-image', frameworkName: 'SDWebImage', linkage: 'dynamic', flavors: web },
|
|
135
|
+
{ id: 'expo-libavif', frameworkName: 'libavif', linkage: 'dynamic', flavors: avif },
|
|
136
|
+
]);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('reads both flavors of every XCFramework plist through plutil, never as text', () => {
|
|
140
|
+
const { debug, release } = bothFlavors(overrideBase('SDWebImage'), 'SDWebImage');
|
|
141
|
+
|
|
142
|
+
resolveSpmDependencyFrameworks([consumer('ExpoImage', IMAGE_ROOT, ['SDWebImage'])]);
|
|
143
|
+
|
|
144
|
+
for (const xcframework of [debug, release]) {
|
|
145
|
+
expect(execFileSync).toHaveBeenCalledWith(
|
|
146
|
+
'plutil',
|
|
147
|
+
['-convert', 'json', '-o', '-', path.join(xcframework, 'Info.plist')],
|
|
148
|
+
expect.objectContaining({ encoding: 'utf8' })
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('declares nothing for a module that links no SwiftPM package', () => {
|
|
154
|
+
expect(
|
|
155
|
+
resolveSpmDependencyFrameworks([consumer('ExpoModulesCore', '/virtual/core', undefined)])
|
|
156
|
+
).toEqual([]);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('declares nothing for a dependency with no artifact under any base', () => {
|
|
160
|
+
expect(resolveLibavif()).toEqual([]);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('prefers the path override to the monorepo build tree', () => {
|
|
164
|
+
const flavors = bothFlavors(overrideBase('libavif'), 'libavif');
|
|
165
|
+
bothFlavors(monorepoBase('libavif'), 'libavif');
|
|
166
|
+
bothFlavors(bundledBase(IMAGE_ROOT, 'libavif'), 'libavif');
|
|
167
|
+
|
|
168
|
+
expect(resolveLibavif()).toEqual([
|
|
169
|
+
{ id: 'expo-libavif', frameworkName: 'libavif', linkage: 'dynamic', flavors },
|
|
170
|
+
]);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('prefers the monorepo build tree to the copy bundled into the owning package', () => {
|
|
174
|
+
delete process.env.EXPO_PRECOMPILED_MODULES_PATH;
|
|
175
|
+
const flavors = bothFlavors(monorepoBase('libavif'), 'libavif');
|
|
176
|
+
bothFlavors(bundledBase(IMAGE_ROOT, 'libavif'), 'libavif');
|
|
177
|
+
|
|
178
|
+
expect(resolveLibavif()).toEqual([
|
|
179
|
+
{ id: 'expo-libavif', frameworkName: 'libavif', linkage: 'dynamic', flavors },
|
|
180
|
+
]);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Debug resolves in the monorepo build tree, release only in the bundled copy.
|
|
184
|
+
it('resolves each flavor through every base, one flavor at a time', () => {
|
|
185
|
+
const debug = dependencyXcframework(monorepoBase('libavif'), 'libavif', 'debug');
|
|
186
|
+
const release = dependencyXcframework(bundledBase(IMAGE_ROOT, 'libavif'), 'libavif', 'release');
|
|
187
|
+
|
|
188
|
+
expect(resolveLibavif()).toEqual([
|
|
189
|
+
{
|
|
190
|
+
id: 'expo-libavif',
|
|
191
|
+
frameworkName: 'libavif',
|
|
192
|
+
linkage: 'dynamic',
|
|
193
|
+
flavors: { debug, release },
|
|
194
|
+
},
|
|
195
|
+
]);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('skips a stale file left where an XCFramework belongs and resolves the real one', () => {
|
|
199
|
+
dependencyFile(overrideBase('libavif'), 'libavif', 'debug');
|
|
200
|
+
dependencyFile(overrideBase('libavif'), 'libavif', 'release');
|
|
201
|
+
const flavors = bothFlavors(bundledBase(IMAGE_ROOT, 'libavif'), 'libavif');
|
|
202
|
+
|
|
203
|
+
expect(resolveLibavif()).toEqual([
|
|
204
|
+
{ id: 'expo-libavif', frameworkName: 'libavif', linkage: 'dynamic', flavors },
|
|
205
|
+
]);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('rejects a dependency that resolved only one of its two flavors', () => {
|
|
209
|
+
dependencyXcframework(overrideBase('libavif'), 'libavif', 'debug');
|
|
210
|
+
|
|
211
|
+
expect(resolveLibavif).toThrow('libavif has no release XCFramework');
|
|
212
|
+
expect(resolveLibavif).toThrow(overrideBase('libavif'));
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it.each([
|
|
216
|
+
['a dependency shipped as a static library', ['libavif.a'], /libavif\.a/],
|
|
217
|
+
[
|
|
218
|
+
'a dependency whose framework is named after something else',
|
|
219
|
+
['avif.framework'],
|
|
220
|
+
/avif\.framework/,
|
|
221
|
+
],
|
|
222
|
+
[
|
|
223
|
+
'an XCFramework whose second slice alone is unusable',
|
|
224
|
+
['libavif.framework', 'libavif.a'],
|
|
225
|
+
/libavif\.a/,
|
|
226
|
+
],
|
|
227
|
+
['an XCFramework that declares no library slices', [], /no library slices/],
|
|
228
|
+
['an XCFramework whose slice names no library path', [null], /a slice with no LibraryPath/],
|
|
229
|
+
])('rejects %s', (_, libraryPaths, found) => {
|
|
230
|
+
bothFlavors(overrideBase('libavif'), 'libavif', libraryPaths);
|
|
231
|
+
|
|
232
|
+
expect(resolveLibavif).toThrow(
|
|
233
|
+
new RegExp(`libavif does not ship a libavif\\.framework.*${found.source}`, 's')
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it('rejects a dependency whose release flavor alone is a static library', () => {
|
|
238
|
+
dependencyXcframework(overrideBase('libavif'), 'libavif', 'debug');
|
|
239
|
+
const release = dependencyXcframework(overrideBase('libavif'), 'libavif', 'release', [
|
|
240
|
+
'libavif.a',
|
|
241
|
+
]);
|
|
242
|
+
|
|
243
|
+
expect(resolveLibavif).toThrow(release);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('rejects an XCFramework whose slice list is not a list', () => {
|
|
247
|
+
const plist = JSON.stringify({ AvailableLibraries: { 'ios-arm64': 'libavif.framework' } });
|
|
248
|
+
dependencyArtifact(overrideBase('libavif'), 'libavif', 'debug', plist);
|
|
249
|
+
dependencyArtifact(overrideBase('libavif'), 'libavif', 'release', plist);
|
|
250
|
+
|
|
251
|
+
expect(resolveLibavif).toThrow(
|
|
252
|
+
/Info\.plist lists AvailableLibraries as something other than a list of slices/
|
|
253
|
+
);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('rejects an Info.plist that does not convert to a property list', () => {
|
|
257
|
+
const debug = dependencyArtifact(
|
|
258
|
+
overrideBase('libavif'),
|
|
259
|
+
'libavif',
|
|
260
|
+
'debug',
|
|
261
|
+
'not a property list'
|
|
262
|
+
);
|
|
263
|
+
dependencyXcframework(overrideBase('libavif'), 'libavif', 'release');
|
|
264
|
+
|
|
265
|
+
expect(resolveLibavif).toThrow(
|
|
266
|
+
`[expo-spm-plugin] ${path.join(debug, 'Info.plist')} could not be read`
|
|
267
|
+
);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it('reports what plutil said when it refuses the Info.plist', () => {
|
|
271
|
+
bothFlavors(overrideBase('libavif'), 'libavif');
|
|
272
|
+
execFileSync.mockImplementation(() => {
|
|
273
|
+
throw new Error('Command failed: plutil\nUnexpected character b at line 1');
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
expect(resolveLibavif).toThrow(/could not be read.*Unexpected character b/s);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('stops on a base it cannot read, instead of reporting the artifact as missing', () => {
|
|
280
|
+
const blocked = path.join(overrideBase('libavif'), 'debug', 'libavif.xcframework');
|
|
281
|
+
unreadable.add(blocked);
|
|
282
|
+
bothFlavors(bundledBase(IMAGE_ROOT, 'libavif'), 'libavif');
|
|
283
|
+
|
|
284
|
+
expect(resolveLibavif).toThrow(`[expo-spm-plugin] ${blocked} could not be read: EACCES`);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
// Pod names are compared byte by byte, as CocoaPods' `consumers.keys.sort` does:
|
|
288
|
+
// an uppercase B sorts before a lowercase a.
|
|
289
|
+
it('declares a dependency two modules share once, owned by the first pod name in byte order', () => {
|
|
290
|
+
const upper = '/virtual/upper';
|
|
291
|
+
const flavors = {
|
|
292
|
+
debug: dependencyXcframework(bundledBase(upper, 'ZXingObjC'), 'ZXingObjC', 'debug'),
|
|
293
|
+
release: dependencyXcframework(bundledBase(upper, 'ZXingObjC'), 'ZXingObjC', 'release'),
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
expect(
|
|
297
|
+
resolveSpmDependencyFrameworks([
|
|
298
|
+
consumer('aPod', '/virtual/lower', ['ZXingObjC']),
|
|
299
|
+
consumer('BPod', upper, ['ZXingObjC']),
|
|
300
|
+
])
|
|
301
|
+
).toEqual([
|
|
302
|
+
{ id: 'expo-zxing-obj-c', frameworkName: 'ZXingObjC', linkage: 'dynamic', flavors },
|
|
303
|
+
]);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('looks for the bundled copy under the owner alone', () => {
|
|
307
|
+
const lower = '/virtual/lower';
|
|
308
|
+
dependencyXcframework(bundledBase(lower, 'ZXingObjC'), 'ZXingObjC', 'debug');
|
|
309
|
+
dependencyXcframework(bundledBase(lower, 'ZXingObjC'), 'ZXingObjC', 'release');
|
|
310
|
+
|
|
311
|
+
expect(
|
|
312
|
+
resolveSpmDependencyFrameworks([
|
|
313
|
+
consumer('aPod', lower, ['ZXingObjC']),
|
|
314
|
+
consumer('BPod', '/virtual/upper', ['ZXingObjC']),
|
|
315
|
+
])
|
|
316
|
+
).toEqual([]);
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
describe('assertDistinctFlavoredFrameworks', () => {
|
|
321
|
+
it('accepts declarations with distinct ids and framework names', () => {
|
|
322
|
+
expect(() =>
|
|
323
|
+
assertDistinctFlavoredFrameworks([
|
|
324
|
+
declaration('expo-image', 'ExpoImage'),
|
|
325
|
+
declaration('expo-foo', 'Foo'),
|
|
326
|
+
])
|
|
327
|
+
).not.toThrow();
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('rejects two products that collapse onto one framework id', () => {
|
|
331
|
+
expect(() =>
|
|
332
|
+
assertDistinctFlavoredFrameworks([
|
|
333
|
+
declaration('expo-foo', 'ExpoFoo'),
|
|
334
|
+
declaration('expo-foo', 'Foo'),
|
|
335
|
+
])
|
|
336
|
+
).toThrow(/ExpoFoo.*Foo.*framework id "expo-foo"/s);
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it('rejects two products that embed under one framework name', () => {
|
|
340
|
+
expect(() =>
|
|
341
|
+
assertDistinctFlavoredFrameworks([declaration('expo-a', 'Foo'), declaration('expo-b', 'Foo')])
|
|
342
|
+
).toThrow('framework name "Foo"');
|
|
343
|
+
});
|
|
344
|
+
});
|
|
@@ -18,6 +18,8 @@ const xcode = require(
|
|
|
18
18
|
require.resolve('xcode', { paths: [path.dirname(require.resolve('@expo/config-plugins'))] })
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
+
const { pluginError } = require('./diagnostics');
|
|
22
|
+
|
|
21
23
|
/** Written by RN's SwiftPM injector into the .xcodeproj it modified. */
|
|
22
24
|
const INJECTION_MARKER = '.spm-injected.json';
|
|
23
25
|
|
|
@@ -205,4 +207,43 @@ function resolveAppTarget(appRoot) {
|
|
|
205
207
|
};
|
|
206
208
|
}
|
|
207
209
|
|
|
208
|
-
|
|
210
|
+
/**
|
|
211
|
+
* Podfile.properties.json (as precompiled_modules.rb#read_podfile_properties). Missing → {};
|
|
212
|
+
* present but unusable → throw, since every gate would silently fall to its default.
|
|
213
|
+
*/
|
|
214
|
+
function readPodfileProperties(propertiesPath) {
|
|
215
|
+
if (typeof propertiesPath !== 'string' || propertiesPath.length === 0) return {};
|
|
216
|
+
let properties;
|
|
217
|
+
try {
|
|
218
|
+
properties = JSON.parse(fs.readFileSync(propertiesPath, 'utf8'));
|
|
219
|
+
} catch (error) {
|
|
220
|
+
if (error.code === 'ENOENT') return {};
|
|
221
|
+
throw unusablePropertiesError(propertiesPath, error.message, { cause: error });
|
|
222
|
+
}
|
|
223
|
+
if (properties == null || typeof properties !== 'object' || Array.isArray(properties)) {
|
|
224
|
+
throw unusablePropertiesError(
|
|
225
|
+
propertiesPath,
|
|
226
|
+
`it holds ${describeType(properties)}, not an object`
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
return properties;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** Type only: JSON.stringify can overflow on a deep payload. */
|
|
233
|
+
function describeType(payload) {
|
|
234
|
+
if (payload === null) return 'null';
|
|
235
|
+
return Array.isArray(payload) ? 'an array' : `a ${typeof payload}`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function unusablePropertiesError(propertiesPath, reason, options) {
|
|
239
|
+
return pluginError(
|
|
240
|
+
{
|
|
241
|
+
what: `${propertiesPath} could not be read as Podfile properties (${reason}), so the plugin cannot tell which products this app links.`,
|
|
242
|
+
why: "Carrying on would read every property as unset and leave each gated product to its own default instead of the app's configuration, which only shows up at runtime, so the sync stops here.",
|
|
243
|
+
how: 'Restore the file to a JSON object of properties, then re-run `npx react-native spm update`.',
|
|
244
|
+
},
|
|
245
|
+
options
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
module.exports = { readPodfileProperties, resolveAppTarget };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Port of `companion_autolink_condition_met?`/`_label` (precompiled_modules.rb); its
|
|
3
|
+
* pod_lookup_map is the prebuilt-metadata document here.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* First declared key decides (podName, npmPackage, podfileProperty); none → not met.
|
|
10
|
+
* declaredPodNames = every DECLARED pod, not the ones emitted so far.
|
|
11
|
+
*/
|
|
12
|
+
function autolinkConditionMet(
|
|
13
|
+
condition,
|
|
14
|
+
{ declaredPodNames, autolinkedPackages, podfileProperties } = {}
|
|
15
|
+
) {
|
|
16
|
+
if (condition?.podName != null) return declaredPodNames?.has(condition.podName) === true;
|
|
17
|
+
if (condition?.npmPackage != null) return autolinkedPackages?.has(condition.npmPackage) === true;
|
|
18
|
+
if (condition?.podfileProperty != null) {
|
|
19
|
+
// Opt-out; unset and undeclared both read as nil in Ruby.
|
|
20
|
+
// Keeping them apart would link a product that CocoaPods withholds.
|
|
21
|
+
return (
|
|
22
|
+
(podfileProperties?.[condition.podfileProperty] ?? null) !== (condition.disabledValue ?? null)
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** What to call the condition in a diagnostic: the key that decides it. */
|
|
29
|
+
function autolinkConditionLabel(condition) {
|
|
30
|
+
return condition?.podName ?? condition?.npmPackage ?? condition?.podfileProperty ?? null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Which kind of condition it is: the name of the key that decides it. */
|
|
34
|
+
function autolinkConditionKey(condition) {
|
|
35
|
+
return (
|
|
36
|
+
['podName', 'npmPackage', 'podfileProperty'].find((key) => condition?.[key] != null) ?? null
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = { autolinkConditionKey, autolinkConditionLabel, autolinkConditionMet };
|