@@ -13,6 +13,7 @@ import * as plist from "plist";
13
13
import { IOSProvisionService } from "./ios-provision-service" ;
14
14
import { IOSEntitlementsService } from "./ios-entitlements-service" ;
15
15
import { XCConfigService } from "./xcconfig-service" ;
16
+ const simplePlist = require ( "simple-plist" ) ;
16
17
17
18
export class IOSProjectService extends projectServiceBaseLib . PlatformProjectServiceBase implements IPlatformProjectService {
18
19
private static XCODE_PROJECT_EXT_NAME = ".xcodeproj" ;
@@ -39,6 +40,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
39
40
private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
40
41
private $devicesService : Mobile . IDevicesService ,
41
42
private $mobileHelper : Mobile . IMobileHelper ,
43
+ private $hostInfo : IHostInfo ,
42
44
private $pluginVariablesService : IPluginVariablesService ,
43
45
private $xcprojService : IXcprojService ,
44
46
private $iOSProvisionService : IOSProvisionService ,
@@ -111,6 +113,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
111
113
}
112
114
113
115
public async validate ( ) : Promise < void > {
116
+ if ( ! this . $hostInfo . isDarwin ) {
117
+ return ;
118
+ }
119
+
114
120
try {
115
121
await this . $childProcess . exec ( "which xcodebuild" ) ;
116
122
} catch ( error ) {
@@ -492,12 +498,12 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
492
498
}
493
499
494
500
private async addFramework ( frameworkPath : string , projectData : IProjectData ) : Promise < void > {
495
- await this . validateFramework ( frameworkPath ) ;
501
+ this . validateFramework ( frameworkPath ) ;
496
502
497
503
let project = this . createPbxProj ( projectData ) ;
498
504
let frameworkName = path . basename ( frameworkPath , path . extname ( frameworkPath ) ) ;
499
505
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 " ) ;
501
507
502
508
let frameworkAddOptions : IXcode . Options = { customFramework : true } ;
503
509
@@ -918,17 +924,18 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
918
924
return path . join ( newModulesDir , constants . PROJECT_FRAMEWORK_FOLDER_NAME , `${ IOSProjectService . IOS_PROJECT_NAME_PLACEHOLDER } .xcodeproj` , "project.pbxproj" ) ;
919
925
}
920
926
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" ) ;
923
929
if ( ! this . $fs . exists ( infoPlistPath ) ) {
924
930
this . $errors . failWithoutHelp ( "The bundle at %s does not contain an Info.plist file." , libraryPath ) ;
925
931
}
926
932
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
+
928
936
if ( packageType !== "FMWK" ) {
929
937
this . $errors . failWithoutHelp ( "The bundle at %s does not appear to be a dynamic framework." , libraryPath ) ;
930
938
}
931
-
932
939
}
933
940
934
941
private async validateStaticLibrary ( libraryPath : string ) : Promise < void > {
@@ -997,9 +1004,9 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
997
1004
}
998
1005
999
1006
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
+ } ) ;
1003
1010
}
1004
1011
1005
1012
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
1107
1114
this . $fs . writeFile ( projectFile , "" ) ;
1108
1115
}
1109
1116
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
+ }
1115
1124
}
1116
1125
1117
1126
private async mergeProjectXcconfigFiles ( release : boolean , projectData : IProjectData ) : Promise < void > {
0 commit comments