From 302699a4721d8e721bc222909f92b754eb14140d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Mokijewski?= Date: Sun, 17 Jun 2018 22:52:00 -0700 Subject: [PATCH] Make run-ios command play nicely with multiple Xcode versions (#19781) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- local-cli/runIOS/runIOS.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/local-cli/runIOS/runIOS.js b/local-cli/runIOS/runIOS.js index f78700fffbc153..dfabb92b894a4b 100644 --- a/local-cli/runIOS/runIOS.js +++ b/local-cli/runIOS/runIOS.js @@ -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, * this flag has no effect. */ + const activeDeveloperDir = child_process + .execFileSync('xcode-select', ['-p'], {encoding: 'utf8'}) + .trim(); child_process.execFileSync('open', [ - '/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app', + `${activeDeveloperDir}/Applications/Simulator.app`, '--args', '-CurrentDeviceUDID', selectedSimulator.udid,