@@ -13,7 +13,7 @@ import { IOSProvisionService } from "./ios-provision-service";
13
13
import { IOSEntitlementsService } from "./ios-entitlements-service" ;
14
14
import { XCConfigService } from "./xcconfig-service" ;
15
15
import * as mobileprovision from "ios-mobileprovision-finder" ;
16
- import { BUILD_XCCONFIG_FILE_NAME } from "../constants" ;
16
+ import { BUILD_XCCONFIG_FILE_NAME , IosProjectConstants } from "../constants" ;
17
17
18
18
interface INativeSourceCodeGroup {
19
19
name : string ;
@@ -22,8 +22,6 @@ interface INativeSourceCodeGroup {
22
22
}
23
23
24
24
export class IOSProjectService extends projectServiceBaseLib . PlatformProjectServiceBase implements IPlatformProjectService {
25
- private static XCODE_PROJECT_EXT_NAME = ".xcodeproj" ;
26
- private static XCODE_SCHEME_EXT_NAME = ".xcscheme" ;
27
25
private static XCODEBUILD_MIN_VERSION = "6.0" ;
28
26
private static IOS_PROJECT_NAME_PLACEHOLDER = "__PROJECT_NAME__" ;
29
27
private static IOS_PLATFORM_NAME = "ios" ;
@@ -36,7 +34,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
36
34
private $injector : IInjector ,
37
35
$projectDataService : IProjectDataService ,
38
36
private $prompter : IPrompter ,
39
- private $config : IConfiguration ,
40
37
private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
41
38
private $devicesService : Mobile . IDevicesService ,
42
39
private $mobileHelper : Mobile . IMobileHelper ,
@@ -174,21 +171,21 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
174
171
}
175
172
this . replaceFileName ( "-Prefix.pch" , projectRootFilePath , projectData ) ;
176
173
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 ) ;
179
176
180
177
if ( this . $fs . exists ( xcschemeFilePath ) ) {
181
178
this . $logger . debug ( "Found shared scheme at xcschemeFilePath, renaming to match project name." ) ;
182
179
this . $logger . debug ( "Checkpoint 0" ) ;
183
180
this . replaceFileContent ( xcschemeFilePath , projectData ) ;
184
181
this . $logger . debug ( "Checkpoint 1" ) ;
185
- this . replaceFileName ( IOSProjectService . XCODE_SCHEME_EXT_NAME , xcschemeDirPath , projectData ) ;
182
+ this . replaceFileName ( IosProjectConstants . XcodeSchemeExtName , xcschemeDirPath , projectData ) ;
186
183
this . $logger . debug ( "Checkpoint 2" ) ;
187
184
} else {
188
185
this . $logger . debug ( "Copying xcscheme from template not found at " + xcschemeFilePath ) ;
189
186
}
190
187
191
- this . replaceFileName ( IOSProjectService . XCODE_PROJECT_EXT_NAME , this . getPlatformData ( projectData ) . projectRoot , projectData ) ;
188
+ this . replaceFileName ( IosProjectConstants . XcodeProjExtName , this . getPlatformData ( projectData ) . projectRoot , projectData ) ;
192
189
193
190
const pbxprojFilePath = this . getPbxProjPath ( projectData ) ;
194
191
this . replaceFileContent ( pbxprojFilePath , projectData ) ;
@@ -891,7 +888,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
891
888
}
892
889
893
890
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 ) ;
895
892
}
896
893
897
894
private getPluginsDebugXcconfigFilePath ( projectData : IProjectData ) : string {
@@ -941,7 +938,9 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
941
938
await this . prepareResources ( pluginPlatformsFolderPath , pluginData , projectData ) ;
942
939
await this . prepareFrameworks ( pluginPlatformsFolderPath , pluginData , projectData ) ;
943
940
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 ) ;
945
944
}
946
945
947
946
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
958
957
public async afterPrepareAllPlugins ( projectData : IProjectData ) : Promise < void > {
959
958
const projectRoot = this . getPlatformData ( projectData ) . projectRoot ;
960
959
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" ) ;
963
963
964
964
if ( ! this . $fs . exists ( xcuserDataPath ) && ! this . $fs . exists ( sharedDataPath ) ) {
965
965
this . $logger . info ( "Creating project scheme..." ) ;
@@ -969,7 +969,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
969
969
await this . $childProcess . exec ( createSchemeRubyScript , { cwd : this . getPlatformData ( projectData ) . projectRoot } ) ;
970
970
}
971
971
972
- await this . executePodInstall ( projectData ) ;
972
+ await this . $cocoapodsService . executePodInstall ( projectRoot , xcodeProjPath ) ;
973
973
}
974
974
}
975
975
@@ -1070,43 +1070,6 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
1070
1070
this . $fs . rename ( path . join ( fileRootLocation , oldFileName ) , path . join ( fileRootLocation , newFileName ) ) ;
1071
1071
}
1072
1072
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
-
1110
1073
private async prepareNativeSourceCode ( pluginName : string , pluginPlatformsFolderPath : string , projectData : IProjectData ) : Promise < void > {
1111
1074
const project = this . createPbxProj ( projectData ) ;
1112
1075
const group = this . getRootGroup ( pluginName , pluginPlatformsFolderPath ) ;
@@ -1153,15 +1116,6 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
1153
1116
}
1154
1117
}
1155
1118
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
- }
1165
1119
private removeNativeSourceCode ( pluginPlatformsFolderPath : string , pluginData : IPluginData , projectData : IProjectData ) : void {
1166
1120
const project = this . createPbxProj ( projectData ) ;
1167
1121
const group = this . getRootGroup ( pluginData . name , pluginPlatformsFolderPath ) ;
0 commit comments