-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
Summary: Since Xcode 9 you can run multiple simultaneously. And since I believe React Native advocates using the latest version of Xcode, we can safely remove this constraint. Updated the unit tests. Furthermore it can be found in the [Xcode release notes](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/WhatsNewXcode/xcode_9/xcode_9.html#//apple_ref/doc/uid/TP40004626-CH8-SW12) that multiple simulators are now supported. This can be tested with the CLI by running `react-native run-ios` twice, but with a different `--simulator` flag, e.g.; react-native run-ios --simulator "iPhone SE" react-native run-ios --simulator "iPhone X" [IOS] [ENHANCEMENT] [local-cli/runIOS/findMatchingSimulator.js] - Allow running multiple simulators Closes #17284 Differential Revision: D7102790 Pulled By: hramos fbshipit-source-id: 750e7039201e28a1feda2bec1e78144fd9deff98
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,24 +113,30 @@ function runOnSimulator(xcodeProject, args, scheme) { | |
throw new Error(`Could not find ${args.simulator} simulator`); | ||
} | ||
|
||
const simulatorFullName = formattedDeviceName(selectedSimulator); | ||
console.log(`Launching ${simulatorFullName}...`); | ||
try { | ||
child_process.spawnSync('xcrun', ['instruments', '-w', selectedSimulator.udid]); | ||
} catch (e) { | ||
// instruments always fail with 255 because it expects more arguments, | ||
// but we want it to only launch the simulator | ||
if (!selectedSimulator.booted) { | ||
const simulatorFullName = formattedDeviceName(selectedSimulator); | ||
console.log(`Booting ${simulatorFullName}...`); | ||
try { | ||
child_process.execFileSync('xcrun', ['simctl', 'boot', selectedSimulator.udid]); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
grabbou
Contributor
|
||
} 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.` | ||
); | ||
} | ||
} | ||
resolve(selectedSimulator.udid); | ||
|
||
buildProject(xcodeProject, selectedSimulator.udid, scheme, args.configuration, args.packager, args.verbose) | ||
.then((appName) => resolve(selectedSimulator.udid, appName)); | ||
This comment has been minimized.
Sorry, something went wrong.
oguzbilgener
|
||
}) | ||
.then((udid) => buildProject(xcodeProject, udid, scheme, args.configuration, args.packager, args.verbose, args.port)) | ||
.then((appName) => { | ||
.then((udid, appName) => { | ||
if (!appName) { | ||
appName = scheme; | ||
} | ||
let appPath = getBuildPath(args.configuration, appName); | ||
console.log(`Installing ${appPath}`); | ||
child_process.spawnSync('xcrun', ['simctl', 'install', 'booted', appPath], {stdio: 'inherit'}); | ||
child_process.spawnSync('xcrun', ['simctl', 'install', udid, appPath], {stdio: 'inherit'}); | ||
|
||
const bundleID = child_process.execFileSync( | ||
'/usr/libexec/PlistBuddy', | ||
|
@@ -139,7 +145,7 @@ function runOnSimulator(xcodeProject, args, scheme) { | |
).trim(); | ||
|
||
console.log(`Launching ${bundleID}`); | ||
child_process.spawnSync('xcrun', ['simctl', 'launch', 'booted', bundleID], {stdio: 'inherit'}); | ||
child_process.spawnSync('xcrun', ['simctl', 'launch', udid, bundleID], {stdio: 'inherit'}); | ||
}); | ||
} | ||
|
||
|
This command only "boots" simulators, but the Simulator app has to be already opened. Without it, nothing happens.