@@ -13,6 +13,7 @@ import {
1313 getPluginPlatform ,
1414 getPluginType ,
1515} from '../plugin' ;
16+ import { setAllStringIn } from '../tasks/migrate' ;
1617import type { Plugin } from '../plugin' ;
1718import { extractTemplate } from '../util/template' ;
1819
@@ -352,7 +353,21 @@ export async function generateCordovaPackageFile(p: Plugin, config: Config): Pro
352353 publicHeadersPath: "."` ;
353354 }
354355
355- const content = `// swift-tools-version: 5.9
356+ const platformTag = getPluginPlatform ( p , platform ) ;
357+
358+ if ( platformTag . $ ?. package ) {
359+ const packageSwiftPath = join ( p . rootPath , 'Package.swift' ) ;
360+ let content = await readFile ( packageSwiftPath , { encoding : 'utf-8' } ) ;
361+ content = content . replace ( `apache` , `ionic-team` ) . replaceAll ( `cordova-ios` , `capacitor-swift-pm` ) ;
362+ content = setAllStringIn (
363+ content ,
364+ `url: "https://github.com/ionic-team/capacitor-swift-pm.git",` ,
365+ `)` ,
366+ ` from: "${ iosPlatformVersion } "` ,
367+ ) ;
368+ await writeFile ( packageSwiftPath , content ) ;
369+ } else {
370+ const content = `// swift-tools-version: 5.9
356371
357372import PackageDescription
358373
@@ -379,4 +394,5 @@ let package = Package(
379394 ]
380395)` ;
381396 await writeFile ( join ( config . ios . cordovaPluginsDirAbs , 'sources' , p . name , 'Package.swift' ) , content ) ;
397+ }
382398}
0 commit comments