@@ -13,7 +13,7 @@ import { IOSProvisionService } from "./ios-provision-service";
1313import { IOSEntitlementsService } from "./ios-entitlements-service" ;
1414import { XCConfigService } from "./xcconfig-service" ;
1515import * as mobileprovision from "ios-mobileprovision-finder" ;
16- import { BUILD_XCCONFIG_FILE_NAME } from "../constants" ;
16+ import { BUILD_XCCONFIG_FILE_NAME , IosProjectConstants } from "../constants" ;
1717
1818interface INativeSourceCodeGroup {
1919 name : string ;
@@ -22,8 +22,6 @@ interface INativeSourceCodeGroup {
2222}
2323
2424export class IOSProjectService extends projectServiceBaseLib . PlatformProjectServiceBase implements IPlatformProjectService {
25- private static XCODE_PROJECT_EXT_NAME = ".xcodeproj" ;
26- private static XCODE_SCHEME_EXT_NAME = ".xcscheme" ;
2725 private static XCODEBUILD_MIN_VERSION = "6.0" ;
2826 private static IOS_PROJECT_NAME_PLACEHOLDER = "__PROJECT_NAME__" ;
2927 private static IOS_PLATFORM_NAME = "ios" ;
@@ -36,7 +34,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
3634 private $injector : IInjector ,
3735 $projectDataService : IProjectDataService ,
3836 private $prompter : IPrompter ,
39- private $config : IConfiguration ,
4037 private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
4138 private $devicesService : Mobile . IDevicesService ,
4239 private $mobileHelper : Mobile . IMobileHelper ,
@@ -174,21 +171,21 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
174171 }
175172 this . replaceFileName ( "-Prefix.pch" , projectRootFilePath , projectData ) ;
176173
177- const xcschemeDirPath = path . join ( this . getPlatformData ( projectData ) . projectRoot , IOSProjectService . IOS_PROJECT_NAME_PLACEHOLDER + IOSProjectService . XCODE_PROJECT_EXT_NAME , "xcshareddata/xcschemes" ) ;
178- const xcschemeFilePath = path . join ( xcschemeDirPath , IOSProjectService . IOS_PROJECT_NAME_PLACEHOLDER + IOSProjectService . XCODE_SCHEME_EXT_NAME ) ;
174+ const xcschemeDirPath = path . join ( this . getPlatformData ( projectData ) . projectRoot , IOSProjectService . IOS_PROJECT_NAME_PLACEHOLDER + IosProjectConstants . XcodeProjExtName , "xcshareddata/xcschemes" ) ;
175+ const xcschemeFilePath = path . join ( xcschemeDirPath , IOSProjectService . IOS_PROJECT_NAME_PLACEHOLDER + IosProjectConstants . XcodeSchemeExtName ) ;
179176
180177 if ( this . $fs . exists ( xcschemeFilePath ) ) {
181178 this . $logger . debug ( "Found shared scheme at xcschemeFilePath, renaming to match project name." ) ;
182179 this . $logger . debug ( "Checkpoint 0" ) ;
183180 this . replaceFileContent ( xcschemeFilePath , projectData ) ;
184181 this . $logger . debug ( "Checkpoint 1" ) ;
185- this . replaceFileName ( IOSProjectService . XCODE_SCHEME_EXT_NAME , xcschemeDirPath , projectData ) ;
182+ this . replaceFileName ( IosProjectConstants . XcodeSchemeExtName , xcschemeDirPath , projectData ) ;
186183 this . $logger . debug ( "Checkpoint 2" ) ;
187184 } else {
188185 this . $logger . debug ( "Copying xcscheme from template not found at " + xcschemeFilePath ) ;
189186 }
190187
191- this . replaceFileName ( IOSProjectService . XCODE_PROJECT_EXT_NAME , this . getPlatformData ( projectData ) . projectRoot , projectData ) ;
188+ this . replaceFileName ( IosProjectConstants . XcodeProjExtName , this . getPlatformData ( projectData ) . projectRoot , projectData ) ;
192189
193190 const pbxprojFilePath = this . getPbxProjPath ( projectData ) ;
194191 this . replaceFileContent ( pbxprojFilePath , projectData ) ;
@@ -891,7 +888,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
891888 }
892889
893890 private getXcodeprojPath ( projectData : IProjectData ) : string {
894- return path . join ( this . getPlatformData ( projectData ) . projectRoot , projectData . projectName + IOSProjectService . XCODE_PROJECT_EXT_NAME ) ;
891+ return path . join ( this . getPlatformData ( projectData ) . projectRoot , projectData . projectName + IosProjectConstants . XcodeProjExtName ) ;
895892 }
896893
897894 private getPluginsDebugXcconfigFilePath ( projectData : IProjectData ) : string {
@@ -941,7 +938,9 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
941938 await this . prepareResources ( pluginPlatformsFolderPath , pluginData , projectData ) ;
942939 await this . prepareFrameworks ( pluginPlatformsFolderPath , pluginData , projectData ) ;
943940 await this . prepareStaticLibs ( pluginPlatformsFolderPath , pluginData , projectData ) ;
944- await this . prepareCocoapods ( pluginPlatformsFolderPath , pluginData , projectData ) ;
941+
942+ const projectRoot = this . getPlatformData ( projectData ) . projectRoot ;
943+ await this . $cocoapodsService . applyPluginPodfileToProject ( pluginData , projectData , projectRoot ) ;
945944 }
946945
947946 public async removePluginNativeCode ( pluginData : IPluginData , projectData : IProjectData ) : Promise < void > {
@@ -958,8 +957,9 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
958957 public async afterPrepareAllPlugins ( projectData : IProjectData ) : Promise < void > {
959958 const projectRoot = this . getPlatformData ( projectData ) . projectRoot ;
960959 if ( this . $fs . exists ( this . $cocoapodsService . getProjectPodfilePath ( projectRoot ) ) ) {
961- const xcuserDataPath = path . join ( this . getXcodeprojPath ( projectData ) , "xcuserdata" ) ;
962- const sharedDataPath = path . join ( this . getXcodeprojPath ( projectData ) , "xcshareddata" ) ;
960+ const xcodeProjPath = this . getXcodeprojPath ( projectData ) ;
961+ const xcuserDataPath = path . join ( xcodeProjPath , "xcuserdata" ) ;
962+ const sharedDataPath = path . join ( xcodeProjPath , "xcshareddata" ) ;
963963
964964 if ( ! this . $fs . exists ( xcuserDataPath ) && ! this . $fs . exists ( sharedDataPath ) ) {
965965 this . $logger . info ( "Creating project scheme..." ) ;
@@ -969,7 +969,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
969969 await this . $childProcess . exec ( createSchemeRubyScript , { cwd : this . getPlatformData ( projectData ) . projectRoot } ) ;
970970 }
971971
972- await this . executePodInstall ( projectData ) ;
972+ await this . $cocoapodsService . executePodInstall ( projectRoot , xcodeProjPath ) ;
973973 }
974974 }
975975
@@ -1070,43 +1070,6 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
10701070 this . $fs . rename ( path . join ( fileRootLocation , oldFileName ) , path . join ( fileRootLocation , newFileName ) ) ;
10711071 }
10721072
1073- private async executePodInstall ( projectData : IProjectData ) : Promise < any > {
1074- // Check availability
1075- try {
1076- await this . $childProcess . exec ( "which pod" ) ;
1077- await this . $childProcess . exec ( "which xcodeproj" ) ;
1078- } catch ( e ) {
1079- this . $errors . failWithoutHelp ( "CocoaPods or ruby gem 'xcodeproj' is not installed. Run `sudo gem install cocoapods` and try again." ) ;
1080- }
1081-
1082- await this . $xcprojService . verifyXcproj ( true ) ;
1083-
1084- this . $logger . info ( "Installing pods..." ) ;
1085- const podTool = this . $config . USE_POD_SANDBOX ? "sandbox-pod" : "pod" ;
1086- const childProcess = await this . $childProcess . spawnFromEvent ( podTool , [ "install" ] , "close" , { cwd : this . getPlatformData ( projectData ) . projectRoot , stdio : [ 'pipe' , process . stdout , 'pipe' ] } ) ;
1087- if ( childProcess . stderr ) {
1088- const warnings = childProcess . stderr . match ( / ( \u001b \[ (?: \d * ; ) { 0 , 5 } \d * m [ \s \S ] + ?\u001b \[ (?: \d * ; ) { 0 , 5 } \d * m ) | ( \[ ! \] .* ?\n ) | ( .* ?w a r n i n g .* ) / gi) ;
1089- _ . each ( warnings , ( warning : string ) => {
1090- this . $logger . warnWithLabel ( warning . replace ( "\n" , "" ) ) ;
1091- } ) ;
1092-
1093- let errors = childProcess . stderr ;
1094- _ . each ( warnings , warning => {
1095- errors = errors . replace ( warning , "" ) ;
1096- } ) ;
1097-
1098- if ( errors . trim ( ) ) {
1099- this . $errors . failWithoutHelp ( `Pod install command failed. Error output: ${ errors } ` ) ;
1100- }
1101- }
1102-
1103- if ( ( await this . $xcprojService . getXcprojInfo ( ) ) . shouldUseXcproj ) {
1104- await this . $childProcess . spawnFromEvent ( "xcproj" , [ "--project" , this . getXcodeprojPath ( projectData ) , "touch" ] , "close" ) ;
1105- }
1106-
1107- return childProcess ;
1108- }
1109-
11101073 private async prepareNativeSourceCode ( pluginName : string , pluginPlatformsFolderPath : string , projectData : IProjectData ) : Promise < void > {
11111074 const project = this . createPbxProj ( projectData ) ;
11121075 const group = this . getRootGroup ( pluginName , pluginPlatformsFolderPath ) ;
@@ -1153,15 +1116,6 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11531116 }
11541117 }
11551118
1156- private async prepareCocoapods ( pluginPlatformsFolderPath : string , pluginData : IPluginData , projectData : IProjectData , opts ?: any ) : Promise < void > {
1157- const projectRoot = this . getPlatformData ( projectData ) . projectRoot ;
1158- await this . $cocoapodsService . applyPluginPodfileToProject ( pluginData , projectData , projectRoot ) ;
1159- const pluginPodFilePath = path . join ( pluginPlatformsFolderPath , "Podfile" ) ;
1160-
1161- if ( opts && opts . executePodInstall && this . $fs . exists ( pluginPodFilePath ) ) {
1162- await this . executePodInstall ( projectData ) ;
1163- }
1164- }
11651119 private removeNativeSourceCode ( pluginPlatformsFolderPath : string , pluginData : IPluginData , projectData : IProjectData ) : void {
11661120 const project = this . createPbxProj ( projectData ) ;
11671121 const group = this . getRootGroup ( pluginData . name , pluginPlatformsFolderPath ) ;
0 commit comments