From 8d48009a0b17b201f3e4832492bcfb5156702bb6 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Tue, 9 Jul 2024 19:19:15 +0200 Subject: [PATCH] fix(ios): Match CapApp-SPM iOS version with project version --- cli/src/util/spm.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cli/src/util/spm.ts b/cli/src/util/spm.ts index dcc0f69e2b..65db5b7852 100644 --- a/cli/src/util/spm.ts +++ b/cli/src/util/spm.ts @@ -1,5 +1,5 @@ -import { existsSync, writeFileSync } from '@ionic/utils-fs'; -import { relative, resolve } from 'path'; +import { existsSync, readFileSync, writeFileSync } from '@ionic/utils-fs'; +import { join, relative, resolve } from 'path'; import type { Config } from '../definitions'; import { logger } from '../log'; @@ -46,13 +46,23 @@ export async function generatePackageFile( } function generatePackageText(config: Config, plugins: Plugin[]): string { + const pbx = readFileSync( + join(config.ios.nativeXcodeProjDirAbs, 'project.pbxproj'), + 'utf-8', + ); + const searchString = 'IPHONEOS_DEPLOYMENT_TARGET = '; + const iosVersion = pbx.substring( + pbx.indexOf(searchString) + searchString.length, + pbx.indexOf(searchString) + searchString.length + 2, + ); + let packageSwiftText = `// swift-tools-version: 5.9 import PackageDescription // DO NOT MODIFY THIS FILE - managed by Capacitor CLI commands let package = Package( name: "CapApp-SPM", - platforms: [.iOS(.v13)], + platforms: [.iOS(.v${iosVersion})], products: [ .library( name: "CapApp-SPM",