@@ -8,7 +8,7 @@ import * as HostInfoLib from "../lib/common/host-info";
88import * as iOSProjectServiceLib from "../lib/services/ios-project-service" ;
99import { IOSProjectService } from "../lib/services/ios-project-service" ;
1010import { IOSEntitlementsService } from "../lib/services/ios-entitlements-service" ;
11- import { XCConfigService } from "../lib/services/xcconfig-service" ;
11+ import { XcconfigService } from "../lib/services/xcconfig-service" ;
1212import * as LoggerLib from "../lib/common/logger" ;
1313import * as OptionsLib from "../lib/options" ;
1414import * as yok from "../lib/common/yok" ;
@@ -63,7 +63,7 @@ function createTestInjector(projectPath: string, projectName: string, xcode?: IX
6363 testInjector . register ( "cocoapodsService" , CocoaPodsService ) ;
6464 testInjector . register ( "iOSProjectService" , iOSProjectServiceLib . IOSProjectService ) ;
6565 testInjector . register ( "iOSProvisionService" , { } ) ;
66- testInjector . register ( "xCConfigService " , XCConfigService ) ;
66+ testInjector . register ( "xcconfigService " , XcconfigService ) ;
6767 testInjector . register ( "iOSEntitlementsService" , IOSEntitlementsService ) ;
6868 testInjector . register ( "logger" , LoggerLib . Logger ) ;
6969 testInjector . register ( "options" , OptionsLib . Options ) ;
@@ -106,7 +106,11 @@ function createTestInjector(projectPath: string, projectName: string, xcode?: IX
106106 return {
107107 shouldUseXcproj : false
108108 } ;
109- }
109+ } ,
110+ getXcodeprojPath : ( projData : IProjectData , platformData : IPlatformData ) => {
111+ return path . join ( platformData . projectRoot , projData . projectName + ".xcodeproj" ) ;
112+ } ,
113+ checkIfXcodeprojIsRequired : ( ) => ( { } )
110114 } ) ;
111115 testInjector . register ( "iosDeviceOperations" , { } ) ;
112116 testInjector . register ( "pluginVariablesService" , PluginVariablesService ) ;
@@ -129,7 +133,7 @@ function createTestInjector(projectPath: string, projectName: string, xcode?: IX
129133 testInjector . register ( "packageManager" , PackageManager ) ;
130134 testInjector . register ( "npm" , NodePackageManager ) ;
131135 testInjector . register ( "yarn" , YarnPackageManager ) ;
132- testInjector . register ( "xCConfigService " , XCConfigService ) ;
136+ testInjector . register ( "xcconfigService " , XcconfigService ) ;
133137 testInjector . register ( "settingsService" , SettingsService ) ;
134138 testInjector . register ( "httpClient" , { } ) ;
135139 testInjector . register ( "platformEnvironmentRequirements" , { } ) ;
@@ -578,11 +582,12 @@ describe("Source code support", () => {
578582 const platformsFolderPath = path . join ( projectPath , "platforms" , "ios" ) ;
579583 fs . createDirectory ( platformsFolderPath ) ;
580584
581- const iOSProjectService = testInjector . resolve ( "iOSProjectService" ) ;
582-
583- iOSProjectService . getXcodeprojPath = ( ) => {
585+ const xcprojService = testInjector . resolve ( "xcprojService" ) ;
586+ xcprojService . getXcodeprojPath = ( ) => {
584587 return path . join ( __dirname , "files" ) ;
585588 } ;
589+
590+ const iOSProjectService = testInjector . resolve ( "iOSProjectService" ) ;
586591 let pbxProj : any ;
587592 iOSProjectService . savePbxProj = ( project : any ) : Promise < void > => {
588593 pbxProj = project ;
@@ -636,9 +641,11 @@ describe("Source code support", () => {
636641 } ;
637642 } ) ;
638643
639- iOSProjectService . getXcodeprojPath = ( ) => {
644+ const xcprojService = testInjector . resolve ( "xcprojService" ) ;
645+ xcprojService . getXcodeprojPath = ( ) => {
640646 return path . join ( __dirname , "files" ) ;
641647 } ;
648+
642649 let pbxProj : any ;
643650 iOSProjectService . savePbxProj = ( project : any ) : Promise < void > => {
644651 pbxProj = project ;
@@ -993,6 +1000,7 @@ describe("iOS Project Service Signing", () => {
9931000 } ;
9941001 const changes = < IProjectChangesInfo > { } ;
9951002 await iOSProjectService . checkForChanges ( changes , { bundle : false , release : false , provision : "NativeScriptDev" , teamId : undefined , useHotModuleReload : false } , projectData ) ;
1003+ console . log ( "CHANGES !!!! " , changes ) ;
9961004 assert . isFalse ( ! ! changes . signingChanged ) ;
9971005 } ) ;
9981006 } ) ;
@@ -1083,7 +1091,7 @@ describe("Merge Project XCConfig files", () => {
10831091 return ;
10841092 }
10851093 const assertPropertyValues = ( expected : any , xcconfigPath : string , injector : IInjector ) => {
1086- const service = < XCConfigService > injector . resolve ( 'xCConfigService ' ) ;
1094+ const service = < IXcconfigService > injector . resolve ( 'xcconfigService ' ) ;
10871095 _ . forOwn ( expected , ( value , key ) => {
10881096 const actual = service . readPropertyValue ( xcconfigPath , key ) ;
10891097 assert . equal ( actual , value ) ;
@@ -1092,13 +1100,15 @@ describe("Merge Project XCConfig files", () => {
10921100
10931101 let projectName : string ;
10941102 let projectPath : string ;
1103+ let projectRoot : string ;
10951104 let testInjector : IInjector ;
10961105 let iOSProjectService : IOSProjectService ;
10971106 let projectData : IProjectData ;
10981107 let fs : IFileSystem ;
10991108 let appResourcesXcconfigPath : string ;
11001109 let appResourceXCConfigContent : string ;
11011110 let iOSEntitlementsService : IOSEntitlementsService ;
1111+ let xcconfigService : IXcconfigService ;
11021112
11031113 beforeEach ( ( ) => {
11041114 projectName = "projectDirectory" ;
@@ -1125,6 +1135,8 @@ describe("Merge Project XCConfig files", () => {
11251135 } ;
11261136 fs = testInjector . resolve ( "fs" ) ;
11271137 fs . writeJson ( path . join ( projectPath , "package.json" ) , testPackageJson ) ;
1138+ xcconfigService = testInjector . resolve ( "xcconfigService" ) ;
1139+ projectRoot = iOSProjectService . getPlatformData ( projectData ) . projectRoot ;
11281140 } ) ;
11291141
11301142 it ( "Uses the build.xcconfig file content from App_Resources" , async ( ) => {
@@ -1133,10 +1145,9 @@ describe("Merge Project XCConfig files", () => {
11331145
11341146 // run merge for all release: debug|release
11351147 for ( const release in [ true , false ] ) {
1136- await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( release , projectData ) ;
1148+ await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( projectData , { release } ) ;
11371149
1138- const destinationFilePath = release ? ( < any > iOSProjectService ) . getPluginsReleaseXcconfigFilePath ( projectData )
1139- : ( < any > iOSProjectService ) . getPluginsDebugXcconfigFilePath ( projectData ) ;
1150+ const destinationFilePath = xcconfigService . getPluginsXcconfigFilePath ( projectRoot , { release : ! ! release } ) ;
11401151
11411152 assert . isTrue ( fs . exists ( destinationFilePath ) , 'Target build xcconfig is missing for release: ' + release ) ;
11421153 const expected = {
@@ -1160,10 +1171,9 @@ describe("Merge Project XCConfig files", () => {
11601171 return realExistsFunction ( filePath ) ;
11611172 } ;
11621173
1163- await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( release , projectData ) ;
1174+ await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( projectData , { release } ) ;
11641175
1165- const destinationFilePath = release ? ( < any > iOSProjectService ) . getPluginsReleaseXcconfigFilePath ( projectData )
1166- : ( < any > iOSProjectService ) . getPluginsDebugXcconfigFilePath ( projectData ) ;
1176+ const destinationFilePath = xcconfigService . getPluginsXcconfigFilePath ( projectRoot , { release : ! ! release } ) ;
11671177
11681178 assert . isTrue ( fs . exists ( destinationFilePath ) , 'Target build xcconfig is missing for release: ' + release ) ;
11691179 const expected = {
@@ -1181,10 +1191,9 @@ describe("Merge Project XCConfig files", () => {
11811191
11821192 // run merge for all release: debug|release
11831193 for ( const release in [ true , false ] ) {
1184- await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( release , projectData ) ;
1194+ await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( projectData , { release } ) ;
11851195
1186- const destinationFilePath = release ? ( < any > iOSProjectService ) . getPluginsReleaseXcconfigFilePath ( projectData )
1187- : ( < any > iOSProjectService ) . getPluginsDebugXcconfigFilePath ( projectData ) ;
1196+ const destinationFilePath = xcconfigService . getPluginsXcconfigFilePath ( projectRoot , { release : ! ! release } ) ;
11881197
11891198 assert . isTrue ( fs . exists ( destinationFilePath ) , 'Target build xcconfig is missing for release: ' + release ) ;
11901199 const expected = {
@@ -1200,10 +1209,9 @@ describe("Merge Project XCConfig files", () => {
12001209 it ( "creates empty plugins-<config>.xcconfig in case there are no build.xcconfig in App_Resources and in plugins" , async ( ) => {
12011210 // run merge for all release: debug|release
12021211 for ( const release in [ true , false ] ) {
1203- await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( release , projectData ) ;
1212+ await ( < any > iOSProjectService ) . mergeProjectXcconfigFiles ( projectData , { release } ) ;
12041213
1205- const destinationFilePath = release ? ( < any > iOSProjectService ) . getPluginsReleaseXcconfigFilePath ( projectData )
1206- : ( < any > iOSProjectService ) . getPluginsDebugXcconfigFilePath ( projectData ) ;
1214+ const destinationFilePath = xcconfigService . getPluginsXcconfigFilePath ( projectRoot , { release : ! ! release } ) ;
12071215
12081216 assert . isTrue ( fs . exists ( destinationFilePath ) , 'Target build xcconfig is missing for release: ' + release ) ;
12091217 const content = fs . readFile ( destinationFilePath ) . toString ( ) ;
@@ -1244,8 +1252,8 @@ describe("buildProject", () => {
12441252 devicesService . initialize = ( ) => ( { } ) ;
12451253 devicesService . getDeviceInstances = ( ) => data . devices || [ ] ;
12461254
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 ) => {
12491257 if ( propertyName === "IPHONEOS_DEPLOYMENT_TARGET" ) {
12501258 return data . deploymentTarget ;
12511259 }
@@ -1366,3 +1374,27 @@ describe("buildProject", () => {
13661374 executeTests ( testCases , { buildForDevice : false } ) ;
13671375 } ) ;
13681376} ) ;
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