From 10a2f2d32e05f8a51c0bac47f8a8b1a3f26584b5 Mon Sep 17 00:00:00 2001 From: WcaleNieWolny Date: Tue, 16 Dec 2025 07:44:05 +0100 Subject: [PATCH 1/3] fix: generate correct SPM platforms iOS version --- cli/src/ios/common.ts | 26 ++++++++++++++++++++++++++ cli/src/util/spm.ts | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/cli/src/ios/common.ts b/cli/src/ios/common.ts index 71bd34499..b7dba4ed4 100644 --- a/cli/src/ios/common.ts +++ b/cli/src/ios/common.ts @@ -113,3 +113,29 @@ export function getMajoriOSVersion(config: Config): string { ); return iosVersion; } + +export function getMajorMinoriOSVersion(config: Config): string { + const pbx = readFileSync(join(config.ios.nativeXcodeProjDirAbs, 'project.pbxproj'), 'utf-8'); + const searchString = 'IPHONEOS_DEPLOYMENT_TARGET = '; + const startIndex = pbx.indexOf(searchString); + if (startIndex === -1) { + return ''; + } + const valueStart = startIndex + searchString.length; + // Extract until semicolon or newline (typical end of value in pbxproj) + const endIndex = pbx.indexOf(';', valueStart); + const newlineIndex = pbx.indexOf('\n', valueStart); + const actualEnd = endIndex !== -1 && newlineIndex !== -1 + ? Math.min(endIndex, newlineIndex) + : endIndex !== -1 + ? endIndex + : newlineIndex !== -1 + ? newlineIndex + : pbx.length; + let iosVersion = pbx.substring(valueStart, actualEnd).trim(); + // Remove trailing .0 if present + if (iosVersion.endsWith('.0')) { + iosVersion = iosVersion.slice(0, -2); + } + return iosVersion; +} \ No newline at end of file diff --git a/cli/src/util/spm.ts b/cli/src/util/spm.ts index b5dc1a8af..8f329c3ee 100644 --- a/cli/src/util/spm.ts +++ b/cli/src/util/spm.ts @@ -8,7 +8,7 @@ import { extract } from 'tar'; import { getCapacitorPackageVersion } from '../common'; import type { Config } from '../definitions'; import { fatal } from '../errors'; -import { getMajoriOSVersion } from '../ios/common'; +import { getMajorMinoriOSVersion } from '../ios/common'; import { logger } from '../log'; import type { Plugin } from '../plugin'; import { getPluginType, PluginType } from '../plugin'; @@ -92,7 +92,7 @@ export async function removeCocoapodsFiles(config: Config): Promise { export async function generatePackageText(config: Config, plugins: Plugin[]): Promise { const iosPlatformVersion = await getCapacitorPackageVersion(config, config.ios.name); - const iosVersion = getMajoriOSVersion(config); + const iosVersion = getMajorMinoriOSVersion(config); let packageSwiftText = `// swift-tools-version: 5.9 import PackageDescription From d5f86994d9cfa081bedd957bb53eb2f3d1752907 Mon Sep 17 00:00:00 2001 From: WcaleNieWolny Date: Tue, 16 Dec 2025 07:52:41 +0100 Subject: [PATCH 2/3] fix: iOS enum --- cli/src/util/spm.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/util/spm.ts b/cli/src/util/spm.ts index 8f329c3ee..72f4903f1 100644 --- a/cli/src/util/spm.ts +++ b/cli/src/util/spm.ts @@ -100,7 +100,7 @@ import PackageDescription // DO NOT MODIFY THIS FILE - managed by Capacitor CLI commands let package = Package( name: "CapApp-SPM", - platforms: [.iOS(.v${iosVersion})], + platforms: [.iOS(${iosVersion.includes('.') ? `"${iosVersion}"` : `.v${iosVersion}`})], products: [ .library( name: "CapApp-SPM", From ad58cc59d9453f3794a9e161111f3c0d18b35ae0 Mon Sep 17 00:00:00 2001 From: WcaleNieWolny Date: Wed, 17 Dec 2025 06:09:32 +0100 Subject: [PATCH 3/3] chore: lint --- cli/src/ios/common.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cli/src/ios/common.ts b/cli/src/ios/common.ts index b7dba4ed4..5e805ffee 100644 --- a/cli/src/ios/common.ts +++ b/cli/src/ios/common.ts @@ -125,17 +125,18 @@ export function getMajorMinoriOSVersion(config: Config): string { // Extract until semicolon or newline (typical end of value in pbxproj) const endIndex = pbx.indexOf(';', valueStart); const newlineIndex = pbx.indexOf('\n', valueStart); - const actualEnd = endIndex !== -1 && newlineIndex !== -1 - ? Math.min(endIndex, newlineIndex) - : endIndex !== -1 - ? endIndex - : newlineIndex !== -1 - ? newlineIndex - : pbx.length; + const actualEnd = + endIndex !== -1 && newlineIndex !== -1 + ? Math.min(endIndex, newlineIndex) + : endIndex !== -1 + ? endIndex + : newlineIndex !== -1 + ? newlineIndex + : pbx.length; let iosVersion = pbx.substring(valueStart, actualEnd).trim(); // Remove trailing .0 if present if (iosVersion.endsWith('.0')) { iosVersion = iosVersion.slice(0, -2); } return iosVersion; -} \ No newline at end of file +}