@@ -186,19 +186,30 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
186
186
187
187
public addLibrary ( libraryPath : string ) : IFuture < void > {
188
188
return ( ( ) => {
189
- this . validateDynamicFramework ( libraryPath ) . wait ( ) ;
189
+ this . validateFramework ( libraryPath ) . wait ( ) ;
190
190
191
191
let targetPath = path . join ( "lib" , this . platformData . normalizedPlatformName ) ;
192
192
let fullTargetPath = path . join ( this . $projectData . projectDir , targetPath ) ;
193
193
this . $fs . ensureDirectoryExists ( fullTargetPath ) . wait ( ) ;
194
194
shell . cp ( "-R" , libraryPath , fullTargetPath ) ;
195
195
196
196
let project = this . createPbxProj ( ) ;
197
+
198
+ let frameworkName = path . basename ( libraryPath , path . extname ( libraryPath ) ) ;
199
+ let frameworkBinaryPath = path . join ( libraryPath , frameworkName ) ;
200
+ let isDynamic = _ . contains ( this . $childProcess . exec ( `otool -Vh ${ frameworkBinaryPath } ` ) . wait ( ) , " DYLIB " ) ;
201
+
202
+ let frameworkAddOptions : xcode . FrameworkOptions = { customFramework : true } ;
203
+
204
+ if ( isDynamic ) {
205
+ frameworkAddOptions [ "embed" ] = true ;
206
+ project . updateBuildProperty ( "IPHONEOS_DEPLOYMENT_TARGET" , "8.0" ) ;
207
+ this . $logger . info ( "The iOS Deployment Target is now 8.0 in order to support Cocoa Touch Frameworks." ) ;
208
+ }
209
+
197
210
let frameworkPath = this . getFrameworkRelativePath ( libraryPath ) ;
198
- project . addFramework ( frameworkPath , { customFramework : true , embed : true } ) ;
199
- project . updateBuildProperty ( "IPHONEOS_DEPLOYMENT_TARGET" , "8.0" ) ;
211
+ project . addFramework ( frameworkPath , frameworkAddOptions ) ;
200
212
this . savePbxProj ( project ) . wait ( ) ;
201
- this . $logger . info ( "The iOS Deployment Target is now 8.0 in order to support Cocoa Touch Frameworks." ) ;
202
213
} ) . future < void > ( ) ( ) ;
203
214
}
204
215
@@ -305,15 +316,15 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
305
316
public preparePluginNativeCode ( pluginData : IPluginData ) : IFuture < void > {
306
317
return ( ( ) => {
307
318
let pluginPlatformsFolderPath = pluginData . pluginPlatformsFolderPath ( IOSProjectService . IOS_PLATFORM_NAME ) ;
308
- this . prepareDynamicFrameworks ( pluginPlatformsFolderPath , pluginData ) . wait ( ) ;
319
+ this . prepareFrameworks ( pluginPlatformsFolderPath , pluginData ) . wait ( ) ;
309
320
this . prepareCocoapods ( pluginPlatformsFolderPath ) . wait ( ) ;
310
321
} ) . future < void > ( ) ( ) ;
311
322
}
312
323
313
324
public removePluginNativeCode ( pluginData : IPluginData ) : IFuture < void > {
314
325
return ( ( ) => {
315
326
let pluginPlatformsFolderPath = pluginData . pluginPlatformsFolderPath ( IOSProjectService . IOS_PLATFORM_NAME ) ;
316
- this . removeDynamicFrameworks ( pluginPlatformsFolderPath , pluginData ) . wait ( ) ;
327
+ this . removeFrameworks ( pluginPlatformsFolderPath , pluginData ) . wait ( ) ;
317
328
this . removeCocoapods ( pluginPlatformsFolderPath ) . wait ( ) ;
318
329
} ) . future < void > ( ) ( ) ;
319
330
}
@@ -343,7 +354,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
343
354
} ) . future < void > ( ) ( ) ;
344
355
}
345
356
346
- private getAllDynamicFrameworksForPlugin ( pluginData : IPluginData ) : IFuture < string [ ] > {
357
+ private getAllFrameworksForPlugin ( pluginData : IPluginData ) : IFuture < string [ ] > {
347
358
let filterCallback = ( fileName : string , pluginPlatformsFolderPath : string ) => path . extname ( fileName ) === ".framework" ;
348
359
return this . getAllNativeLibrariesForPlugin ( pluginData , IOSProjectService . IOS_PLATFORM_NAME , filterCallback ) ;
349
360
}
@@ -352,7 +363,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
352
363
return path . join ( this . $npmInstallationManager . getCachedPackagePath ( this . platformData . frameworkPackageName , version ) , constants . PROJECT_FRAMEWORK_FOLDER_NAME , util . format ( "%s.xcodeproj" , IOSProjectService . IOS_PROJECT_NAME_PLACEHOLDER ) , "project.pbxproj" ) ;
353
364
}
354
365
355
- private validateDynamicFramework ( libraryPath : string ) : IFuture < void > {
366
+ private validateFramework ( libraryPath : string ) : IFuture < void > {
356
367
return ( ( ) => {
357
368
let infoPlistPath = path . join ( libraryPath , "Info.plist" ) ;
358
369
if ( ! this . $fs . exists ( infoPlistPath ) . wait ( ) ) {
@@ -383,9 +394,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
383
394
} ) . future < void > ( ) ( ) ;
384
395
}
385
396
386
- private prepareDynamicFrameworks ( pluginPlatformsFolderPath : string , pluginData : IPluginData ) : IFuture < void > {
397
+ private prepareFrameworks ( pluginPlatformsFolderPath : string , pluginData : IPluginData ) : IFuture < void > {
387
398
return ( ( ) => {
388
- _ . each ( this . getAllDynamicFrameworksForPlugin ( pluginData ) . wait ( ) , fileName => this . addLibrary ( path . join ( pluginPlatformsFolderPath , fileName ) ) . wait ( ) ) ;
399
+ _ . each ( this . getAllFrameworksForPlugin ( pluginData ) . wait ( ) , fileName => this . addLibrary ( path . join ( pluginPlatformsFolderPath , fileName ) ) . wait ( ) ) ;
389
400
} ) . future < void > ( ) ( ) ;
390
401
}
391
402
@@ -400,11 +411,11 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
400
411
} ) . future < void > ( ) ( ) ;
401
412
}
402
413
403
- private removeDynamicFrameworks ( pluginPlatformsFolderPath : string , pluginData : IPluginData ) : IFuture < void > {
414
+ private removeFrameworks ( pluginPlatformsFolderPath : string , pluginData : IPluginData ) : IFuture < void > {
404
415
return ( ( ) => {
405
416
let project = this . createPbxProj ( ) ;
406
417
407
- _ . each ( this . getAllDynamicFrameworksForPlugin ( pluginData ) . wait ( ) , fileName => {
418
+ _ . each ( this . getAllFrameworksForPlugin ( pluginData ) . wait ( ) , fileName => {
408
419
let fullFrameworkPath = path . join ( pluginPlatformsFolderPath , fileName ) ;
409
420
let relativeFrameworkPath = this . getFrameworkRelativePath ( fullFrameworkPath ) ;
410
421
project . removeFramework ( relativeFrameworkPath , { customFramework : true , embed : true } ) ;
0 commit comments