Repository navigation
run-ios does not run on simulator by default, presumably because it's trying to run on my iPhone #2254
Description
Environment
info Fetching system and libraries information...
System:
OS: macOS 14.2.1
CPU: (10) arm64 Apple M1 Max
Memory: 602.31 MB / 64.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.10.0
path: /opt/homebrew/bin/node
Yarn:
version: 1.22.21
path: /opt/homebrew/bin/yarn
npm:
version: 10.2.3
path: /opt/homebrew/bin/npm
Watchman:
version: 2023.12.04.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.14.3
path: bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.2
- iOS 17.2
- macOS 14.2
- tvOS 17.2
- visionOS 1.0
- watchOS 10.2
Android SDK: Not Found
IDEs:
Android Studio: 2023.1 AI-231.9392.1.2311.11076708
Xcode:
version: 15.2/15C500b
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.9
path: /usr/bin/javac
Ruby:
version: 3.3.0
path: /opt/homebrew/Cellar/ruby/3.3.0/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: "18.2"
react-native:
installed: 0.73.2
wanted: 0.73.2
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Description
When running yarn ios, I expect it to run on the current open & running simulator, or to boot and run on an appropriate simulator. In the example shown below, I have the "iPhone SE (3rd generation)" already running, but the result is the same if it isn't running. It seems to try to use ios-deploy to install it onto my iPhone (connected to my computer via wifi only), rather than installing on the simulator.
$ yarn ios
yarn run v1.22.21
$ react-native run-ios
info A dev server is already running for this project on port 8081.
info Found Xcode workspace "MyApp.xcworkspace"
info Found booted Stefan’s Apple Watch, Stefan’s iPhone 15, iPhone SE (3rd generation)
error Failed to install the app on the device because we couldn't execute the "ios-deploy" command. Please install it by running "brew install ios-deploy" and try again.
error Command failed with exit code 1.
I have also tried previously running with --list-devices and choosing the iPhone SE so that it is "sticky," but that doesn't seem to have any impact
$ yarn ios --list-devices
yarn run v1.22.21
$ react-native run-ios --list-devices
info A dev server is already running for this project on port 8081.
info Found Xcode workspace "MyApp.xcworkspace"
? Select the device you want to use › - Use arrow-keys. Return to submit.
❯ Stefan’s Apple Watch
Stefan’s iPhone 15
iPhone 15 Plus
iPad mini (6th generation)
iPhone 15 Pro Max
iPhone 15 Pro
iPhone SE (3rd generation)
iPad Air (5th generation)
iPhone 15
↓ iPad Pro (11-inch) (4th generation)
Both of these places state that run-ios should open on a Simulator:
Reproducible Demo
I can put together a repro if necessary, but I believe this behavior is tied to the CLI, and not to anything specific to my app's code. As is the case with the default template generated, my package.json under the "scripts" section defines the ios command as such "ios": "react-native run-ios"
Activity
szymonrybczak commentedon Jan 10, 2024
Hey @swrobel, we'll change sorting device, so first it would try running on simulator not on physical device. But
--list-devicesshould work, and correctly pass simulator's UDID to the function. Can you please try using--interactive, which is the same thing and choose simulator and say what's the result?swrobel commentedon Jan 10, 2024
Just to be clear both
--list-devicesand--interactivelaunch the selected simulator, it's just that I thought it was supposed to be sticky, so the next time I run without any args, it should launch & use the last simulator that I selected. This doesn't seem to be the case after using these commands.szymonrybczak commentedon Jan 11, 2024
Okay, I gotcha. So actually the behavior that you described was added recently: #2162. And in #2251, we'll change what runs first - we'll prioritize simulators over devices in
run-ioscommand. If you have any other feedback, it's more than welcome! 🙏swrobel commentedon Apr 23, 2024
@szymonrybczak I finally had the opportunity to test this now that React Native 0.74 is released with the new cli, but the behavior does not seem to be improved. In this case, I'm attempting to run my app with the "iPhone 15 Pro Max" simulator already booted. My personal iPhone 15 is connected via wifi, which is why you can see it referenced below:
szymonrybczak commentedon Apr 23, 2024
Ah, okay so we're launching app in opposite order to the way we log them - fixed in #2364, log were not aligned with actual implementation.
Also I've shipped a small fix, so if you few simulators launched and you have your preferred one - it'll preferred one even if not inside
--interactiveor--list-devicesmode.In my personal experience launching on physical devices fails often than launching app on simulator, so we prioritize simulators over devices. Still in your scenario command will fail, but at least app will launch on simulators. I don't know we can improve expierence here 🤔
Fixes will ship in next patch for 0.74. Sorry for trouble and thanks for testing! 🙏
3plusalpha commentedon Jul 1, 2024
For those who still encounter this issue, this is the fix:
List all devices installed on your machine and select the UUID of the desired simulator
Then start the simulator using the following line:
This is the official way to select a device: https://reactnative.dev/docs/running-on-simulator-ios#specifying-an-udid
What the docs don't say it that the UUID of the device will be stored for the next time you run just
npm run iosszymonrybczak commentedon Jul 2, 2024
@3plusalpha Oh, yea we didn't sync docs with latest changes, do you mind submitting PR to
react-native-websiterepo? 🙏3plusalpha commentedon Jul 2, 2024
@szymonrybczak I don't know which changes you mean. The commands above are actually mentioned in the repo
szymonrybczak commentedon Jul 2, 2024
yea, but you've mentioned:
and I assumed that documentation is not clear for you in this aspect.
waldi commentedon Feb 28, 2025
For anyone looking: Start your iOS simulator before running
npm run iosIt seems to choose the first available/connected device
swrobel commentedon Jan 24, 2026
On React Native 0.83.1 with cli 20.1.0, the behavior seems to be much the same as it always has been, except that XCode no longer allows you to disable Wifi connection to iOS devices, so my iPhone always shows up as connected & available, and React Native tries to launch on it instead of on a simulator. I do want to keep my actual device is an available device, but I'm happy to manually choose it on the rare occasion that I want to develop there instead of the simulator.
What's the conclusion here? That both places that the docs say that
run-iosshould launch on a simulator are wrong, and should be updated to match the current behavior, or that the cli behavior is still wrong?