From df4dc9a17f1b999a68093091d201ba15d234c5f8 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Fri, 12 Jul 2024 15:10:23 +0200 Subject: [PATCH] fix(ios): Match CapApp-SPM iOS version with project version (#7556) --- 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 dcc0f69e2..65db5b785 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",