Can't run React Native App on Expo CLI simulator

Viewed 284

I created a React Native application using the command:

npx create-react-app my-app

After creating the project I try to run in a simulator with the command:

yarn ios

The app runs correctly but the terminal shows that it is opening on an iPhone 8, however the simulator opens on an iPhone 13 and the application never starts, I also start a simulator choosing an iPhone 8 as a device but the app does not start there either.

enter image description here

1 Answers

The React Native Docs recommend using the --simulator flag with react-native run-ios:

react-native run-ios --simulator=”iPhone 11 Pro Max”

If you run into (like I did):

command not found: react-native

Try running the script for iOS in your app’s package.json (often it’s ios):

yarn ios --simulator=”iPhone 11 Pro Max”

In theory npm should work also, but I didn’t have any luck. Your mileage may vary:

npm run ios --simulator=”iPhone 11 Pro Max”

List Available Devices

List available iOS devices:

xcrun simctl list devices

Available devices for iOS 13.3 on my machine:

iPhone 8 (2FE6CAE2–4908–4464–884A-5DED11505CE4) (Shutdown)
iPhone 8 Plus (F2A473F7–1F48–48DB-A6A6–584253814AA6) (Shutdown)
iPhone X (8FC4167D-AC9C-4F90–825C-9FB7004D03BA) (Booted)
iPhone 11 (E7885A5A-0306–4243-A852–8E71A7B0A5CB) (Shutdown)
iPhone 11 Pro (13B1AF48-BDD5–4AD7–8D7C-F31F3CF97FF5) (Shutdown)
iPhone 11 Pro Max (9C3B2313–258B-4E79–86A3–275D6BB3D078) (Shutdown)
iPad Pro (9.7-inch) (1A094DA7-A246–47B7–9716–5D8A9190C563) (Shutdown)
iPad (7th generation) (E0E0E252–5B96–4D2B-BD98–7D9ED79756AD) (Shutdown)
iPad Pro (11-inch) (143BB411-E726–4048–98E5-F87F04DEDCC2) (Shutdown)
iPad Pro (12.9-inch) (3rd generation) (14EFAE0F-C4D2–49E3-B501–633CB3E7DD00) (Shutdown)
iPad Air (3rd generation) (2797C8B5-E8FC-428A-AA4A-81F500153DDA) (Shutdown)

Commands for Your Convenience

Here are some commands with yarn that are ready-to-use for your convenience:

yarn ios --simulator=”iPhone 8"
yarn ios --simulator=”iPhone 8 Plus”
yarn ios --simulator=”iPhone X”
yarn ios --simulator=”iPhone 11"
yarn ios --simulator=”iPhone 11 Pro”
yarn ios --simulator=”iPhone 11 Pro Max”
yarn ios --simulator=”iPad Pro (9.7-inch)”
yarn ios --simulator=”iPad (7th generation)”
yarn ios --simulator=”iPad Pro (11-inch)”
yarn ios --simulator=”iPad Pro (12.9-inch)”
yarn ios --simulator=”iPad Air (3rd generation)”

Note

There is currently no way to set a default device for the Simulator.

Related