React-native: Choose Simulator iOS version

Created on 7 Oct 2016  路  26Comments  路  Source: facebook/react-native

React-native v0.34

Anyway to choose a simulator's ios version to run?
I have list of simulators with iOS 9.3 and iOS 10.

When using --simulator it picks the simulator device with latest iOS which is 10.

Setting deployment target to 9.3 in the project settings doesnt help :/

Maybe a flag --iosversion would be beneficial in the next release.

Thank you very much in advance,

Locked

Most helpful comment

This is still an issue, but a decent workaround exists.

Launch XCode, select Window > Devices and Simulators, then open the Simulator tab. Rename the simulators you need to whatever you want. You can then use the --simulator option to launch your preferred simulator using the new name.

For example, I renamed my iPhone 6 with versions 9.0 and 11.2 to "Nonary" and "Elevensies" respectively. My command would look like --simulator "Nonary" or --simulator "Elevensies".

It'd be really good to see an update where you can actually set the iOS version without any workaround, however.

All 26 comments

+1 but until then, you can manually build and archive your project via XCode

@Amurmurmur this looks like a question related to Xcode usage. Please refer to Apple documentation

this is not an xcode usage problem. xcode can do what i said in #10284. it how the cli uses xcode.

I found "solution" just delete duplicate simulators with different ios versions

I simply removed iPhone 6 10.0 simulator and by default react-native runs iPhone 6 with 9.3

how about when i want to run two simulators of the same iphone and ios, but different name, and run something on one, run something else on the other?

It seems like there is a reasonable workaround here so I am going to close this issue. Thanks folks for chiming in to help answer this!

@lacker this is a workaround, but not a reasonable one IMO. It requires uninstalling and reinstalling simulators when you want to change the iOS version that react-native run-ios uses.

If I run react-native run-ios after upgrading to 0.44.0, I get

xcodebuild: error: SDK "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk" cannot be located.
xcrun: error: unable to find utility "instruments", not a developer tool or in PATH

Command failed: xcrun instruments -s
xcodebuild: error: SDK "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk" cannot be located.
xcrun: error: unable to find utility "instruments", not a developer tool or in PATH`

Hmm.. looks like 10.2 is still getting called.

```
cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs

ls
iPhoneSimulator.sdk iPhoneSimulator10.3.sdk

Where is this 10.2 locked? I tried reinstalling ReactNative a few times, manually and with the Git Tool. It still seems pretty intent on 10.2

I have the same question. Is there any way how this can be specified? Are the UUIDs unique? Or are they the same on my local machine and on other machines? Trying to run iPhone 6 with iOS 10.3

Vote to reopen. It seems like which iOS version is used is random when multiple ones are installed. It would be really useful to have an option that can configure this!

@spinningarrow agreed; mine just opened with iPhone 6 9.1 even though the apps deployment target is 9.3... Took me several minutes to debug why the app was dying immediately on opening! I didn't even know I had 9.1 installed...

+1 to reopen, mine is iPhone 6 8.4

+1

This is still happening with the iOS 11.1 simulator

Actually it works for me now if you launch a simulator of your choice (and only one) and then run react-native run-ios, it will use actually launched simulator.

@comur That's slightly different - that's preloading the simulator and react will use the already open one.

The feature request is to be able to specify the version when launching it... Or at least have the launcher know if your project settings define a minimum version, to not use anything less than that.

I'm also hitting this issue and would like to see it re-opened. Would be great to have three features added in relation to the issue:

  • Ability to specify the OS version via a flag
  • If no flag is set, then it should autodetect the minimum version and use that
  • Ability to set a default device and OS version which persists between runs

So I investigated this issue and figured out that the fix for #9414 that added the ability to run on devices broke the original functionality of the --simulator flag. I differ the code and was able to see where the logic change was made. I'm my local repository, I was able to fix this and change the behavior to match the old way it worked as explained in #10246. However, the documentation and --help don't really explain any of the nuances of how run-ios should behave when flags are mixed (or precedence, or with multiple simulators as is being implemented right now in #17284). This all leaves me at a bit of a blocker wondering:

  • How should all of the flags work and should they work in conjunction with each other?
  • Should version instead be split into a separate flag as suggested by @justynspooner?

Aside from waiting on a decision for #17284, as that affects the same files and would require a merge for a fix, I don't know if I should be committing any additional time into cleaning up the code logic and writing new tests. Thoughts? Could someone with decision making power chime in here?

Sidenote: While examining the code and commit changes, I found an unintended workaround that doesn't require deleting and reinstalling simulators.

Despite what --help says and the names of the functions in the code, you can use the --udid by itself (don't specify any --device or --simulator) to run on a specific simulator. You can get your list of simulators with their unique udids with xcrun simctl list devices. I don't know if this is the workaround that @lacker was thinking of, but it works for now (it's actually a bug based on how everything is written and explained).

Edit: My mistake on the workaround. I was testing on a different code branch where I was working on a udid fix that should address the non-merged closed PR #10405. --udid won't work as I explained above at the moment.

Please reopen

I executed the command with 'sudo' and it worked.

sudo react-native run-ios

Never ever run with sudo when you wanna build react native app, this will lead to more and more trouble.

This is still an issue, but a decent workaround exists.

Launch XCode, select Window > Devices and Simulators, then open the Simulator tab. Rename the simulators you need to whatever you want. You can then use the --simulator option to launch your preferred simulator using the new name.

For example, I renamed my iPhone 6 with versions 9.0 and 11.2 to "Nonary" and "Elevensies" respectively. My command would look like --simulator "Nonary" or --simulator "Elevensies".

It'd be really good to see an update where you can actually set the iOS version without any workaround, however.

Completely agree, OS version should be specifiable @lacker

I think @patrickholley 's workaround is the best thing we can do now

@lacker please reopen. A clunky workaround doesn't count as a fix.

Agreed. We have CI that comes with simulators pre-loaded. Renaming and/or uninstalling is definitely not ideal.

Was this page helpful?
0 / 5 - 0 ratings