File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -113,3 +113,29 @@ export function getMajoriOSVersion(config: Config): string {
113113 ) ;
114114 return iosVersion ;
115115}
116+
117+ export function getMajorMinoriOSVersion ( config : Config ) : string {
118+ const pbx = readFileSync ( join ( config . ios . nativeXcodeProjDirAbs , 'project.pbxproj' ) , 'utf-8' ) ;
119+ const searchString = 'IPHONEOS_DEPLOYMENT_TARGET = ' ;
120+ const startIndex = pbx . indexOf ( searchString ) ;
121+ if ( startIndex === - 1 ) {
122+ return '' ;
123+ }
124+ const valueStart = startIndex + searchString . length ;
125+ // Extract until semicolon or newline (typical end of value in pbxproj)
126+ const endIndex = pbx . indexOf ( ';' , valueStart ) ;
127+ const newlineIndex = pbx . indexOf ( '\n' , valueStart ) ;
128+ const actualEnd = endIndex !== - 1 && newlineIndex !== - 1
129+ ? Math . min ( endIndex , newlineIndex )
130+ : endIndex !== - 1
131+ ? endIndex
132+ : newlineIndex !== - 1
133+ ? newlineIndex
134+ : pbx . length ;
135+ let iosVersion = pbx . substring ( valueStart , actualEnd ) . trim ( ) ;
136+ // Remove trailing .0 if present
137+ if ( iosVersion . endsWith ( '.0' ) ) {
138+ iosVersion = iosVersion . slice ( 0 , - 2 ) ;
139+ }
140+ return iosVersion ;
141+ }
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { extract } from 'tar';
88import { getCapacitorPackageVersion } from '../common' ;
99import type { Config } from '../definitions' ;
1010import { fatal } from '../errors' ;
11- import { getMajoriOSVersion } from '../ios/common' ;
11+ import { getMajorMinoriOSVersion } from '../ios/common' ;
1212import { logger } from '../log' ;
1313import type { Plugin } from '../plugin' ;
1414import { getPluginType , PluginType } from '../plugin' ;
@@ -92,15 +92,15 @@ export async function removeCocoapodsFiles(config: Config): Promise<void> {
9292
9393export async function generatePackageText ( config : Config , plugins : Plugin [ ] ) : Promise < string > {
9494 const iosPlatformVersion = await getCapacitorPackageVersion ( config , config . ios . name ) ;
95- const iosVersion = getMajoriOSVersion ( config ) ;
95+ const iosVersion = getMajorMinoriOSVersion ( config ) ;
9696
9797 let packageSwiftText = `// swift-tools-version: 5.9
9898import PackageDescription
9999
100100// DO NOT MODIFY THIS FILE - managed by Capacitor CLI commands
101101let package = Package(
102102 name: "CapApp-SPM",
103- platforms: [.iOS(. v${ iosVersion } )],
103+ platforms: [.iOS(${ iosVersion . includes ( '.' ) ? `" ${ iosVersion } "` : `. v${ iosVersion } ` } )],
104104 products: [
105105 .library(
106106 name: "CapApp-SPM",
You can’t perform that action at this time.
0 commit comments