@capacitor/cli 8.1.0 → 8.1.1-dev-20260305T152829.0
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/ios/update.js +32 -342
- package/dist/tasks/migrate.js +3 -3
- package/dist/util/cordova-ios.js +346 -0
- package/dist/util/iosplugin.js +1 -0
- package/dist/util/livereload.js +3 -26
- package/dist/util/spm.js +7 -2
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/ios/update.js
CHANGED
|
@@ -11,12 +11,12 @@ const errors_1 = require("../errors");
|
|
|
11
11
|
const log_1 = require("../log");
|
|
12
12
|
const plugin_1 = require("../plugin");
|
|
13
13
|
const copy_1 = require("../tasks/copy");
|
|
14
|
+
const cordova_ios_1 = require("../util/cordova-ios");
|
|
14
15
|
const fs_1 = require("../util/fs");
|
|
15
16
|
const iosplugin_1 = require("../util/iosplugin");
|
|
16
17
|
const node_1 = require("../util/node");
|
|
17
18
|
const spm_1 = require("../util/spm");
|
|
18
19
|
const subprocess_1 = require("../util/subprocess");
|
|
19
|
-
const template_1 = require("../util/template");
|
|
20
20
|
const common_2 = require("./common");
|
|
21
21
|
const platform = 'ios';
|
|
22
22
|
async function updateIOS(config, deployment) {
|
|
@@ -30,10 +30,11 @@ async function updateIOS(config, deployment) {
|
|
|
30
30
|
exports.updateIOS = updateIOS;
|
|
31
31
|
async function updatePluginFiles(config, plugins, deployment) {
|
|
32
32
|
var _a;
|
|
33
|
-
await removePluginsNativeFiles(config);
|
|
33
|
+
await (0, cordova_ios_1.removePluginsNativeFiles)(config);
|
|
34
34
|
const cordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 1 /* PluginType.Cordova */);
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const enableCordova = cordovaPlugins.length > 0;
|
|
36
|
+
if (enableCordova) {
|
|
37
|
+
await (0, cordova_ios_1.copyPluginsNativeFiles)(config, cordovaPlugins);
|
|
37
38
|
}
|
|
38
39
|
if (!(await (0, fs_extra_1.pathExists)(await config.ios.webDirAbs))) {
|
|
39
40
|
await (0, copy_1.copy)(config, platform);
|
|
@@ -41,73 +42,35 @@ async function updatePluginFiles(config, plugins, deployment) {
|
|
|
41
42
|
await (0, cordova_1.handleCordovaPluginsJS)(cordovaPlugins, config, platform);
|
|
42
43
|
await (0, cordova_1.checkPluginDependencies)(plugins, platform, (_a = config.app.extConfig.cordova) === null || _a === void 0 ? void 0 : _a.failOnUninstalledPlugins);
|
|
43
44
|
if ((await config.ios.packageManager) === 'SPM') {
|
|
44
|
-
|
|
45
|
+
if (enableCordova) {
|
|
46
|
+
await (0, cordova_ios_1.generateCordovaPackageFiles)(cordovaPlugins, config);
|
|
47
|
+
}
|
|
45
48
|
const validSPMPackages = await (0, spm_1.checkPluginsForPackageSwift)(config, plugins);
|
|
46
49
|
await (0, spm_1.generatePackageFile)(config, validSPMPackages.concat(cordovaPlugins));
|
|
47
50
|
}
|
|
48
51
|
else {
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
if (enableCordova) {
|
|
53
|
+
await (0, cordova_ios_1.generateCordovaPodspecs)(cordovaPlugins, config);
|
|
54
|
+
}
|
|
55
|
+
await installCocoaPodsPlugins(config, plugins, deployment, enableCordova);
|
|
51
56
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
(0, plugin_1.printPlugins)(incompatibleCordovaPlugins, platform, 'incompatible');
|
|
55
|
-
}
|
|
56
|
-
async function generateCordovaPackageFiles(cordovaPlugins, config) {
|
|
57
|
-
cordovaPlugins.map((plugin) => {
|
|
58
|
-
generateCordovaPackageFile(plugin, config);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
async function generateCordovaPackageFile(p, config) {
|
|
62
|
-
const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
|
|
63
|
-
const iosVersion = (0, common_2.getMajoriOSVersion)(config);
|
|
64
|
-
const headerFiles = (0, plugin_1.getPlatformElement)(p, platform, 'header-file');
|
|
65
|
-
let headersText = '';
|
|
66
|
-
if (headerFiles.length > 0) {
|
|
67
|
-
headersText = `,
|
|
68
|
-
publicHeadersPath: "."`;
|
|
57
|
+
if (enableCordova) {
|
|
58
|
+
await (0, cordova_1.logCordovaManualSteps)(cordovaPlugins, config, platform);
|
|
69
59
|
}
|
|
70
|
-
const content = `// swift-tools-version: 5.9
|
|
71
|
-
|
|
72
|
-
import PackageDescription
|
|
73
|
-
|
|
74
|
-
let package = Package(
|
|
75
|
-
name: "${p.name}",
|
|
76
|
-
platforms: [.iOS(.v${iosVersion})],
|
|
77
|
-
products: [
|
|
78
|
-
.library(
|
|
79
|
-
name: "${p.name}",
|
|
80
|
-
targets: ["${p.name}"]
|
|
81
|
-
)
|
|
82
|
-
],
|
|
83
|
-
dependencies: [
|
|
84
|
-
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "${iosPlatformVersion}")
|
|
85
|
-
],
|
|
86
|
-
targets: [
|
|
87
|
-
.target(
|
|
88
|
-
name: "${p.name}",
|
|
89
|
-
dependencies: [
|
|
90
|
-
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
91
|
-
],
|
|
92
|
-
path: "."${headersText}
|
|
93
|
-
)
|
|
94
|
-
]
|
|
95
|
-
)`;
|
|
96
|
-
await (0, fs_extra_1.writeFile)((0, path_1.join)(config.ios.cordovaPluginsDirAbs, 'sources', p.name, 'Package.swift'), content);
|
|
97
60
|
}
|
|
98
|
-
async function installCocoaPodsPlugins(config, plugins, deployment) {
|
|
61
|
+
async function installCocoaPodsPlugins(config, plugins, deployment, enableCordova) {
|
|
99
62
|
await (0, common_1.runTask)(`Updating iOS native dependencies with ${colors_1.default.input(`${await config.ios.podPath} install`)}`, () => {
|
|
100
|
-
return updatePodfile(config, plugins, deployment);
|
|
63
|
+
return updatePodfile(config, plugins, deployment, enableCordova);
|
|
101
64
|
});
|
|
102
65
|
}
|
|
103
66
|
exports.installCocoaPodsPlugins = installCocoaPodsPlugins;
|
|
104
|
-
async function updatePodfile(config, plugins, deployment) {
|
|
105
|
-
const dependenciesContent = await generatePodFile(config, plugins);
|
|
67
|
+
async function updatePodfile(config, plugins, deployment, enableCordova) {
|
|
68
|
+
const dependenciesContent = await generatePodFile(config, plugins, enableCordova);
|
|
106
69
|
const relativeCapacitoriOSPath = await getRelativeCapacitoriOSPath(config);
|
|
107
70
|
const podfilePath = (0, path_1.join)(config.ios.nativeProjectDirAbs, 'Podfile');
|
|
108
71
|
let podfileContent = await (0, fs_extra_1.readFile)(podfilePath, { encoding: 'utf-8' });
|
|
109
72
|
podfileContent = podfileContent.replace(/(def capacitor_pods)[\s\S]+?(\nend)/, `$1${dependenciesContent}$2`);
|
|
110
|
-
podfileContent = podfileContent.replace(/(require_relative)[\s\S]+?(
|
|
73
|
+
podfileContent = podfileContent.replace(/(require_relative)[\s\S]+?(ios\/scripts\/pods_helpers')/, `require_relative '${relativeCapacitoriOSPath}/scripts/pods_helpers'`);
|
|
111
74
|
await (0, fs_extra_1.writeFile)(podfilePath, podfileContent, { encoding: 'utf-8' });
|
|
112
75
|
const podPath = await config.ios.podPath;
|
|
113
76
|
const useBundler = (await config.ios.packageManager) === 'bundler';
|
|
@@ -116,11 +79,14 @@ async function updatePodfile(config, plugins, deployment) {
|
|
|
116
79
|
cwd: config.ios.nativeProjectDirAbs,
|
|
117
80
|
});
|
|
118
81
|
}
|
|
119
|
-
else {
|
|
82
|
+
else if (await (0, subprocess_1.isInstalled)('pod')) {
|
|
120
83
|
await (0, subprocess_1.runCommand)(podPath, ['install', ...(deployment ? ['--deployment'] : [])], {
|
|
121
84
|
cwd: config.ios.nativeProjectDirAbs,
|
|
122
85
|
});
|
|
123
86
|
}
|
|
87
|
+
else {
|
|
88
|
+
log_1.logger.warn('Skipping pod install because CocoaPods is not installed');
|
|
89
|
+
}
|
|
124
90
|
const isXcodebuildAvailable = await (0, subprocess_1.isInstalled)('xcodebuild');
|
|
125
91
|
if (isXcodebuildAvailable) {
|
|
126
92
|
await (0, subprocess_1.runCommand)('xcodebuild', ['-project', (0, path_1.basename)(`${config.ios.nativeXcodeProjDirAbs}`), 'clean'], {
|
|
@@ -139,7 +105,7 @@ async function getRelativeCapacitoriOSPath(config) {
|
|
|
139
105
|
}
|
|
140
106
|
return (0, fs_1.convertToUnixPath)((0, path_1.relative)(config.ios.nativeProjectDirAbs, await (0, fs_extra_1.realpath)((0, path_1.dirname)(capacitoriOSPath))));
|
|
141
107
|
}
|
|
142
|
-
async function generatePodFile(config, plugins) {
|
|
108
|
+
async function generatePodFile(config, plugins, enableCordova) {
|
|
143
109
|
const relativeCapacitoriOSPath = await getRelativeCapacitoriOSPath(config);
|
|
144
110
|
const capacitorPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 0 /* PluginType.Core */);
|
|
145
111
|
const pods = await Promise.all(capacitorPlugins.map(async (p) => {
|
|
@@ -148,285 +114,15 @@ async function generatePodFile(config, plugins) {
|
|
|
148
114
|
}
|
|
149
115
|
return ` pod '${p.ios.name}', :path => '${(0, fs_1.convertToUnixPath)((0, path_1.relative)(config.ios.nativeProjectDirAbs, await (0, fs_extra_1.realpath)(p.rootPath)))}'\n`;
|
|
150
116
|
}));
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (pod.$.git) {
|
|
158
|
-
let gitRef = '';
|
|
159
|
-
if (pod.$.tag) {
|
|
160
|
-
gitRef = `, :tag => '${pod.$.tag}'`;
|
|
161
|
-
}
|
|
162
|
-
else if (pod.$.branch) {
|
|
163
|
-
gitRef = `, :branch => '${pod.$.branch}'`;
|
|
164
|
-
}
|
|
165
|
-
else if (pod.$.commit) {
|
|
166
|
-
gitRef = `, :commit => '${pod.$.commit}'`;
|
|
167
|
-
}
|
|
168
|
-
pods.push(` pod '${pod.$.name}', :git => '${pod.$.git}'${gitRef}\n`);
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
const staticPlugins = cordovaPlugins.filter((p) => (0, cordova_1.needsStaticPod)(p));
|
|
175
|
-
const noStaticPlugins = cordovaPlugins.filter((el) => !staticPlugins.includes(el));
|
|
176
|
-
if (noStaticPlugins.length > 0) {
|
|
177
|
-
pods.push(` pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'\n`);
|
|
178
|
-
}
|
|
179
|
-
if (staticPlugins.length > 0) {
|
|
180
|
-
pods.push(` pod 'CordovaPluginsStatic', :path => '../capacitor-cordova-ios-plugins'\n`);
|
|
181
|
-
}
|
|
182
|
-
const resourcesPlugins = cordovaPlugins.filter(filterResources);
|
|
183
|
-
if (resourcesPlugins.length > 0) {
|
|
184
|
-
pods.push(` pod 'CordovaPluginsResources', :path => '../capacitor-cordova-ios-plugins'\n`);
|
|
185
|
-
}
|
|
186
|
-
return `
|
|
187
|
-
pod 'Capacitor', :path => '${relativeCapacitoriOSPath}'
|
|
188
|
-
pod 'CapacitorCordova', :path => '${relativeCapacitoriOSPath}'
|
|
189
|
-
${pods.join('').trimRight()}`;
|
|
190
|
-
}
|
|
191
|
-
function getFrameworkName(framework) {
|
|
192
|
-
if (isFramework(framework)) {
|
|
193
|
-
if (framework.$.custom && framework.$.custom === 'true') {
|
|
194
|
-
return framework.$.src;
|
|
195
|
-
}
|
|
196
|
-
return framework.$.src.substr(0, framework.$.src.indexOf('.'));
|
|
197
|
-
}
|
|
198
|
-
return framework.$.src.substr(0, framework.$.src.indexOf('.')).replace('lib', '');
|
|
199
|
-
}
|
|
200
|
-
function isFramework(framework) {
|
|
201
|
-
return framework.$.src.split('.').pop().includes('framework');
|
|
202
|
-
}
|
|
203
|
-
async function generateCordovaPodspecs(cordovaPlugins, config) {
|
|
204
|
-
const staticPlugins = cordovaPlugins.filter((p) => (0, cordova_1.needsStaticPod)(p));
|
|
205
|
-
const noStaticPlugins = cordovaPlugins.filter((el) => !staticPlugins.includes(el));
|
|
206
|
-
generateCordovaPodspec(noStaticPlugins, config, false);
|
|
207
|
-
generateCordovaPodspec(staticPlugins, config, true);
|
|
208
|
-
}
|
|
209
|
-
async function generateCordovaPodspec(cordovaPlugins, config, isStatic) {
|
|
210
|
-
const weakFrameworks = [];
|
|
211
|
-
const linkedFrameworks = [];
|
|
212
|
-
const customFrameworks = [];
|
|
213
|
-
const systemLibraries = [];
|
|
214
|
-
const sourceFrameworks = [];
|
|
215
|
-
const frameworkDeps = [];
|
|
216
|
-
const compilerFlags = [];
|
|
217
|
-
let prefsArray = [];
|
|
218
|
-
let name = 'CordovaPlugins';
|
|
219
|
-
let sourcesFolderName = 'sources';
|
|
220
|
-
if (isStatic) {
|
|
221
|
-
name += 'Static';
|
|
222
|
-
frameworkDeps.push('s.static_framework = true');
|
|
223
|
-
sourcesFolderName += 'static';
|
|
224
|
-
}
|
|
225
|
-
cordovaPlugins.map((plugin) => {
|
|
226
|
-
const frameworks = (0, plugin_1.getPlatformElement)(plugin, platform, 'framework');
|
|
227
|
-
frameworks.map((framework) => {
|
|
228
|
-
if (!framework.$.type) {
|
|
229
|
-
const name = getFrameworkName(framework);
|
|
230
|
-
if (isFramework(framework)) {
|
|
231
|
-
if (framework.$.weak && framework.$.weak === 'true') {
|
|
232
|
-
if (!weakFrameworks.includes(name)) {
|
|
233
|
-
weakFrameworks.push(name);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
else if (framework.$.custom && framework.$.custom === 'true') {
|
|
237
|
-
const frameworktPath = (0, path_1.join)(sourcesFolderName, plugin.name, name);
|
|
238
|
-
if (!customFrameworks.includes(frameworktPath)) {
|
|
239
|
-
customFrameworks.push(frameworktPath);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
if (!linkedFrameworks.includes(name)) {
|
|
244
|
-
linkedFrameworks.push(name);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
if (!systemLibraries.includes(name)) {
|
|
250
|
-
systemLibraries.push(name);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
else if (framework.$.type && framework.$.type === 'podspec') {
|
|
255
|
-
let depString = `s.dependency '${framework.$.src}'`;
|
|
256
|
-
if (framework.$.spec && framework.$.spec !== '') {
|
|
257
|
-
depString += `, '${framework.$.spec}'`;
|
|
258
|
-
}
|
|
259
|
-
if (!frameworkDeps.includes(depString)) {
|
|
260
|
-
frameworkDeps.push(depString);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
prefsArray = prefsArray.concat((0, plugin_1.getAllElements)(plugin, platform, 'preference'));
|
|
265
|
-
const podspecs = (0, plugin_1.getPlatformElement)(plugin, platform, 'podspec');
|
|
266
|
-
podspecs.map((podspec) => {
|
|
267
|
-
podspec.pods.map((pods) => {
|
|
268
|
-
pods.pod.map((pod) => {
|
|
269
|
-
let depString = `s.dependency '${pod.$.name}'`;
|
|
270
|
-
if (pod.$.spec && pod.$.spec !== '') {
|
|
271
|
-
depString += `, '${pod.$.spec}'`;
|
|
272
|
-
}
|
|
273
|
-
if (!frameworkDeps.includes(depString)) {
|
|
274
|
-
frameworkDeps.push(depString);
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
const sourceFiles = (0, plugin_1.getPlatformElement)(plugin, platform, 'source-file');
|
|
280
|
-
sourceFiles.map((sourceFile) => {
|
|
281
|
-
if (sourceFile.$.framework && sourceFile.$.framework === 'true') {
|
|
282
|
-
let fileName = sourceFile.$.src.split('/').pop();
|
|
283
|
-
if (!fileName.startsWith('lib')) {
|
|
284
|
-
fileName = 'lib' + fileName;
|
|
285
|
-
}
|
|
286
|
-
const frameworktPath = (0, path_1.join)(sourcesFolderName, plugin.name, fileName);
|
|
287
|
-
if (!sourceFrameworks.includes(frameworktPath)) {
|
|
288
|
-
sourceFrameworks.push(frameworktPath);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
else if (sourceFile.$['compiler-flags']) {
|
|
292
|
-
const cFlag = sourceFile.$['compiler-flags'];
|
|
293
|
-
if (!compilerFlags.includes(cFlag)) {
|
|
294
|
-
compilerFlags.push(cFlag);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
const onlySystemLibraries = systemLibraries.filter((library) => removeNoSystem(library, sourceFrameworks));
|
|
300
|
-
if (weakFrameworks.length > 0) {
|
|
301
|
-
frameworkDeps.push(`s.weak_frameworks = '${weakFrameworks.join(`', '`)}'`);
|
|
302
|
-
}
|
|
303
|
-
if (linkedFrameworks.length > 0) {
|
|
304
|
-
frameworkDeps.push(`s.frameworks = '${linkedFrameworks.join(`', '`)}'`);
|
|
305
|
-
}
|
|
306
|
-
if (onlySystemLibraries.length > 0) {
|
|
307
|
-
frameworkDeps.push(`s.libraries = '${onlySystemLibraries.join(`', '`)}'`);
|
|
308
|
-
}
|
|
309
|
-
if (customFrameworks.length > 0) {
|
|
310
|
-
frameworkDeps.push(`s.vendored_frameworks = '${customFrameworks.join(`', '`)}'`);
|
|
311
|
-
frameworkDeps.push(`s.exclude_files = 'sources/**/*.framework/Headers/*.h', 'sources/**/*.framework/PrivateHeaders/*.h'`);
|
|
312
|
-
}
|
|
313
|
-
if (sourceFrameworks.length > 0) {
|
|
314
|
-
frameworkDeps.push(`s.vendored_libraries = '${sourceFrameworks.join(`', '`)}'`);
|
|
117
|
+
const cordovaPodlines = (0, cordova_ios_1.cordovaPodfileLines)(config, plugins);
|
|
118
|
+
pods.concat(cordovaPodlines);
|
|
119
|
+
let podfileString = '\n';
|
|
120
|
+
podfileString += ` pod 'Capacitor', :path => '${relativeCapacitoriOSPath}'\n`;
|
|
121
|
+
if (enableCordova) {
|
|
122
|
+
podfileString += ` pod 'CapacitorCordova', :path => '${relativeCapacitoriOSPath}'\n`;
|
|
315
123
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
const arcPlugins = cordovaPlugins.filter(filterARCFiles);
|
|
320
|
-
if (arcPlugins.length > 0) {
|
|
321
|
-
frameworkDeps.push(`s.subspec 'noarc' do |sna|
|
|
322
|
-
sna.requires_arc = false
|
|
323
|
-
sna.source_files = 'noarc/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
324
|
-
end`);
|
|
325
|
-
}
|
|
326
|
-
let frameworksString = frameworkDeps.join('\n ');
|
|
327
|
-
frameworksString = await replaceFrameworkVariables(config, prefsArray, frameworksString);
|
|
328
|
-
const content = `
|
|
329
|
-
Pod::Spec.new do |s|
|
|
330
|
-
s.name = '${name}'
|
|
331
|
-
s.version = '${config.cli.package.version}'
|
|
332
|
-
s.summary = 'Autogenerated spec'
|
|
333
|
-
s.license = 'Unknown'
|
|
334
|
-
s.homepage = 'https://example.com'
|
|
335
|
-
s.authors = { 'Capacitor Generator' => 'hi@example.com' }
|
|
336
|
-
s.source = { :git => 'https://github.com/ionic-team/does-not-exist.git', :tag => '${config.cli.package.version}' }
|
|
337
|
-
s.source_files = '${sourcesFolderName}/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
338
|
-
s.ios.deployment_target = '${config.ios.minVersion}'
|
|
339
|
-
s.xcconfig = {'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1 WK_WEB_VIEW_ONLY=1' }
|
|
340
|
-
s.dependency 'CapacitorCordova'${getLinkerFlags(config)}
|
|
341
|
-
s.swift_version = '5.1'
|
|
342
|
-
${frameworksString}
|
|
343
|
-
end`;
|
|
344
|
-
await (0, fs_extra_1.writeFile)((0, path_1.join)(config.ios.cordovaPluginsDirAbs, `${name}.podspec`), content);
|
|
345
|
-
}
|
|
346
|
-
function getLinkerFlags(config) {
|
|
347
|
-
var _a;
|
|
348
|
-
if ((_a = config.app.extConfig.ios) === null || _a === void 0 ? void 0 : _a.cordovaLinkerFlags) {
|
|
349
|
-
return `\n s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '${config.app.extConfig.ios.cordovaLinkerFlags.join(' ')}' }`;
|
|
350
|
-
}
|
|
351
|
-
return '';
|
|
352
|
-
}
|
|
353
|
-
async function copyPluginsNativeFiles(config, cordovaPlugins) {
|
|
354
|
-
for (const p of cordovaPlugins) {
|
|
355
|
-
const sourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'source-file');
|
|
356
|
-
const headerFiles = (0, plugin_1.getPlatformElement)(p, platform, 'header-file');
|
|
357
|
-
const codeFiles = sourceFiles.concat(headerFiles);
|
|
358
|
-
const frameworks = (0, plugin_1.getPlatformElement)(p, platform, 'framework');
|
|
359
|
-
let sourcesFolderName = 'sources';
|
|
360
|
-
if ((0, cordova_1.needsStaticPod)(p)) {
|
|
361
|
-
sourcesFolderName += 'static';
|
|
362
|
-
}
|
|
363
|
-
const sourcesFolder = (0, path_1.join)(config.ios.cordovaPluginsDirAbs, sourcesFolderName, p.name);
|
|
364
|
-
for (const codeFile of codeFiles) {
|
|
365
|
-
let fileName = codeFile.$.src.split('/').pop();
|
|
366
|
-
const fileExt = codeFile.$.src.split('.').pop();
|
|
367
|
-
if (fileExt === 'a' && !fileName.startsWith('lib')) {
|
|
368
|
-
fileName = 'lib' + fileName;
|
|
369
|
-
}
|
|
370
|
-
let destFolder = sourcesFolderName;
|
|
371
|
-
if (codeFile.$['compiler-flags'] && codeFile.$['compiler-flags'] === '-fno-objc-arc') {
|
|
372
|
-
destFolder = 'noarc';
|
|
373
|
-
}
|
|
374
|
-
const filePath = (0, plugin_1.getFilePath)(config, p, codeFile.$.src);
|
|
375
|
-
const fileDest = (0, path_1.join)(config.ios.cordovaPluginsDirAbs, destFolder, p.name, fileName);
|
|
376
|
-
await (0, fs_extra_1.copy)(filePath, fileDest);
|
|
377
|
-
if (!codeFile.$.framework) {
|
|
378
|
-
let fileContent = await (0, fs_extra_1.readFile)(fileDest, { encoding: 'utf-8' });
|
|
379
|
-
if (fileExt === 'swift') {
|
|
380
|
-
fileContent = 'import Cordova\n' + fileContent;
|
|
381
|
-
await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
|
|
382
|
-
}
|
|
383
|
-
else {
|
|
384
|
-
if (fileContent.includes('@import Firebase;')) {
|
|
385
|
-
fileContent = fileContent.replace('@import Firebase;', '#import <Firebase/Firebase.h>');
|
|
386
|
-
await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
|
|
387
|
-
}
|
|
388
|
-
if (fileContent.includes('[NSBundle bundleForClass:[self class]]') ||
|
|
389
|
-
fileContent.includes('[NSBundle bundleForClass:[CDVCapture class]]')) {
|
|
390
|
-
fileContent = fileContent.replace('[NSBundle bundleForClass:[self class]]', '[NSBundle mainBundle]');
|
|
391
|
-
fileContent = fileContent.replace('[NSBundle bundleForClass:[CDVCapture class]]', '[NSBundle mainBundle]');
|
|
392
|
-
await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
|
|
393
|
-
}
|
|
394
|
-
if (fileContent.includes('[self.webView superview]') || fileContent.includes('self.webView.superview')) {
|
|
395
|
-
fileContent = fileContent.replace(/\[self.webView superview\]/g, 'self.viewController.view');
|
|
396
|
-
fileContent = fileContent.replace(/self.webView.superview/g, 'self.viewController.view');
|
|
397
|
-
await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
const resourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'resource-file');
|
|
403
|
-
for (const resourceFile of resourceFiles) {
|
|
404
|
-
const fileName = resourceFile.$.src.split('/').pop();
|
|
405
|
-
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(config.ios.cordovaPluginsDirAbs, 'resources', fileName));
|
|
406
|
-
}
|
|
407
|
-
for (const framework of frameworks) {
|
|
408
|
-
if (framework.$.custom && framework.$.custom === 'true') {
|
|
409
|
-
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, framework.$.src), (0, path_1.join)(sourcesFolder, framework.$.src));
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
async function removePluginsNativeFiles(config) {
|
|
415
|
-
await (0, fs_extra_1.remove)(config.ios.cordovaPluginsDirAbs);
|
|
416
|
-
await (0, template_1.extractTemplate)(config.cli.assets.ios.cordovaPluginsTemplateArchiveAbs, config.ios.cordovaPluginsDirAbs);
|
|
417
|
-
}
|
|
418
|
-
function filterResources(plugin) {
|
|
419
|
-
const resources = (0, plugin_1.getPlatformElement)(plugin, platform, 'resource-file');
|
|
420
|
-
return resources.length > 0;
|
|
421
|
-
}
|
|
422
|
-
function filterARCFiles(plugin) {
|
|
423
|
-
const sources = (0, plugin_1.getPlatformElement)(plugin, platform, 'source-file');
|
|
424
|
-
const sourcesARC = sources.filter((sourceFile) => sourceFile.$['compiler-flags'] && sourceFile.$['compiler-flags'] === '-fno-objc-arc');
|
|
425
|
-
return sourcesARC.length > 0;
|
|
426
|
-
}
|
|
427
|
-
function removeNoSystem(library, sourceFrameworks) {
|
|
428
|
-
const libraries = sourceFrameworks.filter((framework) => framework.includes(library));
|
|
429
|
-
return libraries.length === 0;
|
|
124
|
+
podfileString += pods.join('').trimEnd();
|
|
125
|
+
return podfileString;
|
|
430
126
|
}
|
|
431
127
|
async function getPluginsTask(config) {
|
|
432
128
|
return await (0, common_1.runTask)('Updating iOS plugins', async () => {
|
|
@@ -435,9 +131,3 @@ async function getPluginsTask(config) {
|
|
|
435
131
|
return iosPlugins;
|
|
436
132
|
});
|
|
437
133
|
}
|
|
438
|
-
async function replaceFrameworkVariables(config, prefsArray, frameworkString) {
|
|
439
|
-
prefsArray.map((preference) => {
|
|
440
|
-
frameworkString = frameworkString.replace(new RegExp(('$' + preference.$.name).replace('$', '\\$&'), 'g'), preference.$.default);
|
|
441
|
-
});
|
|
442
|
-
return frameworkString;
|
|
443
|
-
}
|
package/dist/tasks/migrate.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.migrateCommand = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs_extra_1 = require("fs-extra");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
-
const rimraf_1 = require("rimraf");
|
|
7
|
+
const rimraf_1 = tslib_1.__importDefault(require("rimraf"));
|
|
8
8
|
const semver_1 = require("semver");
|
|
9
9
|
const colors_1 = tslib_1.__importDefault(require("../colors"));
|
|
10
10
|
const common_1 = require("../common");
|
|
@@ -233,7 +233,7 @@ async function migrateCommand(config, noprompt, packagemanager) {
|
|
|
233
233
|
}
|
|
234
234
|
})();
|
|
235
235
|
});
|
|
236
|
-
rimraf_1.
|
|
236
|
+
rimraf_1.default.sync((0, path_1.join)(config.android.appDirAbs, 'build'));
|
|
237
237
|
}
|
|
238
238
|
// Write all breaking changes
|
|
239
239
|
await (0, common_1.runTask)(`Writing breaking changes.`, () => {
|
|
@@ -289,7 +289,7 @@ async function installLatestLibs(dependencyManager, runInstall, config) {
|
|
|
289
289
|
encoding: 'utf-8',
|
|
290
290
|
});
|
|
291
291
|
if (runInstall) {
|
|
292
|
-
rimraf_1.
|
|
292
|
+
rimraf_1.default.sync((0, path_1.join)(config.app.rootDir, 'node_modules/@capacitor/!(cli)'));
|
|
293
293
|
await (0, subprocess_1.runCommand)(dependencyManager, ['install']);
|
|
294
294
|
if (dependencyManager == 'yarn') {
|
|
295
295
|
await (0, subprocess_1.runCommand)(dependencyManager, ['upgrade']);
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateCordovaPackageFile = exports.generateCordovaPackageFiles = exports.cordovaPodfileLines = exports.filterARCFiles = exports.removePluginsNativeFiles = exports.copyPluginsNativeFiles = exports.generateCordovaPodspec = exports.generateCordovaPodspecs = void 0;
|
|
4
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const cordova_1 = require("../cordova");
|
|
8
|
+
const common_2 = require("../ios/common");
|
|
9
|
+
const plugin_1 = require("../plugin");
|
|
10
|
+
const template_1 = require("../util/template");
|
|
11
|
+
const platform = 'ios';
|
|
12
|
+
async function generateCordovaPodspecs(cordovaPlugins, config) {
|
|
13
|
+
const staticPlugins = cordovaPlugins.filter((p) => (0, cordova_1.needsStaticPod)(p));
|
|
14
|
+
const noStaticPlugins = cordovaPlugins.filter((el) => !staticPlugins.includes(el));
|
|
15
|
+
generateCordovaPodspec(noStaticPlugins, config, false);
|
|
16
|
+
generateCordovaPodspec(staticPlugins, config, true);
|
|
17
|
+
}
|
|
18
|
+
exports.generateCordovaPodspecs = generateCordovaPodspecs;
|
|
19
|
+
async function generateCordovaPodspec(cordovaPlugins, config, isStatic) {
|
|
20
|
+
const weakFrameworks = [];
|
|
21
|
+
const linkedFrameworks = [];
|
|
22
|
+
const customFrameworks = [];
|
|
23
|
+
const systemLibraries = [];
|
|
24
|
+
const sourceFrameworks = [];
|
|
25
|
+
const frameworkDeps = [];
|
|
26
|
+
const compilerFlags = [];
|
|
27
|
+
let prefsArray = [];
|
|
28
|
+
let name = 'CordovaPlugins';
|
|
29
|
+
let sourcesFolderName = 'sources';
|
|
30
|
+
if (isStatic) {
|
|
31
|
+
name += 'Static';
|
|
32
|
+
frameworkDeps.push('s.static_framework = true');
|
|
33
|
+
sourcesFolderName += 'static';
|
|
34
|
+
}
|
|
35
|
+
cordovaPlugins.map((plugin) => {
|
|
36
|
+
const frameworks = (0, plugin_1.getPlatformElement)(plugin, platform, 'framework');
|
|
37
|
+
frameworks.map((framework) => {
|
|
38
|
+
if (!framework.$.type) {
|
|
39
|
+
const name = getFrameworkName(framework);
|
|
40
|
+
if (isFramework(framework)) {
|
|
41
|
+
if (framework.$.weak && framework.$.weak === 'true') {
|
|
42
|
+
if (!weakFrameworks.includes(name)) {
|
|
43
|
+
weakFrameworks.push(name);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (framework.$.custom && framework.$.custom === 'true') {
|
|
47
|
+
const frameworktPath = (0, path_1.join)(sourcesFolderName, plugin.name, name);
|
|
48
|
+
if (!customFrameworks.includes(frameworktPath)) {
|
|
49
|
+
customFrameworks.push(frameworktPath);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
if (!linkedFrameworks.includes(name)) {
|
|
54
|
+
linkedFrameworks.push(name);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
if (!systemLibraries.includes(name)) {
|
|
60
|
+
systemLibraries.push(name);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (framework.$.type && framework.$.type === 'podspec') {
|
|
65
|
+
let depString = `s.dependency '${framework.$.src}'`;
|
|
66
|
+
if (framework.$.spec && framework.$.spec !== '') {
|
|
67
|
+
depString += `, '${framework.$.spec}'`;
|
|
68
|
+
}
|
|
69
|
+
if (!frameworkDeps.includes(depString)) {
|
|
70
|
+
frameworkDeps.push(depString);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
prefsArray = prefsArray.concat((0, plugin_1.getAllElements)(plugin, platform, 'preference'));
|
|
75
|
+
const podspecs = (0, plugin_1.getPlatformElement)(plugin, platform, 'podspec');
|
|
76
|
+
podspecs.map((podspec) => {
|
|
77
|
+
podspec.pods.map((pods) => {
|
|
78
|
+
pods.pod.map((pod) => {
|
|
79
|
+
let depString = `s.dependency '${pod.$.name}'`;
|
|
80
|
+
if (pod.$.spec && pod.$.spec !== '') {
|
|
81
|
+
depString += `, '${pod.$.spec}'`;
|
|
82
|
+
}
|
|
83
|
+
if (!frameworkDeps.includes(depString)) {
|
|
84
|
+
frameworkDeps.push(depString);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
const sourceFiles = (0, plugin_1.getPlatformElement)(plugin, platform, 'source-file');
|
|
90
|
+
sourceFiles.map((sourceFile) => {
|
|
91
|
+
if (sourceFile.$.framework && sourceFile.$.framework === 'true') {
|
|
92
|
+
let fileName = sourceFile.$.src.split('/').pop();
|
|
93
|
+
if (!fileName.startsWith('lib')) {
|
|
94
|
+
fileName = 'lib' + fileName;
|
|
95
|
+
}
|
|
96
|
+
const frameworktPath = (0, path_1.join)(sourcesFolderName, plugin.name, fileName);
|
|
97
|
+
if (!sourceFrameworks.includes(frameworktPath)) {
|
|
98
|
+
sourceFrameworks.push(frameworktPath);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else if (sourceFile.$['compiler-flags']) {
|
|
102
|
+
const cFlag = sourceFile.$['compiler-flags'];
|
|
103
|
+
if (!compilerFlags.includes(cFlag)) {
|
|
104
|
+
compilerFlags.push(cFlag);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
const onlySystemLibraries = systemLibraries.filter((library) => removeNoSystem(library, sourceFrameworks));
|
|
110
|
+
if (weakFrameworks.length > 0) {
|
|
111
|
+
frameworkDeps.push(`s.weak_frameworks = '${weakFrameworks.join(`', '`)}'`);
|
|
112
|
+
}
|
|
113
|
+
if (linkedFrameworks.length > 0) {
|
|
114
|
+
frameworkDeps.push(`s.frameworks = '${linkedFrameworks.join(`', '`)}'`);
|
|
115
|
+
}
|
|
116
|
+
if (onlySystemLibraries.length > 0) {
|
|
117
|
+
frameworkDeps.push(`s.libraries = '${onlySystemLibraries.join(`', '`)}'`);
|
|
118
|
+
}
|
|
119
|
+
if (customFrameworks.length > 0) {
|
|
120
|
+
frameworkDeps.push(`s.vendored_frameworks = '${customFrameworks.join(`', '`)}'`);
|
|
121
|
+
frameworkDeps.push(`s.exclude_files = 'sources/**/*.framework/Headers/*.h', 'sources/**/*.framework/PrivateHeaders/*.h'`);
|
|
122
|
+
}
|
|
123
|
+
if (sourceFrameworks.length > 0) {
|
|
124
|
+
frameworkDeps.push(`s.vendored_libraries = '${sourceFrameworks.join(`', '`)}'`);
|
|
125
|
+
}
|
|
126
|
+
if (compilerFlags.length > 0) {
|
|
127
|
+
frameworkDeps.push(`s.compiler_flags = '${compilerFlags.join(' ')}'`);
|
|
128
|
+
}
|
|
129
|
+
const arcPlugins = cordovaPlugins.filter(filterARCFiles);
|
|
130
|
+
if (arcPlugins.length > 0) {
|
|
131
|
+
frameworkDeps.push(`s.subspec 'noarc' do |sna|
|
|
132
|
+
sna.requires_arc = false
|
|
133
|
+
sna.source_files = 'noarc/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
134
|
+
end`);
|
|
135
|
+
}
|
|
136
|
+
let frameworksString = frameworkDeps.join('\n ');
|
|
137
|
+
frameworksString = await replaceFrameworkVariables(config, prefsArray, frameworksString);
|
|
138
|
+
const content = `
|
|
139
|
+
Pod::Spec.new do |s|
|
|
140
|
+
s.name = '${name}'
|
|
141
|
+
s.version = '${config.cli.package.version}'
|
|
142
|
+
s.summary = 'Autogenerated spec'
|
|
143
|
+
s.license = 'Unknown'
|
|
144
|
+
s.homepage = 'https://example.com'
|
|
145
|
+
s.authors = { 'Capacitor Generator' => 'hi@example.com' }
|
|
146
|
+
s.source = { :git => 'https://github.com/ionic-team/does-not-exist.git', :tag => '${config.cli.package.version}' }
|
|
147
|
+
s.source_files = '${sourcesFolderName}/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
148
|
+
s.ios.deployment_target = '${config.ios.minVersion}'
|
|
149
|
+
s.xcconfig = {'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1 WK_WEB_VIEW_ONLY=1' }
|
|
150
|
+
s.dependency 'CapacitorCordova'${getLinkerFlags(config)}
|
|
151
|
+
s.swift_version = '5.1'
|
|
152
|
+
${frameworksString}
|
|
153
|
+
end`;
|
|
154
|
+
await (0, fs_extra_1.writeFile)((0, path_1.join)(config.ios.cordovaPluginsDirAbs, `${name}.podspec`), content);
|
|
155
|
+
}
|
|
156
|
+
exports.generateCordovaPodspec = generateCordovaPodspec;
|
|
157
|
+
function getLinkerFlags(config) {
|
|
158
|
+
var _a;
|
|
159
|
+
if ((_a = config.app.extConfig.ios) === null || _a === void 0 ? void 0 : _a.cordovaLinkerFlags) {
|
|
160
|
+
return `\n s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '${config.app.extConfig.ios.cordovaLinkerFlags.join(' ')}' }`;
|
|
161
|
+
}
|
|
162
|
+
return '';
|
|
163
|
+
}
|
|
164
|
+
async function copyPluginsNativeFiles(config, cordovaPlugins) {
|
|
165
|
+
for (const p of cordovaPlugins) {
|
|
166
|
+
const sourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'source-file');
|
|
167
|
+
const headerFiles = (0, plugin_1.getPlatformElement)(p, platform, 'header-file');
|
|
168
|
+
const codeFiles = sourceFiles.concat(headerFiles);
|
|
169
|
+
const frameworks = (0, plugin_1.getPlatformElement)(p, platform, 'framework');
|
|
170
|
+
let sourcesFolderName = 'sources';
|
|
171
|
+
if ((0, cordova_1.needsStaticPod)(p)) {
|
|
172
|
+
sourcesFolderName += 'static';
|
|
173
|
+
}
|
|
174
|
+
const sourcesFolder = (0, path_1.join)(config.ios.cordovaPluginsDirAbs, sourcesFolderName, p.name);
|
|
175
|
+
for (const codeFile of codeFiles) {
|
|
176
|
+
let fileName = codeFile.$.src.split('/').pop();
|
|
177
|
+
const fileExt = codeFile.$.src.split('.').pop();
|
|
178
|
+
if (fileExt === 'a' && !fileName.startsWith('lib')) {
|
|
179
|
+
fileName = 'lib' + fileName;
|
|
180
|
+
}
|
|
181
|
+
let destFolder = sourcesFolderName;
|
|
182
|
+
if (codeFile.$['compiler-flags'] && codeFile.$['compiler-flags'] === '-fno-objc-arc') {
|
|
183
|
+
destFolder = 'noarc';
|
|
184
|
+
}
|
|
185
|
+
const filePath = (0, plugin_1.getFilePath)(config, p, codeFile.$.src);
|
|
186
|
+
const fileDest = (0, path_1.join)(config.ios.cordovaPluginsDirAbs, destFolder, p.name, fileName);
|
|
187
|
+
await (0, fs_extra_1.copy)(filePath, fileDest);
|
|
188
|
+
if (!codeFile.$.framework) {
|
|
189
|
+
let fileContent = await (0, fs_extra_1.readFile)(fileDest, { encoding: 'utf-8' });
|
|
190
|
+
if (fileExt === 'swift') {
|
|
191
|
+
fileContent = 'import Cordova\n' + fileContent;
|
|
192
|
+
await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
if (fileContent.includes('@import Firebase;')) {
|
|
196
|
+
fileContent = fileContent.replace('@import Firebase;', '#import <Firebase/Firebase.h>');
|
|
197
|
+
await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
|
|
198
|
+
}
|
|
199
|
+
if (fileContent.includes('[NSBundle bundleForClass:[self class]]') ||
|
|
200
|
+
fileContent.includes('[NSBundle bundleForClass:[CDVCapture class]]')) {
|
|
201
|
+
fileContent = fileContent.replace('[NSBundle bundleForClass:[self class]]', '[NSBundle mainBundle]');
|
|
202
|
+
fileContent = fileContent.replace('[NSBundle bundleForClass:[CDVCapture class]]', '[NSBundle mainBundle]');
|
|
203
|
+
await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
|
|
204
|
+
}
|
|
205
|
+
if (fileContent.includes('[self.webView superview]') || fileContent.includes('self.webView.superview')) {
|
|
206
|
+
fileContent = fileContent.replace(/\[self.webView superview\]/g, 'self.viewController.view');
|
|
207
|
+
fileContent = fileContent.replace(/self.webView.superview/g, 'self.viewController.view');
|
|
208
|
+
await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const resourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'resource-file');
|
|
214
|
+
for (const resourceFile of resourceFiles) {
|
|
215
|
+
const fileName = resourceFile.$.src.split('/').pop();
|
|
216
|
+
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(config.ios.cordovaPluginsDirAbs, 'resources', fileName));
|
|
217
|
+
}
|
|
218
|
+
for (const framework of frameworks) {
|
|
219
|
+
if (framework.$.custom && framework.$.custom === 'true') {
|
|
220
|
+
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, framework.$.src), (0, path_1.join)(sourcesFolder, framework.$.src));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exports.copyPluginsNativeFiles = copyPluginsNativeFiles;
|
|
226
|
+
async function removePluginsNativeFiles(config) {
|
|
227
|
+
await (0, fs_extra_1.remove)(config.ios.cordovaPluginsDirAbs);
|
|
228
|
+
await (0, template_1.extractTemplate)(config.cli.assets.ios.cordovaPluginsTemplateArchiveAbs, config.ios.cordovaPluginsDirAbs);
|
|
229
|
+
}
|
|
230
|
+
exports.removePluginsNativeFiles = removePluginsNativeFiles;
|
|
231
|
+
function filterARCFiles(plugin) {
|
|
232
|
+
const sources = (0, plugin_1.getPlatformElement)(plugin, platform, 'source-file');
|
|
233
|
+
const sourcesARC = sources.filter((sourceFile) => sourceFile.$['compiler-flags'] && sourceFile.$['compiler-flags'] === '-fno-objc-arc');
|
|
234
|
+
return sourcesARC.length > 0;
|
|
235
|
+
}
|
|
236
|
+
exports.filterARCFiles = filterARCFiles;
|
|
237
|
+
function removeNoSystem(library, sourceFrameworks) {
|
|
238
|
+
const libraries = sourceFrameworks.filter((framework) => framework.includes(library));
|
|
239
|
+
return libraries.length === 0;
|
|
240
|
+
}
|
|
241
|
+
async function replaceFrameworkVariables(config, prefsArray, frameworkString) {
|
|
242
|
+
prefsArray.map((preference) => {
|
|
243
|
+
frameworkString = frameworkString.replace(new RegExp(('$' + preference.$.name).replace('$', '\\$&'), 'g'), preference.$.default);
|
|
244
|
+
});
|
|
245
|
+
return frameworkString;
|
|
246
|
+
}
|
|
247
|
+
function getFrameworkName(framework) {
|
|
248
|
+
if (isFramework(framework)) {
|
|
249
|
+
if (framework.$.custom && framework.$.custom === 'true') {
|
|
250
|
+
return framework.$.src;
|
|
251
|
+
}
|
|
252
|
+
return framework.$.src.substr(0, framework.$.src.indexOf('.'));
|
|
253
|
+
}
|
|
254
|
+
return framework.$.src.substr(0, framework.$.src.indexOf('.')).replace('lib', '');
|
|
255
|
+
}
|
|
256
|
+
function isFramework(framework) {
|
|
257
|
+
return framework.$.src.split('.').pop().includes('framework');
|
|
258
|
+
}
|
|
259
|
+
function cordovaPodfileLines(config, plugins) {
|
|
260
|
+
const pods = [];
|
|
261
|
+
const cordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 1 /* PluginType.Cordova */);
|
|
262
|
+
cordovaPlugins.map(async (p) => {
|
|
263
|
+
const podspecs = (0, plugin_1.getPlatformElement)(p, platform, 'podspec');
|
|
264
|
+
podspecs.map((podspec) => {
|
|
265
|
+
podspec.pods.map((pPods) => {
|
|
266
|
+
pPods.pod.map((pod) => {
|
|
267
|
+
if (pod.$.git) {
|
|
268
|
+
let gitRef = '';
|
|
269
|
+
if (pod.$.tag) {
|
|
270
|
+
gitRef = `, :tag => '${pod.$.tag}'`;
|
|
271
|
+
}
|
|
272
|
+
else if (pod.$.branch) {
|
|
273
|
+
gitRef = `, :branch => '${pod.$.branch}'`;
|
|
274
|
+
}
|
|
275
|
+
else if (pod.$.commit) {
|
|
276
|
+
gitRef = `, :commit => '${pod.$.commit}'`;
|
|
277
|
+
}
|
|
278
|
+
pods.push(` pod '${pod.$.name}', :git => '${pod.$.git}'${gitRef}\n`);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
const staticPlugins = cordovaPlugins.filter((p) => (0, cordova_1.needsStaticPod)(p));
|
|
285
|
+
const noStaticPlugins = cordovaPlugins.filter((el) => !staticPlugins.includes(el));
|
|
286
|
+
if (noStaticPlugins.length > 0) {
|
|
287
|
+
pods.push(` pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'\n`);
|
|
288
|
+
}
|
|
289
|
+
if (staticPlugins.length > 0) {
|
|
290
|
+
pods.push(` pod 'CordovaPluginsStatic', :path => '../capacitor-cordova-ios-plugins'\n`);
|
|
291
|
+
}
|
|
292
|
+
const resourcesPlugins = cordovaPlugins.filter(filterResources);
|
|
293
|
+
if (resourcesPlugins.length > 0) {
|
|
294
|
+
pods.push(` pod 'CordovaPluginsResources', :path => '../capacitor-cordova-ios-plugins'\n`);
|
|
295
|
+
}
|
|
296
|
+
return pods;
|
|
297
|
+
}
|
|
298
|
+
exports.cordovaPodfileLines = cordovaPodfileLines;
|
|
299
|
+
function filterResources(plugin) {
|
|
300
|
+
const resources = (0, plugin_1.getPlatformElement)(plugin, platform, 'resource-file');
|
|
301
|
+
return resources.length > 0;
|
|
302
|
+
}
|
|
303
|
+
async function generateCordovaPackageFiles(cordovaPlugins, config) {
|
|
304
|
+
cordovaPlugins.map((plugin) => {
|
|
305
|
+
generateCordovaPackageFile(plugin, config);
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
exports.generateCordovaPackageFiles = generateCordovaPackageFiles;
|
|
309
|
+
async function generateCordovaPackageFile(p, config) {
|
|
310
|
+
const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
|
|
311
|
+
const iosVersion = (0, common_2.getMajoriOSVersion)(config);
|
|
312
|
+
const headerFiles = (0, plugin_1.getPlatformElement)(p, platform, 'header-file');
|
|
313
|
+
let headersText = '';
|
|
314
|
+
if (headerFiles.length > 0) {
|
|
315
|
+
headersText = `,
|
|
316
|
+
publicHeadersPath: "."`;
|
|
317
|
+
}
|
|
318
|
+
const content = `// swift-tools-version: 5.9
|
|
319
|
+
|
|
320
|
+
import PackageDescription
|
|
321
|
+
|
|
322
|
+
let package = Package(
|
|
323
|
+
name: "${p.name}",
|
|
324
|
+
platforms: [.iOS(.v${iosVersion})],
|
|
325
|
+
products: [
|
|
326
|
+
.library(
|
|
327
|
+
name: "${p.name}",
|
|
328
|
+
targets: ["${p.name}"]
|
|
329
|
+
)
|
|
330
|
+
],
|
|
331
|
+
dependencies: [
|
|
332
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "${iosPlatformVersion}")
|
|
333
|
+
],
|
|
334
|
+
targets: [
|
|
335
|
+
.target(
|
|
336
|
+
name: "${p.name}",
|
|
337
|
+
dependencies: [
|
|
338
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
339
|
+
],
|
|
340
|
+
path: "."${headersText}
|
|
341
|
+
)
|
|
342
|
+
]
|
|
343
|
+
)`;
|
|
344
|
+
await (0, fs_extra_1.writeFile)((0, path_1.join)(config.ios.cordovaPluginsDirAbs, 'sources', p.name, 'Package.swift'), content);
|
|
345
|
+
}
|
|
346
|
+
exports.generateCordovaPackageFile = generateCordovaPackageFile;
|
package/dist/util/iosplugin.js
CHANGED
|
@@ -60,6 +60,7 @@ async function generateIOSPackageJSON(config, plugins) {
|
|
|
60
60
|
const cordovaPlugins = await (0, cordova_1.getCordovaPlugins)(config, 'ios');
|
|
61
61
|
if (cordovaPlugins.length > 0) {
|
|
62
62
|
classList.push('CDVPlugin');
|
|
63
|
+
classList.push('CordovaPlugin');
|
|
63
64
|
}
|
|
64
65
|
writePluginJSON(config, classList);
|
|
65
66
|
}
|
package/dist/util/livereload.js
CHANGED
|
@@ -93,8 +93,7 @@ class CapLiveReload {
|
|
|
93
93
|
.filter(Boolean);
|
|
94
94
|
return !all.length ? loopback(family) : all[0];
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
async editExtConfigForLiveReload(config, platformName, options, rootConfigChange = false) {
|
|
96
|
+
async editCapConfigForLiveReload(config, platformName, options) {
|
|
98
97
|
const platformAbsPath = platformName == config.ios.name
|
|
99
98
|
? config.ios.nativeTargetDirAbs
|
|
100
99
|
: platformName == config.android.name
|
|
@@ -102,35 +101,13 @@ class CapLiveReload {
|
|
|
102
101
|
: null;
|
|
103
102
|
if (platformAbsPath == null)
|
|
104
103
|
throw new Error('Platform not found.');
|
|
105
|
-
const capConfigPath =
|
|
106
|
-
? config.app.extConfigFilePath
|
|
107
|
-
: (0, path_1.join)(platformAbsPath, 'capacitor.config.json');
|
|
108
|
-
const configJson = { ...config.app.extConfig };
|
|
109
|
-
this.configJsonToRevertTo.json = JSON.stringify(configJson, null, 2);
|
|
110
|
-
this.configJsonToRevertTo.platformPath = capConfigPath;
|
|
111
|
-
const url = `http://${options.host}:${options.port}`;
|
|
112
|
-
configJson.server = {
|
|
113
|
-
url,
|
|
114
|
-
};
|
|
115
|
-
return configJson;
|
|
116
|
-
}
|
|
117
|
-
// TODO remove rootConfigChange param on next major as it's unused
|
|
118
|
-
async editCapConfigForLiveReload(config, platformName, options, rootConfigChange = false) {
|
|
119
|
-
const platformAbsPath = platformName == config.ios.name
|
|
120
|
-
? config.ios.nativeTargetDirAbs
|
|
121
|
-
: platformName == config.android.name
|
|
122
|
-
? config.android.assetsDirAbs
|
|
123
|
-
: null;
|
|
124
|
-
if (platformAbsPath == null)
|
|
125
|
-
throw new Error('Platform not found.');
|
|
126
|
-
const capConfigPath = rootConfigChange
|
|
127
|
-
? config.app.extConfigFilePath
|
|
128
|
-
: (0, path_1.join)(platformAbsPath, 'capacitor.config.json');
|
|
104
|
+
const capConfigPath = (0, path_1.join)(platformAbsPath, 'capacitor.config.json');
|
|
129
105
|
const configJson = (0, fs_extra_1.readJSONSync)(capConfigPath);
|
|
130
106
|
this.configJsonToRevertTo.json = JSON.stringify(configJson, null, 2);
|
|
131
107
|
this.configJsonToRevertTo.platformPath = capConfigPath;
|
|
132
108
|
const url = `http://${options.host}:${options.port}`;
|
|
133
109
|
configJson.server = {
|
|
110
|
+
...configJson.server,
|
|
134
111
|
url,
|
|
135
112
|
};
|
|
136
113
|
(0, fs_extra_1.writeJSONSync)(capConfigPath, configJson, { spaces: '\t' });
|
package/dist/util/spm.js
CHANGED
|
@@ -7,6 +7,7 @@ const path_1 = require("path");
|
|
|
7
7
|
const plist_1 = require("plist");
|
|
8
8
|
const tar_1 = require("tar");
|
|
9
9
|
const common_1 = require("../common");
|
|
10
|
+
const cordova_1 = require("../cordova");
|
|
10
11
|
const errors_1 = require("../errors");
|
|
11
12
|
const common_2 = require("../ios/common");
|
|
12
13
|
const log_1 = require("../log");
|
|
@@ -87,6 +88,8 @@ async function generatePackageText(config, plugins) {
|
|
|
87
88
|
var _a, _b, _c;
|
|
88
89
|
const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
|
|
89
90
|
const iosVersion = (0, common_2.getMajoriOSVersion)(config);
|
|
91
|
+
const cordovaPlugins = await (0, cordova_1.getCordovaPlugins)(config, 'ios');
|
|
92
|
+
const enableCordova = cordovaPlugins.length > 0;
|
|
90
93
|
let packageSwiftText = `// swift-tools-version: 5.9
|
|
91
94
|
import PackageDescription
|
|
92
95
|
|
|
@@ -116,8 +119,10 @@ let package = Package(
|
|
|
116
119
|
.target(
|
|
117
120
|
name: "CapApp-SPM",
|
|
118
121
|
dependencies: [
|
|
119
|
-
.product(name: "Capacitor", package: "capacitor-swift-pm")
|
|
120
|
-
|
|
122
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),`;
|
|
123
|
+
if (enableCordova) {
|
|
124
|
+
packageSwiftText += ` .product(name: "Cordova", package: "capacitor-swift-pm")`;
|
|
125
|
+
}
|
|
121
126
|
for (const plugin of plugins) {
|
|
122
127
|
packageSwiftText += `,\n .product(name: "${(_b = plugin.ios) === null || _b === void 0 ? void 0 : _b.name}", package: "${(_c = plugin.ios) === null || _c === void 0 ? void 0 : _c.name}")`;
|
|
123
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/cli",
|
|
3
|
-
"version": "8.1.0",
|
|
3
|
+
"version": "8.1.1-dev-20260305T152829.0",
|
|
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)",
|