@capacitor/cli 8.3.2-nightly-20260507T154821.0 → 9.0.0-alpha.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.
Binary file
Binary file
Binary file
@@ -9,6 +9,7 @@ const colors_1 = tslib_1.__importDefault(require("../colors"));
9
9
  const common_1 = require("../common");
10
10
  const cordova_1 = require("../cordova");
11
11
  const errors_1 = require("../errors");
12
+ const log_1 = require("../log");
12
13
  const plugin_1 = require("../plugin");
13
14
  const copy_1 = require("../tasks/copy");
14
15
  const fs_1 = require("../util/fs");
@@ -22,10 +23,12 @@ async function updateAndroid(config) {
22
23
  const plugins = await getPluginsTask(config);
23
24
  const capacitorPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 0 /* PluginType.Core */);
24
25
  (0, plugin_1.printPlugins)(capacitorPlugins, 'android');
25
- await writePluginsJson(config, capacitorPlugins);
26
- await removePluginsNativeFiles(config);
27
26
  const cordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 1 /* PluginType.Cordova */);
28
- if (cordovaPlugins.length > 0) {
27
+ const enableCordova = cordovaPlugins.length > 0;
28
+ await writePluginsJson(config, capacitorPlugins, enableCordova);
29
+ await removePluginsNativeFiles(config);
30
+ if (enableCordova) {
31
+ log_1.logger.info('Found Cordova Plugins: Including Android Cordova Support');
29
32
  await copyPluginsNativeFiles(config, cordovaPlugins);
30
33
  }
31
34
  if (!(await (0, fs_extra_1.pathExists)(config.android.webDirAbs))) {
@@ -34,8 +37,10 @@ async function updateAndroid(config) {
34
37
  await (0, cordova_1.handleCordovaPluginsJS)(cordovaPlugins, config, platform);
35
38
  await (0, cordova_1.checkPluginDependencies)(plugins, platform, (_a = config.app.extConfig.cordova) === null || _a === void 0 ? void 0 : _a.failOnUninstalledPlugins);
36
39
  await installGradlePlugins(config, capacitorPlugins, cordovaPlugins);
37
- await handleCordovaPluginsGradle(config, cordovaPlugins);
38
- await (0, cordova_1.writeCordovaAndroidManifest)(cordovaPlugins, config, platform);
40
+ if (enableCordova) {
41
+ await handleCordovaPluginsGradle(config, cordovaPlugins);
42
+ await (0, cordova_1.writeCordovaAndroidManifest)(cordovaPlugins, config, platform);
43
+ }
39
44
  const incompatibleCordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 2 /* PluginType.Incompatible */);
40
45
  (0, plugin_1.printPlugins)(incompatibleCordovaPlugins, platform, 'incompatible');
41
46
  await (0, common_1.checkPlatformVersions)(config, platform);
@@ -44,8 +49,14 @@ exports.updateAndroid = updateAndroid;
44
49
  function getGradlePackageName(id) {
45
50
  return id.replace('@', '').replace('/', '-');
46
51
  }
47
- async function writePluginsJson(config, plugins) {
52
+ async function writePluginsJson(config, plugins, includeCordova) {
48
53
  const classes = await findAndroidPluginClasses(plugins);
54
+ if (includeCordova) {
55
+ classes.push({
56
+ pkg: '@capacitor/android',
57
+ classpath: 'com.getcapacitor.cordova.CordovaPlugin',
58
+ });
59
+ }
49
60
  const pluginsJsonPath = (0, path_1.resolve)(config.android.assetsDirAbs, 'capacitor.plugins.json');
50
61
  await (0, fs_extra_1.writeJSON)(pluginsJsonPath, classes, { spaces: '\t' });
51
62
  }
@@ -96,13 +107,25 @@ async function installGradlePlugins(config, capacitorPlugins, cordovaPlugins) {
96
107
  (0, errors_1.fatal)(`Unable to find ${colors_1.default.strong('node_modules/@capacitor/android')}.\n` +
97
108
  `Are you sure ${colors_1.default.strong('@capacitor/android')} is installed?`);
98
109
  }
110
+ const enableCordova = cordovaPlugins.length > 0;
99
111
  const capacitorAndroidPath = (0, path_1.resolve)((0, path_1.dirname)(capacitorAndroidPackagePath), 'capacitor');
112
+ const capacitorCordovaAndroidPath = (0, path_1.resolve)((0, path_1.dirname)(capacitorAndroidPackagePath), 'capacitor-cordova');
100
113
  const settingsPath = config.android.platformDirAbs;
101
114
  const dependencyPath = config.android.appDirAbs;
102
115
  const relativeCapcitorAndroidPath = (0, fs_1.convertToUnixPath)((0, path_1.relative)(settingsPath, capacitorAndroidPath));
116
+ const relativeCapacitorCordovaAndroidPath = (0, fs_1.convertToUnixPath)((0, path_1.relative)(settingsPath, capacitorCordovaAndroidPath));
117
+ const cdvIncludeText = enableCordova
118
+ ? `
119
+ include ':capacitor-cordova-android'
120
+ project(':capacitor-cordova-android').projectDir = new File('${relativeCapacitorCordovaAndroidPath}')
121
+
122
+ include ':capacitor-cordova-android-plugins'
123
+ project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/')`
124
+ : '';
103
125
  const settingsLines = `// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
104
126
  include ':capacitor-android'
105
127
  project(':capacitor-android').projectDir = new File('${relativeCapcitorAndroidPath}')
128
+ ${cdvIncludeText}
106
129
  ${capacitorPlugins
107
130
  .map((p) => {
108
131
  if (!p.android) {
@@ -139,6 +162,20 @@ project(':${getGradlePackageName(p.id)}').projectDir = new File('${relativePlugi
139
162
  });
140
163
  prefsArray = prefsArray.concat((0, plugin_1.getAllElements)(p, platform, 'preference'));
141
164
  });
165
+ const cdvRepoApplyText = enableCordova
166
+ ? `
167
+ repositories {
168
+ flatDir{
169
+ dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
170
+ }
171
+ }
172
+
173
+ apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
174
+ `
175
+ : '';
176
+ const cdvDependencyText = enableCordova
177
+ ? ` implementation project(':capacitor-cordova-android')\n implementation project(':capacitor-cordova-android-plugins')\n`
178
+ : '';
142
179
  let frameworkString = frameworksArray.join('\n');
143
180
  frameworkString = await replaceFrameworkVariables(config, prefsArray, frameworkString);
144
181
  const dependencyLines = `// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
@@ -149,10 +186,9 @@ android {
149
186
  targetCompatibility JavaVersion.VERSION_21
150
187
  }
151
188
  }
152
-
153
- apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
189
+ ${cdvRepoApplyText}
154
190
  dependencies {
155
- ${capacitorPlugins
191
+ ${cdvDependencyText}${capacitorPlugins
156
192
  .map((p) => {
157
193
  return ` implementation project(':${getGradlePackageName(p.id)}')`;
158
194
  })
@@ -11,13 +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 migrate_1 = require("../tasks/migrate");
14
+ const cordova_ios_1 = require("../util/cordova-ios");
15
15
  const fs_1 = require("../util/fs");
16
16
  const iosplugin_1 = require("../util/iosplugin");
17
17
  const node_1 = require("../util/node");
18
18
  const spm_1 = require("../util/spm");
19
19
  const subprocess_1 = require("../util/subprocess");
20
- const template_1 = require("../util/template");
21
20
  const common_2 = require("./common");
22
21
  const platform = 'ios';
23
22
  async function updateIOS(config, deployment) {
@@ -31,10 +30,12 @@ async function updateIOS(config, deployment) {
31
30
  exports.updateIOS = updateIOS;
32
31
  async function updatePluginFiles(config, plugins, deployment) {
33
32
  var _a;
34
- await removePluginsNativeFiles(config);
33
+ await (0, cordova_ios_1.removePluginsNativeFiles)(config);
35
34
  const cordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 1 /* PluginType.Cordova */);
36
- if (cordovaPlugins.length > 0) {
37
- await copyPluginsNativeFiles(config, cordovaPlugins);
35
+ const enableCordova = cordovaPlugins.length > 0;
36
+ if (enableCordova) {
37
+ log_1.logger.info('Found Cordova Plugins: Including iOS Cordova Support');
38
+ await (0, cordova_ios_1.copyPluginsNativeFiles)(config, cordovaPlugins);
38
39
  }
39
40
  if (!(await (0, fs_extra_1.pathExists)(await config.ios.webDirAbs))) {
40
41
  await (0, copy_1.copy)(config, platform);
@@ -42,218 +43,38 @@ async function updatePluginFiles(config, plugins, deployment) {
42
43
  await (0, cordova_1.handleCordovaPluginsJS)(cordovaPlugins, config, platform);
43
44
  await (0, cordova_1.checkPluginDependencies)(plugins, platform, (_a = config.app.extConfig.cordova) === null || _a === void 0 ? void 0 : _a.failOnUninstalledPlugins);
44
45
  if ((await config.ios.packageManager) === 'SPM') {
45
- await generateCordovaPackageFiles(cordovaPlugins, config);
46
+ if (enableCordova) {
47
+ await (0, cordova_ios_1.generateCordovaPackageFiles)(cordovaPlugins, config);
48
+ }
46
49
  const validSPMPackages = await (0, spm_1.checkPluginsForPackageSwift)(config, plugins);
47
50
  await (0, spm_1.generatePackageFile)(config, validSPMPackages.concat(cordovaPlugins));
48
51
  }
49
52
  else {
50
- await generateCordovaPodspecs(cordovaPlugins, config);
51
- await installCocoaPodsPlugins(config, plugins, deployment);
52
- }
53
- await (0, cordova_1.logCordovaManualSteps)(cordovaPlugins, config, platform);
54
- const incompatibleCordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 2 /* PluginType.Incompatible */);
55
- (0, plugin_1.printPlugins)(incompatibleCordovaPlugins, platform, 'incompatible');
56
- }
57
- async function generateCordovaPackageFiles(cordovaPlugins, config) {
58
- cordovaPlugins.map((plugin) => {
59
- generateCordovaPackageFile(plugin, config);
60
- });
61
- }
62
- async function generateCordovaPackageFile(p, config) {
63
- var _a;
64
- const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
65
- const platformTag = (0, plugin_1.getPluginPlatform)(p, platform);
66
- if ((_a = platformTag.$) === null || _a === void 0 ? void 0 : _a.package) {
67
- const packageSwiftPath = (0, path_1.join)(p.rootPath, 'Package.swift');
68
- let content = await (0, fs_extra_1.readFile)(packageSwiftPath, { encoding: 'utf-8' });
69
- content = content.replace(`apache`, `ionic-team`).replaceAll(`cordova-ios`, `capacitor-swift-pm`);
70
- content = (0, migrate_1.setAllStringIn)(content, `url: "https://github.com/ionic-team/capacitor-swift-pm.git",`, `)`, ` from: "${iosPlatformVersion}"`);
71
- await (0, fs_extra_1.writeFile)(packageSwiftPath, content);
72
- }
73
- else {
74
- await writeGeneratedPackageSwift(p, config, iosPlatformVersion);
75
- }
76
- }
77
- function buildBinaryTargetEntries(p, frameworks) {
78
- const customXcframeworks = frameworks.filter((f) => f.$.custom === 'true' && f.$.src.endsWith('.xcframework'));
79
- const customFrameworks = frameworks.filter((f) => f.$.custom === 'true' && f.$.src.endsWith('.framework'));
80
- if (customFrameworks.length > 0) {
81
- customFrameworks.forEach((f) => {
82
- log_1.logger.warn(`${p.id}: custom .framework files are not supported as binaryTarget in SPM (${f.$.src}). Convert to .xcframework for SPM compatibility.`);
83
- });
84
- }
85
- const binaryTargetsText = customXcframeworks
86
- .map((f) => {
87
- const name = f.$.src.split('/').pop().replace('.xcframework', '');
88
- return `,
89
- .binaryTarget(
90
- name: "${name}",
91
- path: "${f.$.src}"
92
- )`;
93
- })
94
- .join('');
95
- const binaryDepsText = customXcframeworks
96
- .map((f) => {
97
- const name = f.$.src.split('/').pop().replace('.xcframework', '');
98
- return `,\n .target(name: "${name}")`;
99
- })
100
- .join('');
101
- return { binaryTargetsText, binaryDepsText };
102
- }
103
- function buildResourcesText(resources) {
104
- const resourceEntry = [];
105
- for (const resource of resources) {
106
- resourceEntry.push(`.copy("resources/${resource.$.src.split('/').pop()}")`);
107
- }
108
- return resources.length > 0
109
- ? `,
110
- resources: [
111
- ${resourceEntry.join(',\n ')}
112
- ]`
113
- : '';
114
- }
115
- async function buildDependencyTexts(p, config) {
116
- let allDependencies = (0, plugin_1.getPlatformElement)(p, platform, 'dependency');
117
- if (p.xml['dependency']) {
118
- allDependencies = allDependencies.concat(p.xml['dependency']);
119
- }
120
- let packageText = '';
121
- let productText = '';
122
- await Promise.all(allDependencies.map(async (dep) => {
123
- let plugin = dep.$.id;
124
- if (plugin.includes('@') && plugin.indexOf('@') !== 0) {
125
- [plugin] = plugin.split('@');
126
- }
127
- const depPlugin = await (0, plugin_1.resolvePlugin)(config, plugin);
128
- if (depPlugin) {
129
- const headerFiles = (0, plugin_1.getPlatformElement)(depPlugin, platform, 'header-file');
130
- const resources = (0, plugin_1.getPlatformElement)(depPlugin, platform, 'resource-file');
131
- const sourceFiles = (0, plugin_1.getPlatformElement)(depPlugin, platform, 'source-file');
132
- if (sourceFiles.length === 0 && headerFiles.length === 0 && resources.length === 0) {
133
- return;
134
- }
135
- packageText += `,\n .package(name: "${depPlugin.name}", path: "../${depPlugin.name}")`;
136
- productText += `,\n .product(name: "${depPlugin.name}", package: "${depPlugin.name}")`;
137
- }
138
- }));
139
- return { packageText, productText };
140
- }
141
- function buildCSettingsText(p, sourceFiles) {
142
- var _a;
143
- const pluginId = p.id;
144
- const allFlags = new Set();
145
- for (const sourceFile of sourceFiles) {
146
- const flags = (_a = sourceFile.$) === null || _a === void 0 ? void 0 : _a['compiler-flags'];
147
- if (flags) {
148
- flags
149
- .split(/\s+/)
150
- .map((f) => f.trim())
151
- .filter((f) => f.length > 0)
152
- .forEach((f) => allFlags.add(f));
153
- }
154
- }
155
- if (allFlags.size === 0) {
156
- return '';
157
- }
158
- const entries = [];
159
- const unsupportedFlags = [];
160
- for (const flag of allFlags) {
161
- if (flag.startsWith('-D')) {
162
- const definition = flag.slice(2);
163
- const eqIndex = definition.indexOf('=');
164
- if (eqIndex !== -1) {
165
- const name = definition.slice(0, eqIndex);
166
- const value = definition.slice(eqIndex + 1);
167
- entries.push(` .define("${name}", to: "${value}")`);
168
- }
169
- else {
170
- entries.push(` .define("${definition}")`);
171
- }
172
- }
173
- else {
174
- unsupportedFlags.push(flag);
175
- }
53
+ await installCocoaPodsPlugins(config, plugins, deployment, enableCordova);
176
54
  }
177
- if (unsupportedFlags.length > 0) {
178
- log_1.logger.warn(`${pluginId}: the following compiler flags are not supported in SPM and were ignored: ${unsupportedFlags.join(', ')}. ` +
179
- `This might cause the plugin to fail to compile.`);
55
+ if (enableCordova) {
56
+ await (0, cordova_1.logCordovaManualSteps)(cordovaPlugins, config, platform);
57
+ const incompatibleCordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 2 /* PluginType.Incompatible */);
58
+ (0, plugin_1.printPlugins)(incompatibleCordovaPlugins, platform, 'incompatible');
180
59
  }
181
- if (entries.length === 0) {
182
- return '';
183
- }
184
- return `,
185
- cSettings: [
186
- ${entries.join(',\n')}
187
- ]`;
188
60
  }
189
- async function writeGeneratedPackageSwift(p, config, iosPlatformVersion) {
190
- const iosVersion = (0, common_2.getMajoriOSVersion)(config);
191
- const headerFiles = (0, plugin_1.getPlatformElement)(p, platform, 'header-file');
192
- const headersText = headerFiles.length > 0
193
- ? `,
194
- publicHeadersPath: "."`
195
- : '';
196
- const resources = (0, plugin_1.getPlatformElement)(p, platform, 'resource-file');
197
- const sourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'source-file');
198
- if (sourceFiles.length === 0 && headerFiles.length === 0 && resources.length === 0) {
199
- return;
61
+ async function installCocoaPodsPlugins(config, plugins, deployment, enableCordova) {
62
+ if (enableCordova) {
63
+ const cordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 1 /* PluginType.Cordova */);
64
+ await (0, cordova_ios_1.generateCordovaPodspecs)(cordovaPlugins, config);
200
65
  }
201
- const frameworks = (0, plugin_1.getPlatformElement)(p, platform, 'framework');
202
- const { binaryTargetsText, binaryDepsText } = buildBinaryTargetEntries(p, frameworks);
203
- const cSettingsText = buildCSettingsText(p, sourceFiles);
204
- const systemFrameworks = frameworks.filter((f) => !f.$.custom && f.$.src.endsWith('.framework'));
205
- const hasWeakFrameworks = systemFrameworks.some((f) => f.$.weak === 'true');
206
- const requiredSystemFrameworks = systemFrameworks.filter((f) => f.$.weak !== 'true');
207
- const resourcesText = buildResourcesText(resources);
208
- const libraryTypeText = hasWeakFrameworks ? `\n type: .dynamic,` : '';
209
- const linkerSettingsText = requiredSystemFrameworks.length > 0
210
- ? `,
211
- linkerSettings: [
212
- ${requiredSystemFrameworks.map((f) => ` .linkedFramework("${f.$.src.replace('.framework', '')}")`).join(',\n')}
213
- ]`
214
- : '';
215
- const { packageText, productText } = await buildDependencyTexts(p, config);
216
- const content = `// swift-tools-version: 5.9
217
-
218
- import PackageDescription
219
-
220
- let package = Package(
221
- name: "${p.name}",
222
- platforms: [.iOS(.v${iosVersion})],
223
- products: [
224
- .library(
225
- name: "${p.name}",${libraryTypeText}
226
- targets: ["${p.name}"]
227
- )
228
- ],
229
- dependencies: [
230
- .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "${iosPlatformVersion}")${packageText}
231
- ],
232
- targets: [
233
- .target(
234
- name: "${p.name}",
235
- dependencies: [
236
- .product(name: "Cordova", package: "capacitor-swift-pm")${binaryDepsText}${productText}
237
- ],
238
- path: "."${resourcesText}${headersText}${cSettingsText}${linkerSettingsText}
239
- )${binaryTargetsText}
240
- ]
241
- )`;
242
- await (0, fs_extra_1.writeFile)((0, path_1.join)(config.ios.cordovaPluginsDirAbs, 'sources', p.name, 'Package.swift'), content);
243
- }
244
- async function installCocoaPodsPlugins(config, plugins, deployment) {
245
66
  await (0, common_1.runTask)(`Updating iOS native dependencies with ${colors_1.default.input(`${await config.ios.podPath} install`)}`, () => {
246
- return updatePodfile(config, plugins, deployment);
67
+ return updatePodfile(config, plugins, deployment, enableCordova);
247
68
  });
248
69
  }
249
70
  exports.installCocoaPodsPlugins = installCocoaPodsPlugins;
250
- async function updatePodfile(config, plugins, deployment) {
251
- const dependenciesContent = await generatePodFile(config, plugins);
71
+ async function updatePodfile(config, plugins, deployment, enableCordova) {
72
+ const dependenciesContent = await generatePodFile(config, plugins, enableCordova);
252
73
  const relativeCapacitoriOSPath = await getRelativeCapacitoriOSPath(config);
253
74
  const podfilePath = (0, path_1.join)(config.ios.nativeProjectDirAbs, 'Podfile');
254
75
  let podfileContent = await (0, fs_extra_1.readFile)(podfilePath, { encoding: 'utf-8' });
255
76
  podfileContent = podfileContent.replace(/(def capacitor_pods)[\s\S]+?(\nend)/, `$1${dependenciesContent}$2`);
256
- podfileContent = podfileContent.replace(/(require_relative)[\s\S]+?(@capacitor\/ios\/scripts\/pods_helpers')/, `require_relative '${relativeCapacitoriOSPath}/scripts/pods_helpers'`);
77
+ podfileContent = podfileContent.replace(/(require_relative)[\s\S]+?(ios\/scripts\/pods_helpers')/, `require_relative '${relativeCapacitoriOSPath}/scripts/pods_helpers'`);
257
78
  await (0, fs_extra_1.writeFile)(podfilePath, podfileContent, { encoding: 'utf-8' });
258
79
  const podPath = await config.ios.podPath;
259
80
  const useBundler = (await config.ios.packageManager) === 'bundler';
@@ -288,306 +109,24 @@ async function getRelativeCapacitoriOSPath(config) {
288
109
  }
289
110
  return (0, fs_1.convertToUnixPath)((0, path_1.relative)(config.ios.nativeProjectDirAbs, await (0, fs_extra_1.realpath)((0, path_1.dirname)(capacitoriOSPath))));
290
111
  }
291
- async function generatePodFile(config, plugins) {
112
+ async function generatePodFile(config, plugins, enableCordova) {
292
113
  const relativeCapacitoriOSPath = await getRelativeCapacitoriOSPath(config);
293
114
  const capacitorPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 0 /* PluginType.Core */);
115
+ const cordovaPodlines = (0, cordova_ios_1.cordovaPodfileLines)(config, plugins);
294
116
  const pods = await Promise.all(capacitorPlugins.map(async (p) => {
295
117
  if (!p.ios) {
296
118
  return '';
297
119
  }
298
120
  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`;
299
121
  }));
300
- const cordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 1 /* PluginType.Cordova */);
301
- cordovaPlugins.map(async (p) => {
302
- const podspecs = (0, plugin_1.getPlatformElement)(p, platform, 'podspec');
303
- podspecs.map((podspec) => {
304
- podspec.pods.map((pPods) => {
305
- pPods.pod.map((pod) => {
306
- if (pod.$.git) {
307
- let gitRef = '';
308
- if (pod.$.tag) {
309
- gitRef = `, :tag => '${pod.$.tag}'`;
310
- }
311
- else if (pod.$.branch) {
312
- gitRef = `, :branch => '${pod.$.branch}'`;
313
- }
314
- else if (pod.$.commit) {
315
- gitRef = `, :commit => '${pod.$.commit}'`;
316
- }
317
- pods.push(` pod '${pod.$.name}', :git => '${pod.$.git}'${gitRef}\n`);
318
- }
319
- });
320
- });
321
- });
322
- });
323
- const staticPlugins = cordovaPlugins.filter((p) => (0, cordova_1.needsStaticPod)(p));
324
- const noStaticPlugins = cordovaPlugins.filter((el) => !staticPlugins.includes(el));
325
- if (noStaticPlugins.length > 0) {
326
- pods.push(` pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'\n`);
327
- }
328
- if (staticPlugins.length > 0) {
329
- pods.push(` pod 'CordovaPluginsStatic', :path => '../capacitor-cordova-ios-plugins'\n`);
330
- }
331
- const resourcesPlugins = cordovaPlugins.filter(filterResources);
332
- if (resourcesPlugins.length > 0) {
333
- pods.push(` pod 'CordovaPluginsResources', :path => '../capacitor-cordova-ios-plugins'\n`);
334
- }
335
- return `
336
- pod 'Capacitor', :path => '${relativeCapacitoriOSPath}'
337
- pod 'CapacitorCordova', :path => '${relativeCapacitoriOSPath}'
338
- ${pods.join('').trimRight()}`;
339
- }
340
- function getFrameworkName(framework) {
341
- if (isFramework(framework)) {
342
- if (framework.$.custom && framework.$.custom === 'true') {
343
- return framework.$.src;
344
- }
345
- return framework.$.src.substr(0, framework.$.src.indexOf('.'));
346
- }
347
- return framework.$.src.substr(0, framework.$.src.indexOf('.')).replace('lib', '');
348
- }
349
- function isFramework(framework) {
350
- return framework.$.src.split('.').pop().includes('framework');
351
- }
352
- async function generateCordovaPodspecs(cordovaPlugins, config) {
353
- const staticPlugins = cordovaPlugins.filter((p) => (0, cordova_1.needsStaticPod)(p));
354
- const noStaticPlugins = cordovaPlugins.filter((el) => !staticPlugins.includes(el));
355
- generateCordovaPodspec(noStaticPlugins, config, false);
356
- generateCordovaPodspec(staticPlugins, config, true);
357
- }
358
- async function generateCordovaPodspec(cordovaPlugins, config, isStatic) {
359
- const weakFrameworks = [];
360
- const linkedFrameworks = [];
361
- const customFrameworks = [];
362
- const systemLibraries = [];
363
- const sourceFrameworks = [];
364
- const frameworkDeps = [];
365
- const compilerFlags = [];
366
- let prefsArray = [];
367
- let name = 'CordovaPlugins';
368
- let sourcesFolderName = 'sources';
369
- if (isStatic) {
370
- name += 'Static';
371
- frameworkDeps.push('s.static_framework = true');
372
- sourcesFolderName += 'static';
373
- }
374
- cordovaPlugins.map((plugin) => {
375
- const frameworks = (0, plugin_1.getPlatformElement)(plugin, platform, 'framework');
376
- frameworks.map((framework) => {
377
- if (!framework.$.type) {
378
- const name = getFrameworkName(framework);
379
- if (isFramework(framework)) {
380
- if (framework.$.weak && framework.$.weak === 'true') {
381
- if (!weakFrameworks.includes(name)) {
382
- weakFrameworks.push(name);
383
- }
384
- }
385
- else if (framework.$.custom && framework.$.custom === 'true') {
386
- const frameworktPath = (0, path_1.join)(sourcesFolderName, plugin.name, name);
387
- if (!customFrameworks.includes(frameworktPath)) {
388
- customFrameworks.push(frameworktPath);
389
- }
390
- }
391
- else {
392
- if (!linkedFrameworks.includes(name)) {
393
- linkedFrameworks.push(name);
394
- }
395
- }
396
- }
397
- else {
398
- if (!systemLibraries.includes(name)) {
399
- systemLibraries.push(name);
400
- }
401
- }
402
- }
403
- else if (framework.$.type && framework.$.type === 'podspec') {
404
- let depString = `s.dependency '${framework.$.src}'`;
405
- if (framework.$.spec && framework.$.spec !== '') {
406
- depString += `, '${framework.$.spec}'`;
407
- }
408
- if (!frameworkDeps.includes(depString)) {
409
- frameworkDeps.push(depString);
410
- }
411
- }
412
- });
413
- prefsArray = prefsArray.concat((0, plugin_1.getAllElements)(plugin, platform, 'preference'));
414
- const podspecs = (0, plugin_1.getPlatformElement)(plugin, platform, 'podspec');
415
- podspecs.map((podspec) => {
416
- podspec.pods.map((pods) => {
417
- pods.pod.map((pod) => {
418
- let depString = `s.dependency '${pod.$.name}'`;
419
- if (pod.$.spec && pod.$.spec !== '') {
420
- depString += `, '${pod.$.spec}'`;
421
- }
422
- if (!frameworkDeps.includes(depString)) {
423
- frameworkDeps.push(depString);
424
- }
425
- });
426
- });
427
- });
428
- const sourceFiles = (0, plugin_1.getPlatformElement)(plugin, platform, 'source-file');
429
- sourceFiles.map((sourceFile) => {
430
- if (sourceFile.$.framework && sourceFile.$.framework === 'true') {
431
- let fileName = sourceFile.$.src.split('/').pop();
432
- if (!fileName.startsWith('lib')) {
433
- fileName = 'lib' + fileName;
434
- }
435
- const frameworktPath = (0, path_1.join)(sourcesFolderName, plugin.name, fileName);
436
- if (!sourceFrameworks.includes(frameworktPath)) {
437
- sourceFrameworks.push(frameworktPath);
438
- }
439
- }
440
- else if (sourceFile.$['compiler-flags']) {
441
- const cFlag = sourceFile.$['compiler-flags'];
442
- if (!compilerFlags.includes(cFlag)) {
443
- compilerFlags.push(cFlag);
444
- }
445
- }
446
- });
447
- });
448
- const onlySystemLibraries = systemLibraries.filter((library) => removeNoSystem(library, sourceFrameworks));
449
- if (weakFrameworks.length > 0) {
450
- frameworkDeps.push(`s.weak_frameworks = '${weakFrameworks.join(`', '`)}'`);
451
- }
452
- if (linkedFrameworks.length > 0) {
453
- frameworkDeps.push(`s.frameworks = '${linkedFrameworks.join(`', '`)}'`);
454
- }
455
- if (onlySystemLibraries.length > 0) {
456
- frameworkDeps.push(`s.libraries = '${onlySystemLibraries.join(`', '`)}'`);
457
- }
458
- if (customFrameworks.length > 0) {
459
- frameworkDeps.push(`s.vendored_frameworks = '${customFrameworks.join(`', '`)}'`);
460
- frameworkDeps.push(`s.exclude_files = 'sources/**/*.framework/Headers/*.h', 'sources/**/*.framework/PrivateHeaders/*.h'`);
461
- }
462
- if (sourceFrameworks.length > 0) {
463
- frameworkDeps.push(`s.vendored_libraries = '${sourceFrameworks.join(`', '`)}'`);
464
- }
465
- if (compilerFlags.length > 0) {
466
- frameworkDeps.push(`s.compiler_flags = '${compilerFlags.join(' ')}'`);
467
- }
468
- const arcPlugins = cordovaPlugins.filter(filterARCFiles);
469
- if (arcPlugins.length > 0) {
470
- frameworkDeps.push(`s.subspec 'noarc' do |sna|
471
- sna.requires_arc = false
472
- sna.source_files = 'noarc/**/*.{swift,h,m,c,cc,mm,cpp}'
473
- end`);
122
+ let podfileString = '\n';
123
+ podfileString += ` pod 'Capacitor', :path => '${relativeCapacitoriOSPath}'\n`;
124
+ if (enableCordova) {
125
+ podfileString += ` pod 'CapacitorCordova', :path => '${relativeCapacitoriOSPath}'\n`;
126
+ podfileString += cordovaPodlines.join('').trimEnd() + '\n';
474
127
  }
475
- let frameworksString = frameworkDeps.join('\n ');
476
- frameworksString = await replaceFrameworkVariables(config, prefsArray, frameworksString);
477
- const content = `
478
- Pod::Spec.new do |s|
479
- s.name = '${name}'
480
- s.version = '${config.cli.package.version}'
481
- s.summary = 'Autogenerated spec'
482
- s.license = 'Unknown'
483
- s.homepage = 'https://example.com'
484
- s.authors = { 'Capacitor Generator' => 'hi@example.com' }
485
- s.source = { :git => 'https://github.com/ionic-team/does-not-exist.git', :tag => '${config.cli.package.version}' }
486
- s.source_files = '${sourcesFolderName}/**/*.{swift,h,m,c,cc,mm,cpp}'
487
- s.ios.deployment_target = '${config.ios.minVersion}'
488
- s.xcconfig = {'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1 WK_WEB_VIEW_ONLY=1' }
489
- s.dependency 'CapacitorCordova'${getLinkerFlags(config)}
490
- s.swift_version = '5.1'
491
- ${frameworksString}
492
- end`;
493
- await (0, fs_extra_1.writeFile)((0, path_1.join)(config.ios.cordovaPluginsDirAbs, `${name}.podspec`), content);
494
- }
495
- function getLinkerFlags(config) {
496
- var _a;
497
- if ((_a = config.app.extConfig.ios) === null || _a === void 0 ? void 0 : _a.cordovaLinkerFlags) {
498
- return `\n s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '${config.app.extConfig.ios.cordovaLinkerFlags.join(' ')}' }`;
499
- }
500
- return '';
501
- }
502
- async function copyPluginsNativeFiles(config, cordovaPlugins) {
503
- var _a;
504
- const isSPM = (await config.ios.packageManager) === 'SPM';
505
- for (const p of cordovaPlugins) {
506
- const platformTag = (0, plugin_1.getPluginPlatform)(p, platform);
507
- if ((_a = platformTag.$) === null || _a === void 0 ? void 0 : _a.package) {
508
- continue;
509
- }
510
- const sourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'source-file');
511
- const headerFiles = (0, plugin_1.getPlatformElement)(p, platform, 'header-file');
512
- const codeFiles = sourceFiles.concat(headerFiles);
513
- const frameworks = (0, plugin_1.getPlatformElement)(p, platform, 'framework');
514
- let sourcesFolderName = 'sources';
515
- if (!isSPM && (0, cordova_1.needsStaticPod)(p)) {
516
- sourcesFolderName += 'static';
517
- }
518
- const sourcesFolder = (0, path_1.join)(config.ios.cordovaPluginsDirAbs, sourcesFolderName, p.name);
519
- for (const codeFile of codeFiles) {
520
- let fileName = codeFile.$.src.split('/').pop();
521
- const fileExt = codeFile.$.src.split('.').pop();
522
- if (fileExt === 'a' && !fileName.startsWith('lib')) {
523
- fileName = 'lib' + fileName;
524
- }
525
- let destFolder = sourcesFolderName;
526
- if (!isSPM && codeFile.$['compiler-flags'] && codeFile.$['compiler-flags'] === '-fno-objc-arc') {
527
- destFolder = 'noarc';
528
- }
529
- const filePath = (0, plugin_1.getFilePath)(config, p, codeFile.$.src);
530
- const fileDest = (0, path_1.join)(config.ios.cordovaPluginsDirAbs, destFolder, p.name, fileName);
531
- await (0, fs_extra_1.copy)(filePath, fileDest);
532
- if (!codeFile.$.framework) {
533
- let fileContent = await (0, fs_extra_1.readFile)(fileDest, { encoding: 'utf-8' });
534
- if (fileExt === 'swift') {
535
- fileContent = 'import Cordova\n' + fileContent;
536
- await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
537
- }
538
- else {
539
- if (fileContent.includes('@import Firebase;')) {
540
- fileContent = fileContent.replace('@import Firebase;', '#import <Firebase/Firebase.h>');
541
- await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
542
- }
543
- if (fileContent.includes('[NSBundle bundleForClass:[self class]]') ||
544
- fileContent.includes('[NSBundle bundleForClass:[CDVCapture class]]')) {
545
- const bundleName = isSPM ? 'SWIFTPM_MODULE_BUNDLE' : '[NSBundle mainBundle]';
546
- fileContent = fileContent.replace('[NSBundle bundleForClass:[self class]]', bundleName);
547
- fileContent = fileContent.replace('[NSBundle bundleForClass:[CDVCapture class]]', bundleName);
548
- await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
549
- }
550
- if (isSPM && fileContent.includes('[NSBundle mainBundle] URLForResource')) {
551
- fileContent = fileContent.replace('[NSBundle mainBundle] URLForResource', 'SWIFTPM_MODULE_BUNDLE URLForResource');
552
- await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
553
- }
554
- if (fileContent.includes('[self.webView superview]') || fileContent.includes('self.webView.superview')) {
555
- fileContent = fileContent.replace(/\[self.webView superview\]/g, 'self.viewController.view');
556
- fileContent = fileContent.replace(/self.webView.superview/g, 'self.viewController.view');
557
- await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
558
- }
559
- }
560
- }
561
- }
562
- const resourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'resource-file');
563
- for (const resourceFile of resourceFiles) {
564
- const fileName = resourceFile.$.src.split('/').pop();
565
- const rootResFolder = isSPM ? sourcesFolder : config.ios.cordovaPluginsDirAbs;
566
- await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(rootResFolder, 'resources', fileName));
567
- }
568
- for (const framework of frameworks) {
569
- if (framework.$.custom && framework.$.custom === 'true') {
570
- await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, framework.$.src), (0, path_1.join)(sourcesFolder, framework.$.src));
571
- }
572
- }
573
- }
574
- }
575
- async function removePluginsNativeFiles(config) {
576
- await (0, fs_extra_1.remove)(config.ios.cordovaPluginsDirAbs);
577
- await (0, template_1.extractTemplate)(config.cli.assets.ios.cordovaPluginsTemplateArchiveAbs, config.ios.cordovaPluginsDirAbs);
578
- }
579
- function filterResources(plugin) {
580
- const resources = (0, plugin_1.getPlatformElement)(plugin, platform, 'resource-file');
581
- return resources.length > 0;
582
- }
583
- function filterARCFiles(plugin) {
584
- const sources = (0, plugin_1.getPlatformElement)(plugin, platform, 'source-file');
585
- const sourcesARC = sources.filter((sourceFile) => sourceFile.$['compiler-flags'] && sourceFile.$['compiler-flags'] === '-fno-objc-arc');
586
- return sourcesARC.length > 0;
587
- }
588
- function removeNoSystem(library, sourceFrameworks) {
589
- const libraries = sourceFrameworks.filter((framework) => framework.includes(library));
590
- return libraries.length === 0;
128
+ podfileString += pods.join('').trimEnd();
129
+ return podfileString;
591
130
  }
592
131
  async function getPluginsTask(config) {
593
132
  return await (0, common_1.runTask)('Updating iOS plugins', async () => {
@@ -596,9 +135,3 @@ async function getPluginsTask(config) {
596
135
  return iosPlugins;
597
136
  });
598
137
  }
599
- async function replaceFrameworkVariables(config, prefsArray, frameworkString) {
600
- prefsArray.map((preference) => {
601
- frameworkString = frameworkString.replace(new RegExp(('$' + preference.$.name).replace('$', '\\$&'), 'g'), preference.$.default);
602
- });
603
- return frameworkString;
604
- }
@@ -4,7 +4,7 @@ exports.setAllStringIn = 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.rimraf.sync((0, path_1.join)(config.android.appDirAbs, 'build'));
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.rimraf.sync((0, path_1.join)(config.app.rootDir, 'node_modules/@capacitor/!(cli)'));
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']);
package/dist/tasks/run.js CHANGED
@@ -16,9 +16,6 @@ const sync_1 = require("./sync");
16
16
  async function runCommand(config, selectedPlatformName, options) {
17
17
  var _a, _b, _c;
18
18
  options.host = (_b = (_a = options.host) !== null && _a !== void 0 ? _a : livereload_1.CapLiveReloadHelper.getIpAddress()) !== null && _b !== void 0 ? _b : 'localhost';
19
- if (!options.https && !options.port) {
20
- options.port = '3000';
21
- }
22
19
  if (selectedPlatformName && !(await (0, common_1.isValidPlatform)(selectedPlatformName))) {
23
20
  const platformDir = (0, common_1.resolvePlatform)(config, selectedPlatformName);
24
21
  if (platformDir) {
@@ -0,0 +1,357 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateCordovaPackageFile = exports.generateCordovaPackageFiles = exports.cordovaPodfileLines = exports.filterARCFiles = exports.removePluginsNativeFiles = exports.copyPluginsNativeFiles = 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
+ function getLinkerFlags(config) {
157
+ var _a;
158
+ if ((_a = config.app.extConfig.ios) === null || _a === void 0 ? void 0 : _a.cordovaLinkerFlags) {
159
+ return `\n s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '${config.app.extConfig.ios.cordovaLinkerFlags.join(' ')}' }`;
160
+ }
161
+ return '';
162
+ }
163
+ async function copyPluginsNativeFiles(config, cordovaPlugins) {
164
+ var _a;
165
+ const isSPM = (await config.ios.packageManager) === 'SPM';
166
+ for (const p of cordovaPlugins) {
167
+ const platformTag = (0, plugin_1.getPluginPlatform)(p, platform);
168
+ if ((_a = platformTag.$) === null || _a === void 0 ? void 0 : _a.package) {
169
+ continue;
170
+ }
171
+ const sourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'source-file');
172
+ const headerFiles = (0, plugin_1.getPlatformElement)(p, platform, 'header-file');
173
+ const codeFiles = sourceFiles.concat(headerFiles);
174
+ const frameworks = (0, plugin_1.getPlatformElement)(p, platform, 'framework');
175
+ let sourcesFolderName = 'sources';
176
+ if (!isSPM && (0, cordova_1.needsStaticPod)(p)) {
177
+ sourcesFolderName += 'static';
178
+ }
179
+ const sourcesFolder = (0, path_1.join)(config.ios.cordovaPluginsDirAbs, sourcesFolderName, p.name);
180
+ for (const codeFile of codeFiles) {
181
+ let fileName = codeFile.$.src.split('/').pop();
182
+ const fileExt = codeFile.$.src.split('.').pop();
183
+ if (fileExt === 'a' && !fileName.startsWith('lib')) {
184
+ fileName = 'lib' + fileName;
185
+ }
186
+ let destFolder = sourcesFolderName;
187
+ if (!isSPM && codeFile.$['compiler-flags'] && codeFile.$['compiler-flags'] === '-fno-objc-arc') {
188
+ destFolder = 'noarc';
189
+ }
190
+ const filePath = (0, plugin_1.getFilePath)(config, p, codeFile.$.src);
191
+ const fileDest = (0, path_1.join)(config.ios.cordovaPluginsDirAbs, destFolder, p.name, fileName);
192
+ await (0, fs_extra_1.copy)(filePath, fileDest);
193
+ if (!codeFile.$.framework) {
194
+ let fileContent = await (0, fs_extra_1.readFile)(fileDest, { encoding: 'utf-8' });
195
+ if (fileExt === 'swift') {
196
+ fileContent = 'import Cordova\n' + fileContent;
197
+ await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
198
+ }
199
+ else {
200
+ if (fileContent.includes('@import Firebase;')) {
201
+ fileContent = fileContent.replace('@import Firebase;', '#import <Firebase/Firebase.h>');
202
+ await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
203
+ }
204
+ if (fileContent.includes('[NSBundle bundleForClass:[self class]]') ||
205
+ fileContent.includes('[NSBundle bundleForClass:[CDVCapture class]]')) {
206
+ const bundleName = isSPM ? 'SWIFTPM_MODULE_BUNDLE' : '[NSBundle mainBundle]';
207
+ fileContent = fileContent.replace('[NSBundle bundleForClass:[self class]]', bundleName);
208
+ fileContent = fileContent.replace('[NSBundle bundleForClass:[CDVCapture class]]', bundleName);
209
+ await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
210
+ }
211
+ if (isSPM && fileContent.includes('[NSBundle mainBundle] URLForResource')) {
212
+ fileContent = fileContent.replace('[NSBundle mainBundle] URLForResource', 'SWIFTPM_MODULE_BUNDLE URLForResource');
213
+ await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
214
+ }
215
+ if (fileContent.includes('[self.webView superview]') || fileContent.includes('self.webView.superview')) {
216
+ fileContent = fileContent.replace(/\[self.webView superview\]/g, 'self.viewController.view');
217
+ fileContent = fileContent.replace(/self.webView.superview/g, 'self.viewController.view');
218
+ await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
219
+ }
220
+ }
221
+ }
222
+ }
223
+ const resourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'resource-file');
224
+ for (const resourceFile of resourceFiles) {
225
+ const fileName = resourceFile.$.src.split('/').pop();
226
+ const rootResFolder = isSPM ? sourcesFolder : config.ios.cordovaPluginsDirAbs;
227
+ await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(rootResFolder, 'resources', fileName));
228
+ }
229
+ for (const framework of frameworks) {
230
+ if (framework.$.custom && framework.$.custom === 'true') {
231
+ await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, framework.$.src), (0, path_1.join)(sourcesFolder, framework.$.src));
232
+ }
233
+ }
234
+ }
235
+ }
236
+ exports.copyPluginsNativeFiles = copyPluginsNativeFiles;
237
+ async function removePluginsNativeFiles(config) {
238
+ await (0, fs_extra_1.remove)(config.ios.cordovaPluginsDirAbs);
239
+ await (0, template_1.extractTemplate)(config.cli.assets.ios.cordovaPluginsTemplateArchiveAbs, config.ios.cordovaPluginsDirAbs);
240
+ }
241
+ exports.removePluginsNativeFiles = removePluginsNativeFiles;
242
+ function filterARCFiles(plugin) {
243
+ const sources = (0, plugin_1.getPlatformElement)(plugin, platform, 'source-file');
244
+ const sourcesARC = sources.filter((sourceFile) => sourceFile.$['compiler-flags'] && sourceFile.$['compiler-flags'] === '-fno-objc-arc');
245
+ return sourcesARC.length > 0;
246
+ }
247
+ exports.filterARCFiles = filterARCFiles;
248
+ function removeNoSystem(library, sourceFrameworks) {
249
+ const libraries = sourceFrameworks.filter((framework) => framework.includes(library));
250
+ return libraries.length === 0;
251
+ }
252
+ async function replaceFrameworkVariables(config, prefsArray, frameworkString) {
253
+ prefsArray.map((preference) => {
254
+ frameworkString = frameworkString.replace(new RegExp(('$' + preference.$.name).replace('$', '\\$&'), 'g'), preference.$.default);
255
+ });
256
+ return frameworkString;
257
+ }
258
+ function getFrameworkName(framework) {
259
+ if (isFramework(framework)) {
260
+ if (framework.$.custom && framework.$.custom === 'true') {
261
+ return framework.$.src;
262
+ }
263
+ return framework.$.src.substr(0, framework.$.src.indexOf('.'));
264
+ }
265
+ return framework.$.src.substr(0, framework.$.src.indexOf('.')).replace('lib', '');
266
+ }
267
+ function isFramework(framework) {
268
+ return framework.$.src.split('.').pop().includes('framework');
269
+ }
270
+ function cordovaPodfileLines(config, plugins) {
271
+ const pods = [];
272
+ const cordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 1 /* PluginType.Cordova */);
273
+ cordovaPlugins.map(async (p) => {
274
+ const podspecs = (0, plugin_1.getPlatformElement)(p, platform, 'podspec');
275
+ podspecs.map((podspec) => {
276
+ podspec.pods.map((pPods) => {
277
+ pPods.pod.map((pod) => {
278
+ if (pod.$.git) {
279
+ let gitRef = '';
280
+ if (pod.$.tag) {
281
+ gitRef = `, :tag => '${pod.$.tag}'`;
282
+ }
283
+ else if (pod.$.branch) {
284
+ gitRef = `, :branch => '${pod.$.branch}'`;
285
+ }
286
+ else if (pod.$.commit) {
287
+ gitRef = `, :commit => '${pod.$.commit}'`;
288
+ }
289
+ pods.push(` pod '${pod.$.name}', :git => '${pod.$.git}'${gitRef}\n`);
290
+ }
291
+ });
292
+ });
293
+ });
294
+ });
295
+ const staticPlugins = cordovaPlugins.filter((p) => (0, cordova_1.needsStaticPod)(p));
296
+ const noStaticPlugins = cordovaPlugins.filter((el) => !staticPlugins.includes(el));
297
+ if (noStaticPlugins.length > 0) {
298
+ pods.push(` pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'\n`);
299
+ }
300
+ if (staticPlugins.length > 0) {
301
+ pods.push(` pod 'CordovaPluginsStatic', :path => '../capacitor-cordova-ios-plugins'\n`);
302
+ }
303
+ const resourcesPlugins = cordovaPlugins.filter(filterResources);
304
+ if (resourcesPlugins.length > 0) {
305
+ pods.push(` pod 'CordovaPluginsResources', :path => '../capacitor-cordova-ios-plugins'\n`);
306
+ }
307
+ return pods;
308
+ }
309
+ exports.cordovaPodfileLines = cordovaPodfileLines;
310
+ function filterResources(plugin) {
311
+ const resources = (0, plugin_1.getPlatformElement)(plugin, platform, 'resource-file');
312
+ return resources.length > 0;
313
+ }
314
+ async function generateCordovaPackageFiles(cordovaPlugins, config) {
315
+ cordovaPlugins.map((plugin) => {
316
+ generateCordovaPackageFile(plugin, config);
317
+ });
318
+ }
319
+ exports.generateCordovaPackageFiles = generateCordovaPackageFiles;
320
+ async function generateCordovaPackageFile(p, config) {
321
+ const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
322
+ const iosVersion = (0, common_2.getMajoriOSVersion)(config);
323
+ const headerFiles = (0, plugin_1.getPlatformElement)(p, platform, 'header-file');
324
+ let headersText = '';
325
+ if (headerFiles.length > 0) {
326
+ headersText = `,
327
+ publicHeadersPath: "."`;
328
+ }
329
+ const content = `// swift-tools-version: 5.9
330
+
331
+ import PackageDescription
332
+
333
+ let package = Package(
334
+ name: "${p.name}",
335
+ platforms: [.iOS(.v${iosVersion})],
336
+ products: [
337
+ .library(
338
+ name: "${p.name}",
339
+ targets: ["${p.name}"]
340
+ )
341
+ ],
342
+ dependencies: [
343
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "${iosPlatformVersion}")
344
+ ],
345
+ targets: [
346
+ .target(
347
+ name: "${p.name}",
348
+ dependencies: [
349
+ .product(name: "Cordova", package: "capacitor-swift-pm")
350
+ ],
351
+ path: "."${headersText}
352
+ )
353
+ ]
354
+ )`;
355
+ await (0, fs_extra_1.writeFile)((0, path_1.join)(config.ios.cordovaPluginsDirAbs, 'sources', p.name, 'Package.swift'), content);
356
+ }
357
+ exports.generateCordovaPackageFile = generateCordovaPackageFile;
@@ -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
  }
@@ -93,8 +93,7 @@ class CapLiveReload {
93
93
  .filter(Boolean);
94
94
  return !all.length ? loopback(family) : all[0];
95
95
  }
96
- // TODO remove on next major as it's unused
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,30 +101,7 @@ class CapLiveReload {
102
101
  : null;
103
102
  if (platformAbsPath == null)
104
103
  throw new Error('Platform not found.');
105
- const capConfigPath = rootConfigChange
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;
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, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
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
  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 : {};
91
94
  const swiftToolsVersion = (_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.swiftToolsVersion) !== null && _h !== void 0 ? _h : '5.9';
92
95
  let packageSwiftText = `// swift-tools-version: ${swiftToolsVersion}
@@ -139,8 +142,10 @@ let package = Package(
139
142
  .target(
140
143
  name: "CapApp-SPM",
141
144
  dependencies: [
142
- .product(name: "Capacitor", package: "capacitor-swift-pm"),
143
- .product(name: "Cordova", package: "capacitor-swift-pm")`;
145
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),`;
146
+ if (enableCordova) {
147
+ packageSwiftText += ` .product(name: "Cordova", package: "capacitor-swift-pm")`;
148
+ }
144
149
  for (const plugin of plugins) {
145
150
  let pluginText = `,\n .product(name: "${(_l = plugin.ios) === null || _l === void 0 ? void 0 : _l.name}", package: "${(_m = plugin.ios) === null || _m === void 0 ? void 0 : _m.name}")`;
146
151
  if ((0, plugin_1.getPluginType)(plugin, config.ios.name) === 1 /* PluginType.Cordova */) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/cli",
3
- "version": "8.3.2-nightly-20260507T154821.0",
3
+ "version": "9.0.0-alpha.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)",