@@ -61,12 +61,11 @@ const buildFlagMatchers = {
61
61
* a project path and name
62
62
*
63
63
* @param {* } projectPath
64
- * @param {* } projectName
65
64
*/
66
- function createProjectObject ( projectPath , projectName ) {
65
+ function createProjectObject ( projectPath ) {
67
66
const locations = {
68
67
root : projectPath ,
69
- pbxproj : path . join ( projectPath , ` ${ projectName } .xcodeproj` , 'project.pbxproj' )
68
+ pbxproj : path . join ( projectPath , 'App .xcodeproj' , 'project.pbxproj' )
70
69
} ;
71
70
72
71
return projectFile . parse ( locations ) ;
@@ -103,7 +102,6 @@ function getDefaultSimulatorTarget () {
103
102
module . exports . run = function ( buildOpts ) {
104
103
const projectPath = this . root ;
105
104
let emulatorTarget = 'iOS Device' ;
106
- let projectName = '' ;
107
105
108
106
buildOpts = buildOpts || { } ;
109
107
@@ -180,9 +178,7 @@ module.exports.run = function (buildOpts) {
180
178
}
181
179
} )
182
180
. then ( ( ) => check_reqs . run ( ) )
183
- . then ( ( ) => findXCodeProjectIn ( projectPath ) )
184
- . then ( name => {
185
- projectName = name ;
181
+ . then ( ( ) => {
186
182
let extraConfig = '' ;
187
183
if ( buildOpts . codeSignIdentity ) {
188
184
extraConfig += `CODE_SIGN_IDENTITY = ${ buildOpts . codeSignIdentity } \n` ;
@@ -201,7 +197,7 @@ module.exports.run = function (buildOpts) {
201
197
}
202
198
203
199
function writeCodeSignStyle ( value ) {
204
- const project = createProjectObject ( projectPath , projectName ) ;
200
+ const project = createProjectObject ( projectPath ) ;
205
201
206
202
events . emit ( 'verbose' , `Set CODE_SIGN_STYLE Build Property to ${ value } .` ) ;
207
203
project . xcode . updateBuildProperty ( 'CODE_SIGN_STYLE' , value ) ;
@@ -223,7 +219,7 @@ module.exports.run = function (buildOpts) {
223
219
} ) . then ( ( ) => {
224
220
const configuration = buildOpts . release ? 'Release' : 'Debug' ;
225
221
226
- events . emit ( 'log' , `Building project: ${ path . join ( projectPath , ` ${ projectName } .xcworkspace` ) } ` ) ;
222
+ events . emit ( 'log' , `Building project: ${ path . join ( projectPath , 'App .xcworkspace' ) } ` ) ;
227
223
events . emit ( 'log' , `\tConfiguration: ${ configuration } ` ) ;
228
224
events . emit ( 'log' , `\tPlatform: ${ buildOpts . device ? 'device' : 'emulator' } ` ) ;
229
225
events . emit ( 'log' , `\tTarget: ${ emulatorTarget } ` ) ;
@@ -233,14 +229,14 @@ module.exports.run = function (buildOpts) {
233
229
// remove the build output folder before building
234
230
fs . rmSync ( buildOutputDir , { recursive : true , force : true } ) ;
235
231
236
- const xcodebuildArgs = getXcodeBuildArgs ( projectName , projectPath , configuration , emulatorTarget , buildOpts ) ;
232
+ const xcodebuildArgs = getXcodeBuildArgs ( projectPath , configuration , emulatorTarget , buildOpts ) ;
237
233
return execa ( 'xcodebuild' , xcodebuildArgs , { cwd : projectPath , stdio : 'inherit' } ) ;
238
234
} ) . then ( ( ) => {
239
235
if ( ! buildOpts . device || buildOpts . catalyst || buildOpts . noSign ) {
240
236
return ;
241
237
}
242
238
243
- const project = createProjectObject ( projectPath , projectName ) ;
239
+ const project = createProjectObject ( projectPath ) ;
244
240
const bundleIdentifier = project . getPackageName ( ) ;
245
241
const exportOptions = { ...buildOpts . exportOptions , compileBitcode : false , method : 'development' } ;
246
242
@@ -287,7 +283,7 @@ module.exports.run = function (buildOpts) {
287
283
}
288
284
289
285
function packageArchive ( ) {
290
- const xcodearchiveArgs = getXcodeArchiveArgs ( projectName , projectPath , buildOutputDir , exportOptionsPath , buildOpts ) ;
286
+ const xcodearchiveArgs = getXcodeArchiveArgs ( projectPath , buildOutputDir , exportOptionsPath , buildOpts ) ;
291
287
return execa ( 'xcodebuild' , xcodearchiveArgs , { cwd : projectPath , stdio : 'inherit' } ) ;
292
288
}
293
289
@@ -298,38 +294,15 @@ module.exports.run = function (buildOpts) {
298
294
. then ( ( ) => { } ) ; // resolve to undefined
299
295
} ;
300
296
301
- /**
302
- * Searches for first XCode project in specified folder
303
- * @param {String } projectPath Path where to search project
304
- * @return {Promise } Promise either fulfilled with project name or rejected
305
- */
306
- function findXCodeProjectIn ( projectPath ) {
307
- // 'Searching for Xcode project in ' + projectPath);
308
- const xcodeProjFiles = fs . readdirSync ( projectPath ) . filter ( name => path . extname ( name ) === '.xcodeproj' ) ;
309
-
310
- if ( xcodeProjFiles . length === 0 ) {
311
- return Promise . reject ( new CordovaError ( `No Xcode project found in ${ projectPath } ` ) ) ;
312
- }
313
- if ( xcodeProjFiles . length > 1 ) {
314
- events . emit ( 'warn' , `Found multiple .xcodeproj directories in \n${ projectPath } \nUsing first one` ) ;
315
- }
316
-
317
- const projectName = path . basename ( xcodeProjFiles [ 0 ] , '.xcodeproj' ) ;
318
- return Promise . resolve ( projectName ) ;
319
- }
320
-
321
- module . exports . findXCodeProjectIn = findXCodeProjectIn ;
322
-
323
297
/**
324
298
* Returns array of arguments for xcodebuild
325
- * @param {String } projectName Name of xcode project
326
299
* @param {String } projectPath Path to project file. Will be used to set CWD for xcodebuild
327
300
* @param {String } configuration Configuration name: debug|release
328
301
* @param {String } emulatorTarget Target for emulator (rather than default)
329
302
* @param {Object } buildConfig The build configuration options
330
303
* @return {Array } Array of arguments that could be passed directly to spawn method
331
304
*/
332
- function getXcodeBuildArgs ( projectName , projectPath , configuration , emulatorTarget , buildConfig = { } ) {
305
+ function getXcodeBuildArgs ( projectPath , configuration , emulatorTarget , buildConfig = { } ) {
333
306
let options ;
334
307
let buildActions ;
335
308
let settings ;
@@ -349,11 +322,11 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, emulatorTar
349
322
350
323
if ( buildConfig . device && ! buildConfig . catalyst ) {
351
324
options = [
352
- '-workspace' , customArgs . workspace || ` ${ projectName } .xcworkspace` ,
353
- '-scheme' , customArgs . scheme || projectName ,
325
+ '-workspace' , customArgs . workspace || 'App .xcworkspace' ,
326
+ '-scheme' , customArgs . scheme || 'App' ,
354
327
'-configuration' , customArgs . configuration || configuration ,
355
328
'-destination' , customArgs . destination || 'generic/platform=iOS' ,
356
- '-archivePath' , customArgs . archivePath || ` ${ projectName } .xcarchive`
329
+ '-archivePath' , customArgs . archivePath || 'App .xcarchive'
357
330
] ;
358
331
buildActions = [ 'archive' ] ;
359
332
settings = [ ] ;
@@ -386,8 +359,8 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, emulatorTar
386
359
}
387
360
} else { // emulator
388
361
options = [
389
- '-workspace' , customArgs . workspace || ` ${ projectName } .xcworkspace` ,
390
- '-scheme' , customArgs . scheme || projectName ,
362
+ '-workspace' , customArgs . workspace || 'App .xcworkspace' ,
363
+ '-scheme' , customArgs . scheme || 'App' ,
391
364
'-configuration' , customArgs . configuration || configuration
392
365
] ;
393
366
@@ -425,15 +398,27 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, emulatorTar
425
398
426
399
/**
427
400
* Returns array of arguments for xcodebuild
428
- * @param {String } projectName Name of xcode project
429
401
* @param {String } projectPath Path to project file. Will be used to set CWD for xcodebuild
430
402
* @param {String } outputPath Output directory to contain the IPA
431
403
* @param {String } exportOptionsPath Path to the exportOptions.plist file
432
404
* @param {Object } buildConfig Build configuration options
433
405
* @return {Array } Array of arguments that could be passed directly to spawn method
434
406
*/
435
- function getXcodeArchiveArgs ( projectName , projectPath , outputPath , exportOptionsPath , buildConfig = { } ) {
407
+ function getXcodeArchiveArgs ( projectPath , outputPath , exportOptionsPath , buildConfig = { } ) {
436
408
const options = [ ] ;
409
+ const buildFlags = buildConfig . buildFlag ;
410
+ const customArgs = { } ;
411
+ customArgs . otherFlags = [ ] ;
412
+
413
+ if ( buildFlags ) {
414
+ if ( typeof buildFlags === 'string' || buildFlags instanceof String ) {
415
+ parseBuildFlag ( buildFlags , customArgs ) ;
416
+ } else { // buildFlags is an Array of strings
417
+ buildFlags . forEach ( flag => {
418
+ parseBuildFlag ( flag , customArgs ) ;
419
+ } ) ;
420
+ }
421
+ }
437
422
438
423
if ( buildConfig . automaticProvisioning ) {
439
424
options . push ( '-allowProvisioningUpdates' ) ;
@@ -450,10 +435,10 @@ function getXcodeArchiveArgs (projectName, projectPath, outputPath, exportOption
450
435
451
436
return [
452
437
'-exportArchive' ,
453
- '-archivePath' , ` ${ projectName } . xcarchive` ,
438
+ '-archivePath' , customArgs . archivePath || 'App. xcarchive' ,
454
439
'-exportOptionsPlist' , exportOptionsPath ,
455
440
'-exportPath' , outputPath
456
- ] . concat ( options ) ;
441
+ ] . concat ( options ) . concat ( customArgs . otherFlags ) ;
457
442
}
458
443
459
444
function parseBuildFlag ( buildFlag , args ) {
0 commit comments