@capacitor-plus/cli 8.3.2 → 8.3.4

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
@@ -100,6 +100,44 @@ function buildBinaryTargetEntries(p, frameworks) {
100
100
  .join('');
101
101
  return { binaryTargetsText, binaryDepsText };
102
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
+ }
103
141
  function buildCSettingsText(p, sourceFiles) {
104
142
  var _a;
105
143
  const pluginId = p.id;
@@ -155,8 +193,9 @@ async function writeGeneratedPackageSwift(p, config, iosPlatformVersion) {
155
193
  ? `,
156
194
  publicHeadersPath: "."`
157
195
  : '';
196
+ const resources = (0, plugin_1.getPlatformElement)(p, platform, 'resource-file');
158
197
  const sourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'source-file');
159
- if (sourceFiles.length === 0 && headerFiles.length === 0) {
198
+ if (sourceFiles.length === 0 && headerFiles.length === 0 && resources.length === 0) {
160
199
  return;
161
200
  }
162
201
  const frameworks = (0, plugin_1.getPlatformElement)(p, platform, 'framework');
@@ -165,6 +204,7 @@ async function writeGeneratedPackageSwift(p, config, iosPlatformVersion) {
165
204
  const systemFrameworks = frameworks.filter((f) => !f.$.custom && f.$.src.endsWith('.framework'));
166
205
  const hasWeakFrameworks = systemFrameworks.some((f) => f.$.weak === 'true');
167
206
  const requiredSystemFrameworks = systemFrameworks.filter((f) => f.$.weak !== 'true');
207
+ const resourcesText = buildResourcesText(resources);
168
208
  const libraryTypeText = hasWeakFrameworks ? `\n type: .dynamic,` : '';
169
209
  const linkerSettingsText = requiredSystemFrameworks.length > 0
170
210
  ? `,
@@ -172,6 +212,7 @@ async function writeGeneratedPackageSwift(p, config, iosPlatformVersion) {
172
212
  ${requiredSystemFrameworks.map((f) => ` .linkedFramework("${f.$.src.replace('.framework', '')}")`).join(',\n')}
173
213
  ]`
174
214
  : '';
215
+ const { packageText, productText } = await buildDependencyTexts(p, config);
175
216
  const content = `// swift-tools-version: 5.9
176
217
 
177
218
  import PackageDescription
@@ -186,15 +227,15 @@ let package = Package(
186
227
  )
187
228
  ],
188
229
  dependencies: [
189
- .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "${iosPlatformVersion}")
230
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "${iosPlatformVersion}")${packageText}
190
231
  ],
191
232
  targets: [
192
233
  .target(
193
234
  name: "${p.name}",
194
235
  dependencies: [
195
- .product(name: "Cordova", package: "capacitor-swift-pm")${binaryDepsText}
236
+ .product(name: "Cordova", package: "capacitor-swift-pm")${binaryDepsText}${productText}
196
237
  ],
197
- path: "."${headersText}${cSettingsText}${linkerSettingsText}
238
+ path: "."${resourcesText}${headersText}${cSettingsText}${linkerSettingsText}
198
239
  )${binaryTargetsText}
199
240
  ]
200
241
  )`;
@@ -505,8 +546,13 @@ async function copyPluginsNativeFiles(config, cordovaPlugins) {
505
546
  }
506
547
  if (fileContent.includes('[NSBundle bundleForClass:[self class]]') ||
507
548
  fileContent.includes('[NSBundle bundleForClass:[CDVCapture class]]')) {
508
- fileContent = fileContent.replace('[NSBundle bundleForClass:[self class]]', '[NSBundle mainBundle]');
509
- fileContent = fileContent.replace('[NSBundle bundleForClass:[CDVCapture class]]', '[NSBundle mainBundle]');
549
+ const bundleName = isSPM ? 'SWIFTPM_MODULE_BUNDLE' : '[NSBundle mainBundle]';
550
+ fileContent = fileContent.replace('[NSBundle bundleForClass:[self class]]', bundleName);
551
+ fileContent = fileContent.replace('[NSBundle bundleForClass:[CDVCapture class]]', bundleName);
552
+ await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
553
+ }
554
+ if (isSPM && fileContent.includes('[NSBundle mainBundle] URLForResource')) {
555
+ fileContent = fileContent.replace('[NSBundle mainBundle] URLForResource', 'SWIFTPM_MODULE_BUNDLE URLForResource');
510
556
  await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
511
557
  }
512
558
  if (fileContent.includes('[self.webView superview]') || fileContent.includes('self.webView.superview')) {
@@ -520,7 +566,8 @@ async function copyPluginsNativeFiles(config, cordovaPlugins) {
520
566
  const resourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'resource-file');
521
567
  for (const resourceFile of resourceFiles) {
522
568
  const fileName = resourceFile.$.src.split('/').pop();
523
- await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(config.ios.cordovaPluginsDirAbs, 'resources', fileName));
569
+ const rootResFolder = isSPM ? sourcesFolder : config.ios.cordovaPluginsDirAbs;
570
+ await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(rootResFolder, 'resources', fileName));
524
571
  }
525
572
  for (const framework of frameworks) {
526
573
  if (framework.$.custom && framework.$.custom === 'true') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-plus/cli",
3
- "version": "8.3.2",
3
+ "version": "8.3.4",
4
4
  "description": "Capacitor+: Enhanced Capacitor with automated upstream sync - Cross-platform apps with JavaScript and the web",
5
5
  "homepage": "https://capgo.app/docs/plugins/capacitor-plus/",
6
6
  "author": "Capgo Team <support@capgo.app> (https://capgo.app)",