Skip to content

Commit 640c3cb

Browse files
authored
fix: use Capacitor 7 for SPM dependency (ionic-team#7835)
1 parent 5dc309e commit 640c3cb

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

cli/src/util/spm.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { existsSync, readFileSync, writeFileSync } from 'fs-extra';
22
import { join, relative, resolve } from 'path';
33

4+
import { getCapacitorPackageVersion } from '../common';
45
import type { Config } from '../definitions';
56
import { logger } from '../log';
67
import type { Plugin } from '../plugin';
@@ -28,14 +29,16 @@ export async function generatePackageFile(config: Config, plugins: Plugin[]): Pr
2829
const packageSwiftFile = await findPackageSwiftFile(config);
2930
try {
3031
logger.warn('SPM Support is still experimental');
31-
const textToWrite = generatePackageText(config, plugins);
32+
const textToWrite = await generatePackageText(config, plugins);
3233
writeFileSync(packageSwiftFile, textToWrite);
3334
} catch (err) {
3435
logger.error(`Unable to write to ${packageSwiftFile}. Verify it is not already open. \n Error: ${err}`);
3536
}
3637
}
3738

38-
function generatePackageText(config: Config, plugins: Plugin[]): string {
39+
async function generatePackageText(config: Config, plugins: Plugin[]): Promise<string> {
40+
const iosPlatformVersion = await getCapacitorPackageVersion(config, config.ios.name);
41+
3942
const pbx = readFileSync(join(config.ios.nativeXcodeProjDirAbs, 'project.pbxproj'), 'utf-8');
4043
const searchString = 'IPHONEOS_DEPLOYMENT_TARGET = ';
4144
const iosVersion = pbx.substring(
@@ -56,7 +59,7 @@ let package = Package(
5659
targets: ["CapApp-SPM"])
5760
],
5861
dependencies: [
59-
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", branch: "main")`;
62+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", exact: "${iosPlatformVersion}")`;
6063

6164
for (const plugin of plugins) {
6265
const relPath = relative(config.ios.nativeXcodeProjDirAbs, plugin.rootPath);

ios-spm-template/App/CapApp-SPM/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let package = Package(
1111
targets: ["CapApp-SPM"])
1212
],
1313
dependencies: [
14-
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", branch: "main")
14+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
1515
],
1616
targets: [
1717
.target(

0 commit comments

Comments
 (0)