Skip to content

Commit

Permalink
Fix launching iOS simulator regression
Browse files Browse the repository at this point in the history
Summary:
PR #17284 (accepted in 2ad34075f1d048bebb08ef30799ac0d081073150) introduced a couple of regressions.

~1. There's the code:~
```
.then((appName) => resolve(selectedSimulator.udid, appName));
/* ... */
.then((udid, appName) => {
```

~~This makes `appName` to be always `undefined` as per `resolve` accepts only 1 argument. This regression causes issues if an app name differs from a scheme name.~

~This PR fixes this by wrapping both values in an array.~

This was fixed in 589eae1432cc4bbc16221f841e27b038099fd128.

2. The code
```
child_process.execFileSync('xcrun', ['simctl', 'boot', selectedSimulator.udid]);
```
makes a simulator *boot*, but the simulator *doesn't launch*. That's a regression, which forces developers to launch simulators by other means (by running a number of elaborate console commands, by running Xcode, or by running a simulator manually).

This PR reverts that part of changes.

Create a blank project with a name that differs from scheme name. Try to `react-native run-ios` in it. See that a simulator is launched and installing succeeds. Without this changes simulator wouldn't launch, and installing step would fail because of app name mismatch.

[CLI][BUGFIX][local-cli/runIOS/runIOS.js] - Fix running on multiple simulators feature regressions
Closes facebook/react-native#18711

Differential Revision: D7535150

Pulled By: hramos

fbshipit-source-id: 5c714231e9977c0c829b6f8c793497cd31cd46b5
  • Loading branch information
lebedev authored and facebook-github-bot committed Apr 6, 2018
1 parent 6af43ae commit 2b91d8a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions runIOS/runIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,12 @@ function runOnSimulator(xcodeProject, args, scheme) {

if (!selectedSimulator.booted) {
const simulatorFullName = formattedDeviceName(selectedSimulator);
console.log(`Booting ${simulatorFullName}...`);
console.log(`Launching ${simulatorFullName}...`);
try {
child_process.execFileSync('xcrun', ['simctl', 'boot', selectedSimulator.udid]);
child_process.spawnSync('xcrun', ['instruments', '-w', selectedSimulator.udid]);
} catch (e) {
throw new Error(
`Could not boot ${args.simulator} simulator. Is there already a simulator running?
Running multiple simulators is only supported from Xcode 9 and up.
Try closing the simulator or run the command again without specifying a simulator.`
);
// instruments always fail with 255 because it expects more arguments,
// but we want it to only launch the simulator
}
}

Expand Down

0 comments on commit 2b91d8a

Please sign in to comment.