@capacitor/cli 9.0.0-alpha.5 → 9.0.0-alpha.7
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/assets/android-template.tar.gz +0 -0
- package/assets/capacitor-cordova-android-plugins.tar.gz +0 -0
- package/assets/capacitor-cordova-ios-plugins.tar.gz +0 -0
- package/assets/ios-pods-template.tar.gz +0 -0
- package/assets/ios-spm-template.tar.gz +0 -0
- package/dist/android/update.js +6 -37
- package/dist/config.js +5 -3
- package/dist/cordova.js +16 -3
- package/dist/declarations.d.ts +70 -4
- package/dist/ios/update.js +21 -7
- package/dist/tasks/migrate-edge-to-edge.js +158 -0
- package/dist/tasks/migrate-swiftui.js +335 -0
- package/dist/tasks/migrate.js +192 -57
- package/dist/util/capacitor-package.js +297 -0
- package/dist/util/cordova-ios.js +144 -12
- package/dist/util/node.js +35 -1
- package/dist/util/spm.js +82 -11
- package/dist/util/xcode.js +48 -0
- package/package.json +4 -2
package/dist/util/spm.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkPackageTraitsRequirements = exports.checkSwiftToolsVersion = exports.addInfoPlistDebugIfNeeded = exports.runCocoapodsDeintegrate = exports.generatePackageText = exports.removeCocoapodsFiles = exports.extractSPMPackageDirectory = exports.checkPluginsForPackageSwift = exports.generatePackageFile = exports.findPackageSwiftFile = exports.checkPackageManager = void 0;
|
|
3
|
+
exports.checkPackageTraitsRequirements = exports.checkSwiftToolsVersion = exports.setSwiftUISceneManifest = exports.hasSwiftUISceneManifest = exports.hasSceneManifest = exports.addInfoPlistDebugIfNeeded = exports.runCocoapodsDeintegrate = exports.generatePackageText = exports.removeCocoapodsFiles = exports.extractSPMPackageDirectory = exports.checkPluginsForPackageSwift = exports.generatePackageFile = exports.findPackageSwiftFile = exports.checkPackageManager = void 0;
|
|
4
4
|
const fs_extra_1 = require("fs-extra");
|
|
5
5
|
const os_1 = require("os");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const plist_1 = require("plist");
|
|
8
8
|
const tar_1 = require("tar");
|
|
9
|
-
const common_1 = require("../common");
|
|
10
9
|
const cordova_1 = require("../cordova");
|
|
11
10
|
const errors_1 = require("../errors");
|
|
12
|
-
const
|
|
11
|
+
const common_1 = require("../ios/common");
|
|
13
12
|
const log_1 = require("../log");
|
|
14
13
|
const plugin_1 = require("../plugin");
|
|
14
|
+
const capacitor_package_1 = require("../util/capacitor-package");
|
|
15
|
+
const fs_1 = require("../util/fs");
|
|
15
16
|
const subprocess_1 = require("../util/subprocess");
|
|
16
17
|
/**
|
|
17
18
|
* @deprecated use config.ios.packageManager
|
|
@@ -86,12 +87,13 @@ async function removeCocoapodsFiles(config) {
|
|
|
86
87
|
exports.removeCocoapodsFiles = removeCocoapodsFiles;
|
|
87
88
|
async function generatePackageText(config, plugins) {
|
|
88
89
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
89
|
-
const
|
|
90
|
-
const iosVersion = (0, common_2.getMajoriOSVersion)(config);
|
|
90
|
+
const iosVersion = (0, common_1.getMajoriOSVersion)(config);
|
|
91
91
|
const cordovaPlugins = await (0, cordova_1.getCordovaPlugins)(config, 'ios');
|
|
92
|
-
const enableCordova = cordovaPlugins.length > 0;
|
|
92
|
+
const enableCordova = cordovaPlugins.length > 0 || config.app.forceCordova;
|
|
93
93
|
const packageTraits = (_d = (_c = (_b = (_a = config.app.extConfig.experimental) === null || _a === void 0 ? void 0 : _a.ios) === null || _b === void 0 ? void 0 : _b.spm) === null || _c === void 0 ? void 0 : _c.packageTraits) !== null && _d !== void 0 ? _d : {};
|
|
94
94
|
const packageOptions = (_h = (_g = (_f = (_e = config.app.extConfig.experimental) === null || _e === void 0 ? void 0 : _e.ios) === null || _f === void 0 ? void 0 : _f.spm) === null || _g === void 0 ? void 0 : _g.packageOptions) !== null && _h !== void 0 ? _h : {};
|
|
95
|
+
const capacitorPackage = await (0, capacitor_package_1.resolveCapacitorPackage)(config);
|
|
96
|
+
const spmDirectory = (0, path_1.join)(config.ios.nativeProjectDirAbs, 'CapApp-SPM');
|
|
95
97
|
const swiftToolsVersion = (_m = (_l = (_k = (_j = config.app.extConfig.experimental) === null || _j === void 0 ? void 0 : _j.ios) === null || _k === void 0 ? void 0 : _k.spm) === null || _l === void 0 ? void 0 : _l.swiftToolsVersion) !== null && _m !== void 0 ? _m : '5.9';
|
|
96
98
|
let packageSwiftText = `// swift-tools-version: ${swiftToolsVersion}
|
|
97
99
|
import PackageDescription
|
|
@@ -106,12 +108,12 @@ let package = Package(
|
|
|
106
108
|
targets: ["CapApp-SPM"])
|
|
107
109
|
],
|
|
108
110
|
dependencies: [
|
|
109
|
-
|
|
111
|
+
${(0, capacitor_package_1.renderCapacitorPackage)(capacitorPackage, spmDirectory)}`;
|
|
110
112
|
for (const plugin of plugins) {
|
|
111
113
|
if ((0, plugin_1.getPluginType)(plugin, config.ios.name) === 1 /* PluginType.Cordova */) {
|
|
112
114
|
const platformTag = (0, plugin_1.getPluginPlatform)(plugin, config.ios.name);
|
|
113
115
|
if ((_o = platformTag.$) === null || _o === void 0 ? void 0 : _o.package) {
|
|
114
|
-
const relPath = (0, path_1.relative)(config.ios.nativeXcodeProjDirAbs, plugin.rootPath);
|
|
116
|
+
const relPath = (0, fs_1.convertToUnixPath)((0, path_1.relative)(config.ios.nativeXcodeProjDirAbs, plugin.rootPath));
|
|
115
117
|
packageSwiftText += `,\n .package(name: "${plugin.id}", path: "${relPath}")`;
|
|
116
118
|
}
|
|
117
119
|
else {
|
|
@@ -127,7 +129,9 @@ let package = Package(
|
|
|
127
129
|
const options = packageOptions[plugin.id];
|
|
128
130
|
const symlink = options === null || options === void 0 ? void 0 : options.symlink;
|
|
129
131
|
const symlinkFolder = (0, path_1.join)('symlinks', plugin.name);
|
|
130
|
-
const relPath = symlink
|
|
132
|
+
const relPath = symlink
|
|
133
|
+
? symlinkFolder
|
|
134
|
+
: (0, fs_1.convertToUnixPath)((0, path_1.relative)(config.ios.nativeXcodeProjDirAbs, plugin.rootPath));
|
|
131
135
|
if (symlink) {
|
|
132
136
|
await (0, fs_extra_1.ensureSymlink)(plugin.rootPath, (0, path_1.resolve)(config.ios.nativeProjectDirAbs, 'CapApp-SPM', symlinkFolder));
|
|
133
137
|
}
|
|
@@ -149,9 +153,9 @@ let package = Package(
|
|
|
149
153
|
.target(
|
|
150
154
|
name: "CapApp-SPM",
|
|
151
155
|
dependencies: [
|
|
152
|
-
.product(name: "Capacitor", package: "
|
|
156
|
+
.product(name: "Capacitor", package: "${capacitorPackage.identity}")`;
|
|
153
157
|
if (enableCordova) {
|
|
154
|
-
packageSwiftText += `,\n .product(name: "
|
|
158
|
+
packageSwiftText += `,\n .product(name: "${capacitorPackage.cordovaProduct}", package: "${capacitorPackage.identity}")`;
|
|
155
159
|
}
|
|
156
160
|
for (const plugin of plugins) {
|
|
157
161
|
const aliases = Object.entries((_r = (_q = packageOptions[plugin.id]) === null || _q === void 0 ? void 0 : _q.moduleAliases) !== null && _r !== void 0 ? _r : {});
|
|
@@ -226,6 +230,73 @@ async function addInfoPlistDebugIfNeeded(config) {
|
|
|
226
230
|
}
|
|
227
231
|
}
|
|
228
232
|
exports.addInfoPlistDebugIfNeeded = addInfoPlistDebugIfNeeded;
|
|
233
|
+
function hasSceneManifest(config) {
|
|
234
|
+
const infoPlist = (0, path_1.resolve)(config.ios.nativeTargetDirAbs, 'Info.plist');
|
|
235
|
+
if (!(0, fs_extra_1.existsSync)(infoPlist)) {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
const entries = (0, plist_1.parse)((0, fs_extra_1.readFileSync)(infoPlist, 'utf-8'));
|
|
239
|
+
return entries['UIApplicationSceneManifest'] !== undefined;
|
|
240
|
+
}
|
|
241
|
+
exports.hasSceneManifest = hasSceneManifest;
|
|
242
|
+
function hasSwiftUISceneManifest(config) {
|
|
243
|
+
const infoPlist = (0, path_1.resolve)(config.ios.nativeTargetDirAbs, 'Info.plist');
|
|
244
|
+
if (!(0, fs_extra_1.existsSync)(infoPlist)) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
const entries = (0, plist_1.parse)((0, fs_extra_1.readFileSync)(infoPlist, 'utf-8'));
|
|
248
|
+
const manifest = entries['UIApplicationSceneManifest'];
|
|
249
|
+
return manifest !== undefined && manifest['UISceneConfigurations'] === undefined;
|
|
250
|
+
}
|
|
251
|
+
exports.hasSwiftUISceneManifest = hasSwiftUISceneManifest;
|
|
252
|
+
/**
|
|
253
|
+
* Point Info.plist at the SwiftUI App-struct scene setup: a scene manifest with no
|
|
254
|
+
* UISceneConfigurations (SwiftUI declares the scene itself) and no main storyboard.
|
|
255
|
+
*
|
|
256
|
+
* Preserves UIApplicationSupportsMultipleScenes when the project already set it, and
|
|
257
|
+
* refuses to touch a manifest that names a scene delegate class other than the stock
|
|
258
|
+
* SceneDelegate.
|
|
259
|
+
*/
|
|
260
|
+
async function setSwiftUISceneManifest(config) {
|
|
261
|
+
var _a;
|
|
262
|
+
const infoPlist = (0, path_1.resolve)(config.ios.nativeTargetDirAbs, 'Info.plist');
|
|
263
|
+
if (!(0, fs_extra_1.existsSync)(infoPlist)) {
|
|
264
|
+
return { status: 'skipped', reason: `${infoPlist} not found.` };
|
|
265
|
+
}
|
|
266
|
+
const entries = (0, plist_1.parse)((0, fs_extra_1.readFileSync)(infoPlist, 'utf-8'));
|
|
267
|
+
const manifest = entries['UIApplicationSceneManifest'];
|
|
268
|
+
const customDelegates = customSceneDelegateClassNames(manifest);
|
|
269
|
+
if (customDelegates.length > 0) {
|
|
270
|
+
return {
|
|
271
|
+
status: 'skipped',
|
|
272
|
+
reason: `UIApplicationSceneManifest names custom scene delegate(s): ${customDelegates.join(', ')}. ` +
|
|
273
|
+
'Remove UISceneConfigurations by hand once the delegate is ported to the SwiftUI scene body.',
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
if (manifest !== undefined &&
|
|
277
|
+
manifest['UISceneConfigurations'] === undefined &&
|
|
278
|
+
!('UIMainStoryboardFile' in entries)) {
|
|
279
|
+
return { status: 'unchanged' };
|
|
280
|
+
}
|
|
281
|
+
entries['UIApplicationSceneManifest'] = {
|
|
282
|
+
UIApplicationSupportsMultipleScenes: (_a = manifest === null || manifest === void 0 ? void 0 : manifest['UIApplicationSupportsMultipleScenes']) !== null && _a !== void 0 ? _a : false,
|
|
283
|
+
};
|
|
284
|
+
delete entries['UIMainStoryboardFile'];
|
|
285
|
+
(0, fs_extra_1.writeFileSync)(infoPlist, (0, plist_1.build)(entries));
|
|
286
|
+
return { status: 'written' };
|
|
287
|
+
}
|
|
288
|
+
exports.setSwiftUISceneManifest = setSwiftUISceneManifest;
|
|
289
|
+
function customSceneDelegateClassNames(manifest) {
|
|
290
|
+
const configurations = manifest === null || manifest === void 0 ? void 0 : manifest['UISceneConfigurations'];
|
|
291
|
+
if (!configurations) {
|
|
292
|
+
return [];
|
|
293
|
+
}
|
|
294
|
+
return Object.values(configurations)
|
|
295
|
+
.flatMap((roleConfigs) => (Array.isArray(roleConfigs) ? roleConfigs : []))
|
|
296
|
+
.map((roleConfig) => roleConfig['UISceneDelegateClassName'])
|
|
297
|
+
.filter((className) => typeof className === 'string')
|
|
298
|
+
.filter((className) => className.split('.').pop() !== 'SceneDelegate');
|
|
299
|
+
}
|
|
229
300
|
async function checkSwiftToolsVersion(config, version) {
|
|
230
301
|
if (!version) {
|
|
231
302
|
return null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findGroupUuidByComment = exports.addSwiftFileToAppTarget = void 0;
|
|
4
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
const xcode_1 = require("xcode");
|
|
6
|
+
/**
|
|
7
|
+
* Register a Swift source file with the first native target of an Xcode project.
|
|
8
|
+
*
|
|
9
|
+
* Writes entries in PBXFileReference, PBXBuildFile, the named PBXGroup's children,
|
|
10
|
+
* and the target's Sources build phase. Idempotent: a second call is a no-op.
|
|
11
|
+
*
|
|
12
|
+
* @param pbxprojPath Absolute path to project.pbxproj
|
|
13
|
+
* @param groupName Comment/name of the PBXGroup the file belongs under (e.g. 'App')
|
|
14
|
+
* @param fileRelPath Path of the file relative to the group (e.g. 'SceneDelegate.swift')
|
|
15
|
+
*/
|
|
16
|
+
function addSwiftFileToAppTarget(pbxprojPath, groupName, fileRelPath) {
|
|
17
|
+
const project = (0, xcode_1.project)(pbxprojPath);
|
|
18
|
+
project.parseSync();
|
|
19
|
+
if (project.hasFile(fileRelPath)) {
|
|
20
|
+
return { added: false };
|
|
21
|
+
}
|
|
22
|
+
const groupUuid = findGroupUuidByComment(project, groupName);
|
|
23
|
+
if (!groupUuid) {
|
|
24
|
+
throw new Error(`Could not find PBXGroup with comment "${groupName}" in ${pbxprojPath}`);
|
|
25
|
+
}
|
|
26
|
+
const targetUuid = project.getFirstTarget().uuid;
|
|
27
|
+
const result = project.addSourceFile(fileRelPath, { target: targetUuid }, groupUuid);
|
|
28
|
+
if (!result) {
|
|
29
|
+
throw new Error(`Failed to register ${fileRelPath} in ${pbxprojPath}`);
|
|
30
|
+
}
|
|
31
|
+
(0, fs_extra_1.writeFileSync)(pbxprojPath, project.writeSync(), 'utf-8');
|
|
32
|
+
return { added: true };
|
|
33
|
+
}
|
|
34
|
+
exports.addSwiftFileToAppTarget = addSwiftFileToAppTarget;
|
|
35
|
+
// Exported for tests.
|
|
36
|
+
function findGroupUuidByComment(project, comment) {
|
|
37
|
+
const groups = project.hash.project.objects.PBXGroup;
|
|
38
|
+
const COMMENT_SUFFIX = '_comment';
|
|
39
|
+
for (const key of Object.keys(groups)) {
|
|
40
|
+
if (!key.endsWith(COMMENT_SUFFIX))
|
|
41
|
+
continue;
|
|
42
|
+
if (groups[key] === comment) {
|
|
43
|
+
return key.substring(0, key.length - COMMENT_SUFFIX.length);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
exports.findGroupUuidByComment = findGroupUuidByComment;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/cli",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.7",
|
|
4
4
|
"description": "Capacitor: Cross-platform apps with JavaScript and the web",
|
|
5
5
|
"homepage": "https://capacitorjs.com",
|
|
6
6
|
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"cross platform"
|
|
28
28
|
],
|
|
29
29
|
"engines": {
|
|
30
|
-
"node": ">=
|
|
30
|
+
"node": ">=24.0.0"
|
|
31
31
|
},
|
|
32
32
|
"main": "dist/index.js",
|
|
33
33
|
"types": "dist/declarations.d.ts",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"semver": "^7.6.3",
|
|
61
61
|
"tar": "^7.5.3",
|
|
62
62
|
"tslib": "^2.8.1",
|
|
63
|
+
"xcode": "^3.0.1",
|
|
63
64
|
"xml2js": "^0.6.2"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
"@types/prompts": "^2.4.9",
|
|
71
72
|
"@types/semver": "^7.5.8",
|
|
72
73
|
"@types/tmp": "^0.2.6",
|
|
74
|
+
"@types/xcode": "^3.0.0",
|
|
73
75
|
"@types/xml2js": "0.4.5",
|
|
74
76
|
"jest": "^29.7.0",
|
|
75
77
|
"jest-environment-jsdom": "^29.7.0",
|