@@ -5,6 +5,7 @@ import * as path from "path";
55import * as _ from "lodash" ;
66import { assert } from "chai" ;
77import { IInjector } from "../../../lib/common/definitions/yok" ;
8+ import { BUILD_XCCONFIG_FILE_NAME } from "../../../lib/constants" ;
89
910function createTestInjector ( data : {
1011 logLevel : string ;
@@ -18,7 +19,13 @@ function createTestInjector(data: {
1819 getDevicesForPlatform : ( ) => data . connectedDevices || [ ] ,
1920 } ) ;
2021 injector . register ( "fs" , {
21- exists : ( ) => data . hasProjectWorkspace ,
22+ exists : ( filepath : string ) => {
23+ if ( filepath . includes ( BUILD_XCCONFIG_FILE_NAME ) ) {
24+ return true ;
25+ } else {
26+ return data . hasProjectWorkspace ;
27+ }
28+ } ,
2229 } ) ;
2330 injector . register ( "logger" , {
2431 getLevel : ( ) => data . logLevel ,
@@ -32,6 +39,8 @@ function createTestInjector(data: {
3239}
3340
3441const projectRoot = "path/to/my/app/folder/platforms/ios" ;
42+ const normalizedPlatformName = "iOS" ;
43+ const appResourcesDirectoryPath = "App_Resources" ;
3544const projectName = "myApp" ;
3645const buildOutputPath = path . join ( projectRoot , projectName , "archive" ) ;
3746
@@ -43,18 +52,27 @@ function getCommonArgs() {
4352}
4453
4554function getXcodeProjectArgs ( data ?: { hasProjectWorkspace : boolean } ) {
55+ const extraArgs = [
56+ "-scheme" ,
57+ projectName ,
58+ "-skipPackagePluginValidation" ,
59+ "-xcconfig" ,
60+ path . join (
61+ appResourcesDirectoryPath ,
62+ normalizedPlatformName ,
63+ BUILD_XCCONFIG_FILE_NAME
64+ ) ,
65+ ] ;
4666 return data && data . hasProjectWorkspace
4767 ? [
4868 "-workspace" ,
4969 path . join ( projectRoot , `${ projectName } .xcworkspace` ) ,
50- "-scheme" ,
51- projectName ,
70+ ...extraArgs ,
5271 ]
5372 : [
5473 "-project" ,
5574 path . join ( projectRoot , `${ projectName } .xcodeproj` ) ,
56- "-scheme" ,
57- projectName ,
75+ ...extraArgs ,
5876 ] ;
5977}
6078
@@ -84,11 +102,12 @@ describe("xcodebuildArgsService", () => {
84102 const xcodebuildArgsService = injector . resolve (
85103 "xcodebuildArgsService"
86104 ) ;
87- const actualArgs = await xcodebuildArgsService . getBuildForSimulatorArgs (
88- { projectRoot } ,
89- { projectName } ,
90- buildConfig
91- ) ;
105+ const actualArgs =
106+ await xcodebuildArgsService . getBuildForSimulatorArgs (
107+ { projectRoot, normalizedPlatformName } ,
108+ { projectName, appResourcesDirectoryPath } ,
109+ buildConfig
110+ ) ;
92111
93112 const expectedArgs = [
94113 "ONLY_ACTIVE_ARCH=NO" ,
@@ -114,8 +133,7 @@ describe("xcodebuildArgsService", () => {
114133 describe ( "getBuildForDeviceArgs" , ( ) => {
115134 const testCases = [
116135 {
117- name :
118- "should return correct args when there are more than one connected device" ,
136+ name : "should return correct args when there are more than one connected device" ,
119137 connectedDevices : [
120138 { deviceInfo : { activeArchitecture : "arm64" } } ,
121139 { deviceInfo : { activeArchitecture : "armv7" } } ,
@@ -125,8 +143,7 @@ describe("xcodebuildArgsService", () => {
125143 ) ,
126144 } ,
127145 {
128- name :
129- "should return correct args when there is only one connected device" ,
146+ name : "should return correct args when there is only one connected device" ,
130147 connectedDevices : [ { deviceInfo : { activeArchitecture : "arm64" } } ] ,
131148 expectedArgs : [ "-sdk" , "iphoneos" ] . concat ( getCommonArgs ( ) ) ,
132149 } ,
@@ -150,21 +167,25 @@ describe("xcodebuildArgsService", () => {
150167
151168 const platformData = {
152169 projectRoot,
170+ normalizedPlatformName,
153171 getBuildOutputPath : ( ) => buildOutputPath ,
154172 } ;
155- const projectData = { projectName } ;
173+ const projectData = {
174+ projectName,
175+ appResourcesDirectoryPath,
176+ } ;
156177 const buildConfig = {
157178 buildForDevice : true ,
158179 release : configuration === "Release" ,
159180 } ;
160- const xcodebuildArgsService : IXcodebuildArgsService = injector . resolve (
161- "xcodebuildArgsService"
162- ) ;
163- const actualArgs = await xcodebuildArgsService . getBuildForDeviceArgs (
164- < any > platformData ,
165- < any > projectData ,
166- < any > buildConfig
167- ) ;
181+ const xcodebuildArgsService : IXcodebuildArgsService =
182+ injector . resolve ( "xcodebuildArgsService" ) ;
183+ const actualArgs =
184+ await xcodebuildArgsService . getBuildForDeviceArgs (
185+ < any > platformData ,
186+ < any > projectData ,
187+ < any > buildConfig
188+ ) ;
168189
169190 const expectedArgs = [
170191 "-destination" ,
0 commit comments