Running React Native apps on specific iOS simulators
👨💻 Perttu Lähteenlahti
Posted on October 31, 2019
Testing your app on multiple devices and screen sizes is a must. Luckily React Native makes this relatively quick to do. If you're developing React Native apps for iOS you're most likely familiar with this command:
react-native run-ios
In most cases, that command opens up the iPhone X simulator. Instead, if you want to open your React Native app in a specific simulator you can also add the wanted device name with the simulator flag like this:
react-native run-ios simulator='iPhone 8'
And it will open up the iPhone 8 Simulator. You can get the full list of available devices with the command
xcrun simctl list devices
And here's a list of all the available devices available for testing:
react-native run-ios --simulator="iPhone 5s"
react-native run-ios --simulator="iPhone 6"
react-native run-ios --simulator="iPhone 6 Plus"
react-native run-ios --simulator="iPhone 6s"
react-native run-ios --simulator="iPhone 6s Plus"
react-native run-ios --simulator="iPhone 7"
react-native run-ios --simulator="iPhone 7 Plus"
react-native run-ios --simulator="iPhone 8"
react-native run-ios --simulator="iPhone 8 Plus"
react-native run-ios --simulator="iPhone SE"
react-native run-ios --simulator="iPhone X"
react-native run-ios --simulator="iPhone XR"
react-native run-ios --simulator="iPhone XS"
react-native run-ios --simulator="iPhone XS Max"
react-native run-ios --simulator="iPhone 11"
react-native run-ios --simulator="iPhone 11 Pro"
react-native run-ios --simulator="iPhone 11 Pro Max"
react-native run-ios --simulator="iPhone XS Max"
react-native run-ios --simulator="iPad Air"
react-native run-ios --simulator="iPad Air 2"
react-native run-ios --simulator="iPad"
react-native run-ios --simulator="iPad Pro"
react-native run-ios --simulator="iPad"
I'm getting "Could not find iPhone X simulator" or similar error message when running this command
At times you might run into problems with this command. This error message, for example, is quite common:
Could not find iPhone X simulator
Error: Could not find iPhone X simulator
This error is often caused by updating to a new Xcode version, which doesn't include the iPhone X simulator any more, which is the default for react-native-cli. This problem should disappear when you pass the simulator flag and another device than iPhone X.
This was a quick and simple guide to running on different iOS simulators when building React Native apps. I wrote this because I found myself googling different device names too often. I hope that you find it useful. 🙂
This post originally appeared on my dev blog perttu.dev
Posted on October 31, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 11, 2024
October 13, 2024
October 4, 2024
October 25, 2024