Make run-ios command play nicely with multiple Xcode versions (#19781)

Summary:
I started using Xcode 10 beta and spotted that even though react-native cli is using cli tools from Xcode 10 for building it tries to open simulator from Xcode 9.4. Turned out that path to simulator app is hardcoded and doesn’t care about active developer directory.

1. You have to have more than one Xcode version (ie. 9.4 and 10 beta).
2. Change active developer directory to Xcode beta (`xcode-select -s /Applications/Xcode-beta.app/Contents/Developer`).
3. Without fix `react-native run-ios` will open simulator from Xcode 9.4, with fix it'll open simulator from active developer directory.

[CLI][IOS] [BUGFIX] [./local-cli] - use simulator from active developer directory
Closes https://github.com/facebook/react-native/pull/19781

Differential Revision: D8475915

Pulled By: TheSavior

fbshipit-source-id: d607f1f9eb9e565d4a017c21de50b5e569d171f9
This commit is contained in:
Michał Mokijewski 2018-06-17 22:52:00 -07:00 committed by Facebook Github Bot
parent 310a2850c5
commit a130239257
1 changed files with 4 additions and 1 deletions

View File

@ -160,8 +160,11 @@ function runOnSimulator(xcodeProject, args, scheme) {
* it will not boot the "default" device, but the one we set. If the app is already running, * it will not boot the "default" device, but the one we set. If the app is already running,
* this flag has no effect. * this flag has no effect.
*/ */
const activeDeveloperDir = child_process
.execFileSync('xcode-select', ['-p'], {encoding: 'utf8'})
.trim();
child_process.execFileSync('open', [ child_process.execFileSync('open', [
'/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app', `${activeDeveloperDir}/Applications/Simulator.app`,
'--args', '--args',
'-CurrentDeviceUDID', '-CurrentDeviceUDID',
selectedSimulator.udid, selectedSimulator.udid,