@@ -13,6 +13,7 @@ import * as plist from "plist";
1313import { IOSProvisionService } from "./ios-provision-service" ;
1414import { IOSEntitlementsService } from "./ios-entitlements-service" ;
1515import { XCConfigService } from "./xcconfig-service" ;
16+ const simplePlist = require ( "simple-plist" ) ;
1617
1718export class IOSProjectService extends projectServiceBaseLib . PlatformProjectServiceBase implements IPlatformProjectService {
1819 private static XCODE_PROJECT_EXT_NAME = ".xcodeproj" ;
@@ -39,6 +40,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
3940 private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
4041 private $devicesService : Mobile . IDevicesService ,
4142 private $mobileHelper : Mobile . IMobileHelper ,
43+ private $hostInfo : IHostInfo ,
4244 private $pluginVariablesService : IPluginVariablesService ,
4345 private $xcprojService : IXcprojService ,
4446 private $iOSProvisionService : IOSProvisionService ,
@@ -111,6 +113,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
111113 }
112114
113115 public async validate ( ) : Promise < void > {
116+ if ( ! this . $hostInfo . isDarwin ) {
117+ return ;
118+ }
119+
114120 try {
115121 await this . $childProcess . exec ( "which xcodebuild" ) ;
116122 } catch ( error ) {
@@ -492,12 +498,12 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
492498 }
493499
494500 private async addFramework ( frameworkPath : string , projectData : IProjectData ) : Promise < void > {
495- await this . validateFramework ( frameworkPath ) ;
501+ this . validateFramework ( frameworkPath ) ;
496502
497503 let project = this . createPbxProj ( projectData ) ;
498504 let frameworkName = path . basename ( frameworkPath , path . extname ( frameworkPath ) ) ;
499505 let frameworkBinaryPath = path . join ( frameworkPath , frameworkName ) ;
500- let isDynamic = _ . includes ( ( await this . $childProcess . spawnFromEvent ( "otool ", [ "-Vh ", frameworkBinaryPath ] , "close" ) ) . stdout , " DYLIB " ) ;
506+ let isDynamic = _ . includes ( ( await this . $childProcess . spawnFromEvent ( path . join ( __dirname , ".. ", ".. ", "vendor" , "file" , "file.exe" ) , [ frameworkBinaryPath ] , "close" ) ) . stdout , "dynamically linked " ) ;
501507
502508 let frameworkAddOptions : IXcode . Options = { customFramework : true } ;
503509
@@ -918,17 +924,18 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
918924 return path . join ( newModulesDir , constants . PROJECT_FRAMEWORK_FOLDER_NAME , `${ IOSProjectService . IOS_PROJECT_NAME_PLACEHOLDER } .xcodeproj` , "project.pbxproj" ) ;
919925 }
920926
921- private async validateFramework ( libraryPath : string ) : Promise < void > {
922- let infoPlistPath = path . join ( libraryPath , "Info.plist" ) ;
927+ private validateFramework ( libraryPath : string ) : void {
928+ const infoPlistPath = path . join ( libraryPath , "Info.plist" ) ;
923929 if ( ! this . $fs . exists ( infoPlistPath ) ) {
924930 this . $errors . failWithoutHelp ( "The bundle at %s does not contain an Info.plist file." , libraryPath ) ;
925931 }
926932
927- let packageType = ( await this . $childProcess . spawnFromEvent ( "/usr/libexec/PlistBuddy" , [ "-c" , "Print :CFBundlePackageType" , infoPlistPath ] , "close" ) ) . stdout . trim ( ) ;
933+ const plistJson = simplePlist . readFileSync ( infoPlistPath ) ;
934+ const packageType = plistJson [ "CFBundlePackageType" ] ;
935+
928936 if ( packageType !== "FMWK" ) {
929937 this . $errors . failWithoutHelp ( "The bundle at %s does not appear to be a dynamic framework." , libraryPath ) ;
930938 }
931-
932939 }
933940
934941 private async validateStaticLibrary ( libraryPath : string ) : Promise < void > {
@@ -997,9 +1004,9 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
9971004 }
9981005
9991006 private async prepareFrameworks ( pluginPlatformsFolderPath : string , pluginData : IPluginData , projectData : IProjectData ) : Promise < void > {
1000- for ( let fileName of this . getAllLibsForPluginWithFileExtension ( pluginData , ".framework" ) ) {
1001- await this . addFramework ( path . join ( pluginPlatformsFolderPath , fileName ) , projectData ) ;
1002- }
1007+ await _ . each ( this . getAllLibsForPluginWithFileExtension ( pluginData , ".framework" ) , ( fileName ) => {
1008+ this . addFramework ( path . join ( pluginPlatformsFolderPath , fileName ) , projectData ) ;
1009+ } ) ;
10031010 }
10041011
10051012 private async prepareStaticLibs ( pluginPlatformsFolderPath : string , pluginData : IPluginData , projectData : IProjectData ) : Promise < void > {
@@ -1107,11 +1114,13 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11071114 this . $fs . writeFile ( projectFile , "" ) ;
11081115 }
11091116
1110- await this . checkIfXcodeprojIsRequired ( ) ;
1111- let escapedProjectFile = projectFile . replace ( / ' / g, "\\'" ) ,
1112- escapedPluginFile = pluginFile . replace ( / ' / g, "\\'" ) ,
1113- mergeScript = `require 'xcodeproj'; Xcodeproj::Config.new('${ escapedProjectFile } ').merge(Xcodeproj::Config.new('${ escapedPluginFile } ')).save_as(Pathname.new('${ escapedProjectFile } '))` ;
1114- await this . $childProcess . exec ( `ruby -e "${ mergeScript } "` ) ;
1117+ if ( this . $hostInfo . isDarwin ) {
1118+ await this . checkIfXcodeprojIsRequired ( ) ;
1119+ let escapedProjectFile = projectFile . replace ( / ' / g, "\\'" ) ,
1120+ escapedPluginFile = pluginFile . replace ( / ' / g, "\\'" ) ,
1121+ mergeScript = `require 'xcodeproj'; Xcodeproj::Config.new('${ escapedProjectFile } ').merge(Xcodeproj::Config.new('${ escapedPluginFile } ')).save_as(Pathname.new('${ escapedProjectFile } '))` ;
1122+ await this . $childProcess . exec ( `ruby -e "${ mergeScript } "` ) ;
1123+ }
11151124 }
11161125
11171126 private async mergeProjectXcconfigFiles ( release : boolean , projectData : IProjectData ) : Promise < void > {
0 commit comments