Skip to content

Commit

Permalink
Allow to specify simulator OS version from cli
Browse files Browse the repository at this point in the history
Summary:
When multiple simulator runtimes are available, this change will make it possible to specify which one to run. So assuming you have e.g. iOS 9.0 and 9.3 runtimes, all following calls will now work:
```
react-native run-ios --simulator "iPhone 6s (9.0)"
react-native run-ios --simulator "iPhone 6s (9.3)"
react-native run-ios --simulator "iPhone 6s"
```
Closes #8559

Differential Revision: D3516811

Pulled By: frantic

fbshipit-source-id: c81658f77e482e712293367b13d27e783e538aad
  • Loading branch information
tomkur authored and Facebook Github Bot 4 committed Jul 5, 2016
1 parent 3e681c1 commit b046b2d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions local-cli/runIOS/runIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function _runIOS(argv, config, resolve, reject) {
reject(new Error(`Cound't find ${args.simulator} simulator`));
}

const simulatorFullName = `${selectedSimulator.name} (${selectedSimulator.version})`;
const simulatorFullName = formattedSimulatorName(selectedSimulator)
console.log(`Launching ${simulatorFullName}...`);
try {
child_process.spawnSync('xcrun', ['instruments', '-w', simulatorFullName]);
Expand Down Expand Up @@ -121,10 +121,14 @@ function _runIOS(argv, config, resolve, reject) {

function matchingSimulator(simulators, simulatorName) {
for (let i = simulators.length - 1; i >= 0; i--) {
if (simulators[i].name === simulatorName) {
if (simulators[i].name === simulatorName || formattedSimulatorName(simulators[i]) === simulatorName) {
return simulators[i];
}
}
}

function formattedSimulatorName(simulator) {
return `${simulator.name} (${simulator.version})`;
}

module.exports = runIOS;

0 comments on commit b046b2d

Please sign in to comment.