@@ -8,7 +8,7 @@ import * as HostInfoLib from "../lib/common/host-info";
8
8
import * as iOSProjectServiceLib from "../lib/services/ios-project-service" ;
9
9
import { IOSProjectService } from "../lib/services/ios-project-service" ;
10
10
import { IOSEntitlementsService } from "../lib/services/ios-entitlements-service" ;
11
- import { XCConfigService } from "../lib/services/xcconfig-service" ;
11
+ import { XcconfigService } from "../lib/services/xcconfig-service" ;
12
12
import * as LoggerLib from "../lib/common/logger" ;
13
13
import * as OptionsLib from "../lib/options" ;
14
14
import * as yok from "../lib/common/yok" ;
@@ -63,7 +63,7 @@ function createTestInjector(projectPath: string, projectName: string, xcode?: IX
63
63
testInjector . register ( "cocoapodsService" , CocoaPodsService ) ;
64
64
testInjector . register ( "iOSProjectService" , iOSProjectServiceLib . IOSProjectService ) ;
65
65
testInjector . register ( "iOSProvisionService" , { } ) ;
66
- testInjector . register ( "xCConfigService " , XCConfigService ) ;
66
+ testInjector . register ( "xcconfigService " , XcconfigService ) ;
67
67
testInjector . register ( "iOSEntitlementsService" , IOSEntitlementsService ) ;
68
68
testInjector . register ( "logger" , LoggerLib . Logger ) ;
69
69
testInjector . register ( "options" , OptionsLib . Options ) ;
@@ -106,7 +106,11 @@ function createTestInjector(projectPath: string, projectName: string, xcode?: IX
106
106
return {
107
107
shouldUseXcproj : false
108
108
} ;
109
- }
109
+ } ,
110
+ getXcodeprojPath : ( projData : IProjectData , platformData : IPlatformData ) => {
111
+ return path . join ( platformData . projectRoot , projData . projectName + ".xcodeproj" ) ;
112
+ } ,
113
+ checkIfXcodeprojIsRequired : ( ) => ( { } )
110
114
} ) ;
111
115
testInjector . register ( "iosDeviceOperations" , { } ) ;
112
116
testInjector . register ( "pluginVariablesService" , PluginVariablesService ) ;
@@ -129,7 +133,7 @@ function createTestInjector(projectPath: string, projectName: string, xcode?: IX
129
133
testInjector . register ( "packageManager" , PackageManager ) ;
130
134
testInjector . register ( "npm" , NodePackageManager ) ;
131
135
testInjector . register ( "yarn" , YarnPackageManager ) ;
132
- testInjector . register ( "xCConfigService " , XCConfigService ) ;
136
+ testInjector . register ( "xcconfigService " , XcconfigService ) ;
133
137
testInjector . register ( "settingsService" , SettingsService ) ;
134
138
testInjector . register ( "httpClient" , { } ) ;
135
139
testInjector . register ( "platformEnvironmentRequirements" , { } ) ;
@@ -578,11 +582,12 @@ describe("Source code support", () => {
578
582
const platformsFolderPath = path . join ( projectPath , "platforms" , "ios" ) ;
579
583
fs . createDirectory ( platformsFolderPath ) ;
580
584
581
- const iOSProjectService = testInjector . resolve ( "iOSProjectService" ) ;
582
-
583
- iOSProjectService . getXcodeprojPath = ( ) => {
585
+ const xcprojService = testInjector . resolve ( "xcprojService" ) ;
586
+ xcprojService . getXcodeprojPath = ( ) => {
584
587
return path . join ( __dirname , "files" ) ;
585
588
} ;
589
+
590
+ const iOSProjectService = testInjector . resolve ( "iOSProjectService" ) ;
586
591
let pbxProj : any ;
587
592
iOSProjectService . savePbxProj = ( project : any ) : Promise < void > => {
588
593
pbxProj = project ;
@@ -636,9 +641,11 @@ describe("Source code support", () => {
636
641
} ;
637
642
} ) ;
638
643
639
- iOSProjectService . getXcodeprojPath = ( ) => {
644
+ const xcprojService = testInjector . resolve ( "xcprojService" ) ;
645
+ xcprojService . getXcodeprojPath = ( ) => {
640
646
return path . join ( __dirname , "files" ) ;
641
647
} ;
648
+
642
649
let pbxProj : any ;
643
650
iOSProjectService . savePbxProj = ( project : any ) : Promise < void > => {
644
651
pbxProj = project ;
@@ -993,6 +1000,7 @@ describe("iOS Project Service Signing", () => {
993
1000
} ;
994
1001
const changes = < IProjectChangesInfo > { } ;
995
1002
await iOSProjectService . checkForChanges ( changes , { bundle : false , release : false , provision : "NativeScriptDev" , teamId : undefined , useHotModuleReload : false } , projectData ) ;
1003
+ console . log ( "CHANGES !!!! " , changes ) ;
996
1004
assert . isFalse ( ! ! changes . signingChanged ) ;
997
1005
} ) ;
998
1006
} ) ;
@@ -1083,7 +1091,7 @@ describe("Merge Project XCConfig files", () => {
1083
1091
return ;
1084
1092
}
1085
1093
const assertPropertyValues = ( expected : any , xcconfigPath : string , injector : IInjector ) => {
1086
- const service = < XCConfigService > injector . resolve ( 'xCConfigService ' ) ;
1094
+ const service = < IXcconfigService > injector . resolve ( 'xcconfigService ' ) ;
1087
1095
_ . forOwn ( expected , ( value , key ) => {
1088
1096
const actual = service . readPropertyValue ( xcconfigPath , key ) ;
1089
1097
assert . equal ( actual , value ) ;
@@ -1092,13 +1100,15 @@ describe("Merge Project XCConfig files", () => {
1092
1100
1093
1101
let projectName : string ;
1094
1102
let projectPath : string ;
1103
+ let projectRoot : string ;
1095
1104
let testInjector : IInjector ;
1096
1105
let iOSProjectService : IOSProjectService ;
1097
1106
let projectData : IProjectData ;
1098
1107
let fs : IFileSystem ;
1099
1108
let appResourcesXcconfigPath : string ;
1100
1109
let appResourceXCConfigContent : string ;
1101
1110
let iOSEntitlementsService : IOSEntitlementsService ;
1111
+ let xcconfigService : IXcconfigService ;
1102
1112
1103
1113
beforeEach ( ( ) => {
1104
1114
projectName = "projectDirectory" ;
@@ -1125,6 +1135,8 @@ describe("Merge Project XCConfig files", () => {
1125
1135
} ;
1126
1136
fs = testInjector . resolve ( "fs" ) ;
1127
1137
fs . writeJson ( path . join ( projectPath , "package.json" ) , testPackageJson ) ;
1138
+ xcconfigService = testInjector . resolve ( "xcconfigService" ) ;
1139
+ projectRoot = iOSProjectService . getPlatformData ( projectData ) . projectRoot ;
1128
1140
} ) ;
1129
1141
1130
1142
it ( "Uses the build.xcconfig file content from App_Resources" , async ( ) => {
@@ -1133,10 +1145,9 @@ describe("Merge Project XCConfig files", () => {
1133
1145
1134
1146
// run merge for all release: debug|release
1135
1147
for ( const release in [ true , false ] ) {
1136
- await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( release , projectData ) ;
1148
+ await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( projectData , { release } ) ;
1137
1149
1138
- const destinationFilePath = release ? ( < any > iOSProjectService ) . getPluginsReleaseXcconfigFilePath ( projectData )
1139
- : ( < any > iOSProjectService ) . getPluginsDebugXcconfigFilePath ( projectData ) ;
1150
+ const destinationFilePath = xcconfigService . getPluginsXcconfigFilePath ( projectRoot , { release : ! ! release } ) ;
1140
1151
1141
1152
assert . isTrue ( fs . exists ( destinationFilePath ) , 'Target build xcconfig is missing for release: ' + release ) ;
1142
1153
const expected = {
@@ -1160,10 +1171,9 @@ describe("Merge Project XCConfig files", () => {
1160
1171
return realExistsFunction ( filePath ) ;
1161
1172
} ;
1162
1173
1163
- await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( release , projectData ) ;
1174
+ await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( projectData , { release } ) ;
1164
1175
1165
- const destinationFilePath = release ? ( < any > iOSProjectService ) . getPluginsReleaseXcconfigFilePath ( projectData )
1166
- : ( < any > iOSProjectService ) . getPluginsDebugXcconfigFilePath ( projectData ) ;
1176
+ const destinationFilePath = xcconfigService . getPluginsXcconfigFilePath ( projectRoot , { release : ! ! release } ) ;
1167
1177
1168
1178
assert . isTrue ( fs . exists ( destinationFilePath ) , 'Target build xcconfig is missing for release: ' + release ) ;
1169
1179
const expected = {
@@ -1181,10 +1191,9 @@ describe("Merge Project XCConfig files", () => {
1181
1191
1182
1192
// run merge for all release: debug|release
1183
1193
for ( const release in [ true , false ] ) {
1184
- await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( release , projectData ) ;
1194
+ await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( projectData , { release } ) ;
1185
1195
1186
- const destinationFilePath = release ? ( < any > iOSProjectService ) . getPluginsReleaseXcconfigFilePath ( projectData )
1187
- : ( < any > iOSProjectService ) . getPluginsDebugXcconfigFilePath ( projectData ) ;
1196
+ const destinationFilePath = xcconfigService . getPluginsXcconfigFilePath ( projectRoot , { release : ! ! release } ) ;
1188
1197
1189
1198
assert . isTrue ( fs . exists ( destinationFilePath ) , 'Target build xcconfig is missing for release: ' + release ) ;
1190
1199
const expected = {
@@ -1200,10 +1209,9 @@ describe("Merge Project XCConfig files", () => {
1200
1209
it ( "creates empty plugins-<config>.xcconfig in case there are no build.xcconfig in App_Resources and in plugins" , async ( ) => {
1201
1210
// run merge for all release: debug|release
1202
1211
for ( const release in [ true , false ] ) {
1203
- await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( release , projectData ) ;
1212
+ await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( projectData , { release } ) ;
1204
1213
1205
- const destinationFilePath = release ? ( < any > iOSProjectService ) . getPluginsReleaseXcconfigFilePath ( projectData )
1206
- : ( < any > iOSProjectService ) . getPluginsDebugXcconfigFilePath ( projectData ) ;
1214
+ const destinationFilePath = xcconfigService . getPluginsXcconfigFilePath ( projectRoot , { release : ! ! release } ) ;
1207
1215
1208
1216
assert . isTrue ( fs . exists ( destinationFilePath ) , 'Target build xcconfig is missing for release: ' + release ) ;
1209
1217
const content = fs . readFile ( destinationFilePath ) . toString ( ) ;
@@ -1244,8 +1252,8 @@ describe("buildProject", () => {
1244
1252
devicesService . initialize = ( ) => ( { } ) ;
1245
1253
devicesService . getDeviceInstances = ( ) => data . devices || [ ] ;
1246
1254
1247
- const xCConfigService = testInjector . resolve ( "xCConfigService " ) ;
1248
- xCConfigService . readPropertyValue = ( projectDir : string , propertyName : string ) => {
1255
+ const xcconfigService = testInjector . resolve ( "xcconfigService " ) ;
1256
+ xcconfigService . readPropertyValue = ( projectDir : string , propertyName : string ) => {
1249
1257
if ( propertyName === "IPHONEOS_DEPLOYMENT_TARGET" ) {
1250
1258
return data . deploymentTarget ;
1251
1259
}
@@ -1366,3 +1374,27 @@ describe("buildProject", () => {
1366
1374
executeTests ( testCases , { buildForDevice : false } ) ;
1367
1375
} ) ;
1368
1376
} ) ;
1377
+
1378
+ describe ( "handleNativeDependenciesChange" , ( ) => {
1379
+ it ( "ensure the correct order of pod install and merging pod's xcconfig file" , async ( ) => {
1380
+ const executedCocoapodsMethods : string [ ] = [ ] ;
1381
+ const projectPodfilePath = "my/test/project/platforms/ios/Podfile" ;
1382
+
1383
+ const testInjector = createTestInjector ( "myTestProjectPath" , "myTestProjectName" ) ;
1384
+ const iOSProjectService = testInjector . resolve ( "iOSProjectService" ) ;
1385
+ const projectData = testInjector . resolve ( "projectData" ) ;
1386
+
1387
+ const cocoapodsService = testInjector . resolve ( "cocoapodsService" ) ;
1388
+ cocoapodsService . executePodInstall = async ( ) => executedCocoapodsMethods . push ( "podInstall" ) ;
1389
+ cocoapodsService . mergePodXcconfigFile = async ( ) => executedCocoapodsMethods . push ( "podMerge" ) ;
1390
+ cocoapodsService . applyPodfileFromAppResources = async ( ) => ( { } ) ;
1391
+ cocoapodsService . getProjectPodfilePath = ( ) => projectPodfilePath ;
1392
+
1393
+ const fs = testInjector . resolve ( "fs" ) ;
1394
+ fs . exists = ( filePath : string ) => filePath === projectPodfilePath ;
1395
+
1396
+ await iOSProjectService . handleNativeDependenciesChange ( projectData ) ;
1397
+
1398
+ assert . deepEqual ( executedCocoapodsMethods , [ "podInstall" , "podMerge" ] ) ;
1399
+ } ) ;
1400
+ } ) ;
0 commit comments