Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ Notes: If selected simulator does not exist, cli will try to run fallback simula

Notes: `simulator_name` must be a valid iOS simulator name. If in doubt, open your AwesomeApp/ios/AwesomeApp.xcodeproj folder on XCode and unroll the dropdown menu containing the simulator list. The dropdown menu is situated on the right hand side of the play button (top left corner).

Notes: You can pass `booted` as the `simulator_name` to launch the currently booted simulator.

Example: this will launch your project directly onto the iPhone XS Max simulator:

```sh
Expand Down
39 changes: 28 additions & 11 deletions packages/cli-platform-ios/src/commands/runIOS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,35 @@ async function runOnSimulator(
'iPhone 12',
'iPhone 11',
];
const selectedSimulator = fallbackSimulators.reduce((simulator, fallback) => {
return (
simulator || findMatchingSimulator(simulators, {simulator: fallback})
);
}, findMatchingSimulator(simulators, args));

if (!selectedSimulator) {
throw new CLIError(
`No simulator available with ${
args.simulator ? `name "${args.simulator}"` : `udid "${args.udid}"`
}`,
);
let selectedSimulator;

if (args.simulator && args.simulator === 'booted') {
Object.values(simulators.devices).forEach((devices) => {
const bootedSimulator = devices.find(({state}) => state === 'Booted');

if (bootedSimulator) {
selectedSimulator = bootedSimulator;
}
});

if (!selectedSimulator) {
throw new CLIError('No booted simulator found.');
}
} else {
selectedSimulator = fallbackSimulators.reduce((simulator, fallback) => {
return (
simulator || findMatchingSimulator(simulators, {simulator: fallback})
);
}, findMatchingSimulator(simulators, args));

if (!selectedSimulator) {
throw new CLIError(
`No simulator available with ${
args.simulator ? `name "${args.simulator}"` : `udid "${args.udid}"`
}`,
);
}
}

/**
Expand Down