@@ -1055,3 +1055,158 @@ describe("Merge Project XCConfig files", () => {
10551055 }
10561056 } ) ;
10571057} ) ;
1058+
1059+ describe ( "buildProject" , ( ) => {
1060+ let xcodeBuildCommandArgs : string [ ] = [ ] ;
1061+
1062+ function setup ( data : { frameworkVersion : string , deploymentTarget : string , devices ?: Mobile . IDevice [ ] } ) : IInjector {
1063+ const projectPath = "myTestProjectPath" ;
1064+ const projectName = "myTestProjectName" ;
1065+ const testInjector = createTestInjector ( projectPath , projectName ) ;
1066+
1067+ const childProcess = testInjector . resolve ( "childProcess" ) ;
1068+ childProcess . spawnFromEvent = ( command : string , args : string [ ] ) => {
1069+ if ( command === "xcodebuild" && args [ 0 ] !== "-exportArchive" ) {
1070+ xcodeBuildCommandArgs = args ;
1071+ }
1072+ } ;
1073+
1074+ const projectDataService = testInjector . resolve ( "projectDataService" ) ;
1075+ projectDataService . getNSValue = ( projectDir : string , propertyName : string ) => {
1076+ if ( propertyName === "tns-ios" ) {
1077+ return {
1078+ name : "tns-ios" ,
1079+ version : data . frameworkVersion
1080+ } ;
1081+ }
1082+ } ;
1083+
1084+ const projectData = testInjector . resolve ( "projectData" ) ;
1085+ projectData . appResourcesDirectoryPath = path . join ( projectPath , "app" , "App_Resources" ) ;
1086+
1087+ const devicesService = testInjector . resolve ( "devicesService" ) ;
1088+ devicesService . initialize = ( ) => ( { } ) ;
1089+ devicesService . getDeviceInstances = ( ) => data . devices || [ ] ;
1090+
1091+ const xCConfigService = testInjector . resolve ( "xCConfigService" ) ;
1092+ xCConfigService . readPropertyValue = ( projectDir : string , propertyName : string ) => {
1093+ if ( propertyName === "IPHONEOS_DEPLOYMENT_TARGET" ) {
1094+ return data . deploymentTarget ;
1095+ }
1096+ } ;
1097+
1098+ const pbxprojDomXcode = testInjector . resolve ( "pbxprojDomXcode" ) ;
1099+ pbxprojDomXcode . Xcode = {
1100+ open : ( ) => ( {
1101+ getSigning : ( ) => ( { } ) ,
1102+ setAutomaticSigningStyle : ( ) => ( { } ) ,
1103+ save : ( ) => ( { } )
1104+ } )
1105+ } ;
1106+
1107+ const iOSProvisionService = testInjector . resolve ( "iOSProvisionService" ) ;
1108+ iOSProvisionService . getDevelopmentTeams = ( ) => ( { } ) ;
1109+ iOSProvisionService . getTeamIdsWithName = ( ) => ( { } ) ;
1110+
1111+ return testInjector ;
1112+ }
1113+
1114+ function executeTests ( testCases : any [ ] , data : { buildForDevice : boolean } ) {
1115+ _ . each ( testCases , testCase => {
1116+ it ( `${ testCase . name } ` , async ( ) => {
1117+ const testInjector = setup ( { frameworkVersion : testCase . frameworkVersion , deploymentTarget : testCase . deploymentTarget } ) ;
1118+ const projectData : IProjectData = testInjector . resolve ( "projectData" ) ;
1119+
1120+ const iOSProjectService = < IOSProjectService > testInjector . resolve ( "iOSProjectService" ) ;
1121+ ( < any > iOSProjectService ) . getExportOptionsMethod = ( ) => ( { } ) ;
1122+ await iOSProjectService . buildProject ( "myProjectRoot" , projectData , < any > { buildForDevice : data . buildForDevice } ) ;
1123+
1124+ const archsItem = xcodeBuildCommandArgs . find ( item => item . startsWith ( "ARCHS=" ) ) ;
1125+ if ( testCase . expectedArchs ) {
1126+ const archsValue = archsItem . split ( "=" ) [ 1 ] ;
1127+ assert . deepEqual ( archsValue , testCase . expectedArchs ) ;
1128+ } else {
1129+ assert . deepEqual ( undefined , archsItem ) ;
1130+ }
1131+ } ) ;
1132+ } ) ;
1133+ }
1134+
1135+ describe ( "for device" , ( ) => {
1136+ afterEach ( ( ) => {
1137+ xcodeBuildCommandArgs = [ ] ;
1138+ } ) ;
1139+
1140+ const testCases = < any [ ] > [ {
1141+ name : "shouldn't exclude armv7 architecture when deployment target 10" ,
1142+ frameworkVersion : "5.0.0" ,
1143+ deploymentTarget : "10.0" ,
1144+ expectedArchs : "armv7 arm64"
1145+ } , {
1146+ name : "should exclude armv7 architecture when deployment target is 11" ,
1147+ frameworkVersion : "5.0.0" ,
1148+ deploymentTarget : "11.0" ,
1149+ expectedArchs : "arm64"
1150+ } , {
1151+ name : "shouldn't pass architecture to xcodebuild command when frameworkVersion is 5.1.0" ,
1152+ frameworkVersion : "5.1.0" ,
1153+ deploymentTarget : "11.0"
1154+ } , {
1155+ name : "should pass only 64bit architecture to xcodebuild command when frameworkVersion is 5.0.0 and deployment target is 11.0" ,
1156+ frameworkVersion : "5.0.0" ,
1157+ deploymentTarget : "11.0" ,
1158+ expectedArchs : "arm64"
1159+ } , {
1160+ name : "should pass both architectures to xcodebuild command when frameworkVersion is 5.0.0 and deployment target is 10.0" ,
1161+ frameworkVersion : "5.0.0" ,
1162+ deploymentTarget : "10.0" ,
1163+ expectedArchs : "armv7 arm64"
1164+ } , {
1165+ name : "should pass both architectures to xcodebuild command when frameworkVersion is 5.0.0 and no deployment target" ,
1166+ frameworkVersion : "5.0.0" ,
1167+ deploymentTarget : null ,
1168+ expectedArchs : "armv7 arm64"
1169+ } ] ;
1170+
1171+ executeTests ( testCases , { buildForDevice : true } ) ;
1172+ } ) ;
1173+
1174+ describe ( "for simulator" , ( ) => {
1175+ afterEach ( ( ) => {
1176+ xcodeBuildCommandArgs = [ ] ;
1177+ } ) ;
1178+
1179+ const testCases = [ {
1180+ name : "shouldn't exclude i386 architecture when deployment target is 10" ,
1181+ frameworkVersion : "5.0.0" ,
1182+ deploymentTarget : "10.0" ,
1183+ expectedArchs : "i386 x86_64"
1184+ } , {
1185+ name : "should exclude i386 architecture when deployment target is 11" ,
1186+ frameworkVersion : "5.0.0" ,
1187+ deploymentTarget : "11.0" ,
1188+ expectedArchs : "x86_64"
1189+ } , {
1190+ name : "shouldn't pass architecture to xcodebuild command when frameworkVersion is 5.1.0" ,
1191+ frameworkVersion : "5.1.0" ,
1192+ deploymentTarget : "11.0"
1193+ } , {
1194+ name : "should pass only 64bit architecture to xcodebuild command when frameworkVersion is 5.0.0 and deployment target is 11.0" ,
1195+ frameworkVersion : "5.0.0" ,
1196+ deploymentTarget : "11.0" ,
1197+ expectedArchs : "x86_64"
1198+ } , {
1199+ name : "should pass both architectures to xcodebuild command when frameworkVersion is 5.0.0 and deployment target is 10.0" ,
1200+ frameworkVersion : "5.0.0" ,
1201+ deploymentTarget : "10.0" ,
1202+ expectedArchs : "i386 x86_64"
1203+ } , {
1204+ name : "should pass both architectures to xcodebuild command when frameworkVersion is 5.0.0 and no deployment target" ,
1205+ frameworkVersion : "5.0.0" ,
1206+ deploymentTarget : null ,
1207+ expectedArchs : "i386 x86_64"
1208+ } ] ;
1209+
1210+ executeTests ( testCases , { buildForDevice : false } ) ;
1211+ } ) ;
1212+ } ) ;
0 commit comments