Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix run-ios not turning on Simulator app #18721

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions local-cli/runIOS/runIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ function runOnSimulator(xcodeProject, args, scheme) {
if (!selectedSimulator) {
throw new Error(`Could not find ${args.simulator} simulator`);
}

/**
* Booting simulator through `xcrun simctl boot` will boot it in the `headless` mode
* (running in the background).
*
* In order for user to see the app and the simulator itself, we have to make sure
* that the Simulator.app is running.
*
* We also pass it `-CurrentDeviceUDID` so that when we launch it for the first time,
* it will not boot the "default" device, but the one we set. If the app is already running,
* this flag has no effect.
*/
child_process.execFileSync('open', [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe open -a Simulator should launch the simulator as well, without specifying a full path. Although not sure if you're then able to pass it additional flags

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After further investigation, I think you should be able to use;

open -a Simulator --args -CurrentDeviceUDID ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that is nice!

'/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app',
'--args',
'-CurrentDeviceUDID',
selectedSimulator.udid
]);

if (!selectedSimulator.booted) {
const simulatorFullName = formattedDeviceName(selectedSimulator);
Expand Down