@@ -190,7 +190,7 @@ async function runOnSimulator(
190
190
bootSimulator ( selectedSimulator ) ;
191
191
}
192
192
193
- const appName = await buildProject (
193
+ const buildOutput = await buildProject (
194
194
xcodeProject ,
195
195
selectedSimulator . udid ,
196
196
scheme ,
@@ -200,8 +200,7 @@ async function runOnSimulator(
200
200
const appPath = getBuildPath (
201
201
xcodeProject ,
202
202
args . configuration ,
203
- appName ,
204
- false ,
203
+ buildOutput ,
205
204
scheme ,
206
205
) ;
207
206
@@ -257,7 +256,7 @@ async function runOnDevice(
257
256
) ;
258
257
}
259
258
260
- const appName = await buildProject (
259
+ const buildOutput = await buildProject (
261
260
xcodeProject ,
262
261
selectedDevice . udid ,
263
262
scheme ,
@@ -266,7 +265,7 @@ async function runOnDevice(
266
265
267
266
const iosDeployInstallArgs = [
268
267
'--bundle' ,
269
- getBuildPath ( xcodeProject , args . configuration , appName , true , scheme ) ,
268
+ getBuildPath ( xcodeProject , args . configuration , buildOutput , scheme ) ,
270
269
'--id' ,
271
270
selectedDevice . udid ,
272
271
'--justlaunch' ,
@@ -367,7 +366,7 @@ function buildProject(
367
366
return ;
368
367
}
369
368
logger . success ( 'Successfully built the app' ) ;
370
- resolve ( getProductName ( buildOutput ) || scheme ) ;
369
+ resolve ( buildOutput ) ;
371
370
} ) ;
372
371
} ) ;
373
372
}
@@ -408,20 +407,9 @@ function getTargetPaths(buildSettings: string) {
408
407
function getBuildPath (
409
408
xcodeProject : ProjectInfo ,
410
409
configuration : string ,
411
- appName : string ,
412
- isDevice : boolean ,
410
+ buildOutput : string ,
413
411
scheme : string ,
414
412
) {
415
- let device ;
416
-
417
- if ( isDevice ) {
418
- device = 'iphoneos' ;
419
- } else if ( appName . toLowerCase ( ) . includes ( 'tvos' ) ) {
420
- device = 'appletvsimulator' ;
421
- } else {
422
- device = 'iphonesimulator' ;
423
- }
424
-
425
413
const buildSettings = child_process . execFileSync (
426
414
'xcodebuild' ,
427
415
[
@@ -430,7 +418,7 @@ function getBuildPath(
430
418
'-scheme' ,
431
419
scheme ,
432
420
'-sdk' ,
433
- device ,
421
+ getPlatformName ( buildOutput ) ,
434
422
'-configuration' ,
435
423
configuration ,
436
424
'-showBuildSettings' ,
@@ -451,11 +439,17 @@ function getBuildPath(
451
439
return `${ targetBuildDir } /${ executableFolderPath } ` ;
452
440
}
453
441
454
- function getProductName ( buildOutput : string ) {
455
- const productNameMatch = / e x p o r t F U L L _ P R O D U C T _ N A M E = " ? ( .+ ) .a p p " ? $ / m. exec (
442
+ function getPlatformName ( buildOutput : string ) {
443
+ // Xcode can sometimes escape `=` with a backslash or put the value in quotes
444
+ const platformNameMatch = / e x p o r t P L A T F O R M _ N A M E \\ ? = " ? ( \w + ) " ? $ / m. exec (
456
445
buildOutput ,
457
446
) ;
458
- return productNameMatch ? productNameMatch [ 1 ] : null ;
447
+ if ( ! platformNameMatch ) {
448
+ throw new CLIError (
449
+ 'Couldn\'t find "PLATFORM_NAME" variable in xcodebuild output. Please report this issue and run your project with Xcode instead.' ,
450
+ ) ;
451
+ }
452
+ return platformNameMatch [ 1 ] ;
459
453
}
460
454
461
455
function xcprettyAvailable ( ) {
0 commit comments