Skip to content

Commit b762402

Browse files
authored
fix: always launches fallback simulator (#2778)
* fix: always launches fallback simulator * fix: use fallback when device not found
1 parent 300a6c5 commit b762402

File tree

1 file changed

+32
-2
lines changed
  • packages/cli-platform-apple/src/commands/runCommand

1 file changed

+32
-2
lines changed

packages/cli-platform-apple/src/commands/runCommand/createRun.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ import {getConfiguration} from '../buildCommand/getConfiguration';
2727
import {getXcodeProjectAndDir} from '../buildCommand/getXcodeProjectAndDir';
2828
import {getFallbackSimulator} from './getFallbackSimulator';
2929
import {getPlatformInfo} from './getPlatformInfo';
30-
import {printFoundDevices, matchingDevice} from './matchingDevice';
30+
import {
31+
printFoundDevices,
32+
matchingDevice,
33+
formattedDeviceName,
34+
} from './matchingDevice';
3135
import {runOnDevice} from './runOnDevice';
3236
import {runOnSimulator} from './runOnSimulator';
3337
import {BuilderCommand} from '../../types';
@@ -326,7 +330,7 @@ const createRun =
326330
mode,
327331
scheme,
328332
args,
329-
fallbackSimulator,
333+
device,
330334
);
331335
} else {
332336
if (!device) {
@@ -392,6 +396,32 @@ const createRun =
392396
args,
393397
);
394398
}
399+
} else if (args.simulator) {
400+
const matchedSimulator = devices.find(
401+
(d) =>
402+
d.type === 'simulator' &&
403+
(d.udid === args.simulator ||
404+
d.name === args.simulator ||
405+
formattedDeviceName(d) === args.simulator),
406+
);
407+
408+
if (!matchedSimulator) {
409+
logger.warn(
410+
`Could not find a simulator with name or UDID: "${pico.bold(
411+
args.simulator,
412+
)}". ${printFoundDevices(devices, 'simulator')}`,
413+
);
414+
logger.info('Falling back to default simulator...');
415+
}
416+
417+
return runOnSimulator(
418+
xcodeProject,
419+
platformName,
420+
mode,
421+
scheme,
422+
args,
423+
matchedSimulator ?? fallbackSimulator,
424+
);
395425
} else {
396426
runOnSimulator(
397427
xcodeProject,

0 commit comments

Comments
 (0)