@@ -23,6 +23,7 @@ interface INativeSourceCodeGroup {
23
23
24
24
const DevicePlatformSdkName = "iphoneos" ;
25
25
const SimulatorPlatformSdkName = "iphonesimulator" ;
26
+ const FRAMEWORK_EXTENSIONS = [ ".framework" , ".xcframework" ] ;
26
27
27
28
const getPlatformSdkName = ( forDevice : boolean ) : string => forDevice ? DevicePlatformSdkName : SimulatorPlatformSdkName ;
28
29
const getConfigurationName = ( release : boolean ) : string => release ? Configurations . Release : Configurations . Debug ;
@@ -89,7 +90,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
89
90
} ;
90
91
} ,
91
92
frameworkFilesExtensions : [ ".a" , ".framework" , ".bin" ] ,
92
- frameworkDirectoriesExtensions : [ ".framework" ] ,
93
+ frameworkDirectoriesExtensions : FRAMEWORK_EXTENSIONS ,
93
94
frameworkDirectoriesNames : [ "Metadata" , "metadataGenerator" , "NativeScript" , "internal" ] ,
94
95
targetedOS : [ 'darwin' ] ,
95
96
configurationFileName : constants . INFO_PLIST_FILE_NAME ,
@@ -155,6 +156,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
155
156
this . replaceFileName ( "-Info.plist" , projectRootFilePath , projectData ) ;
156
157
}
157
158
this . replaceFileName ( "-Prefix.pch" , projectRootFilePath , projectData ) ;
159
+ if ( this . $fs . exists ( path . join ( projectRootFilePath , IOSProjectService . IOS_PROJECT_NAME_PLACEHOLDER + ".entitlements" ) ) ) {
160
+ this . replaceFileName ( ".entitlements" , projectRootFilePath , projectData ) ;
161
+ }
158
162
159
163
const xcschemeDirPath = path . join ( this . getPlatformData ( projectData ) . projectRoot , IOSProjectService . IOS_PROJECT_NAME_PLACEHOLDER + IosProjectConstants . XcodeProjExtName , "xcshareddata/xcschemes" ) ;
160
164
const xcschemeFilePath = path . join ( xcschemeDirPath , IOSProjectService . IOS_PROJECT_NAME_PLACEHOLDER + IosProjectConstants . XcodeSchemeExtName ) ;
@@ -225,17 +229,38 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
225
229
return Promise . resolve ( ) ;
226
230
}
227
231
232
+ private async isDynamicFramework ( frameworkPath : string ) : Promise < boolean > {
233
+ const frameworkName = path . basename ( frameworkPath , path . extname ( frameworkPath ) ) ;
234
+ const isDynamicFrameworkBundle = async ( bundlePath : string ) => {
235
+ const frameworkBinaryPath = path . join ( bundlePath , frameworkName ) ;
236
+
237
+ return _ . includes ( ( await this . $childProcess . spawnFromEvent ( "file" , [ frameworkBinaryPath ] , "close" ) ) . stdout , "dynamically linked" ) ;
238
+ } ;
239
+
240
+ if ( path . extname ( frameworkPath ) === ".xcframework" ) {
241
+ let isDynamic = true ;
242
+ const subDirs = this . $fs . readDirectory ( frameworkPath ) . filter ( entry => this . $fs . getFsStats ( entry ) . isDirectory ( ) ) ;
243
+ for ( const subDir of subDirs ) {
244
+ const singlePlatformFramework = path . join ( subDir , frameworkName + ".framework" ) ;
245
+ if ( this . $fs . exists ( singlePlatformFramework ) ) {
246
+ isDynamic = await isDynamicFrameworkBundle ( singlePlatformFramework ) ;
247
+ break ;
248
+ }
249
+ }
250
+
251
+ return isDynamic ;
252
+ } else {
253
+ return await isDynamicFrameworkBundle ( frameworkName ) ;
254
+ }
255
+ }
256
+
228
257
private async addFramework ( frameworkPath : string , projectData : IProjectData ) : Promise < void > {
229
258
if ( ! this . $hostInfo . isWindows ) {
230
259
this . validateFramework ( frameworkPath ) ;
231
260
232
261
const project = this . createPbxProj ( projectData ) ;
233
- const frameworkName = path . basename ( frameworkPath , path . extname ( frameworkPath ) ) ;
234
- const frameworkBinaryPath = path . join ( frameworkPath , frameworkName ) ;
235
- const isDynamic = _ . includes ( ( await this . $childProcess . spawnFromEvent ( "file" , [ frameworkBinaryPath ] , "close" ) ) . stdout , "dynamically linked" ) ;
236
262
const frameworkAddOptions : IXcode . Options = { customFramework : true } ;
237
-
238
- if ( isDynamic ) {
263
+ if ( this . isDynamicFramework ( frameworkPath ) ) {
239
264
frameworkAddOptions [ "embed" ] = true ;
240
265
}
241
266
@@ -577,8 +602,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
577
602
return target ;
578
603
}
579
604
580
- private getAllLibsForPluginWithFileExtension ( pluginData : IPluginData , fileExtension : string ) : string [ ] {
581
- const filterCallback = ( fileName : string , pluginPlatformsFolderPath : string ) => path . extname ( fileName ) === fileExtension ;
605
+ private getAllLibsForPluginWithFileExtension ( pluginData : IPluginData , fileExtension : string | string [ ] ) : string [ ] {
606
+ const fileExtensions = _ . isArray ( fileExtension ) ? fileExtension : [ fileExtension ] ;
607
+ const filterCallback = ( fileName : string , pluginPlatformsFolderPath : string ) =>
608
+ fileExtensions . indexOf ( path . extname ( fileName ) ) !== - 1 ;
582
609
return this . getAllNativeLibrariesForPlugin ( pluginData , IOSProjectService . IOS_PLATFORM_NAME , filterCallback ) ;
583
610
}
584
611
@@ -599,7 +626,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
599
626
const plistJson = this . $plistParser . parseFileSync ( infoPlistPath ) ;
600
627
const packageType = plistJson [ "CFBundlePackageType" ] ;
601
628
602
- if ( packageType !== "FMWK" ) {
629
+ if ( packageType !== "FMWK" && packageType !== "XFWK" ) {
603
630
this . $errors . failWithoutHelp ( "The bundle at %s does not appear to be a dynamic framework." , libraryPath ) ;
604
631
}
605
632
}
@@ -679,7 +706,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
679
706
this . savePbxProj ( project , projectData ) ;
680
707
}
681
708
private async prepareFrameworks ( pluginPlatformsFolderPath : string , pluginData : IPluginData , projectData : IProjectData ) : Promise < void > {
682
- for ( const fileName of this . getAllLibsForPluginWithFileExtension ( pluginData , ".framework" ) ) {
709
+ for ( const fileName of this . getAllLibsForPluginWithFileExtension ( pluginData , FRAMEWORK_EXTENSIONS ) ) {
683
710
await this . addFramework ( path . join ( pluginPlatformsFolderPath , fileName ) , projectData ) ;
684
711
}
685
712
}
@@ -700,7 +727,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
700
727
701
728
private removeFrameworks ( pluginPlatformsFolderPath : string , pluginData : IPluginData , projectData : IProjectData ) : void {
702
729
const project = this . createPbxProj ( projectData ) ;
703
- _ . each ( this . getAllLibsForPluginWithFileExtension ( pluginData , ".framework" ) , fileName => {
730
+ _ . each ( this . getAllLibsForPluginWithFileExtension ( pluginData , FRAMEWORK_EXTENSIONS ) , fileName => {
704
731
const relativeFrameworkPath = this . getLibSubpathRelativeToProjectPath ( fileName , projectData ) ;
705
732
project . removeFramework ( relativeFrameworkPath , { customFramework : true , embed : true } ) ;
706
733
} ) ;
0 commit comments