307

When I run this command:

react-native run-ios

My app runs by default in the iPhone6 simulator device:

Found Xcode project RN.xcodeproj
Launching iPhone 6 (9.2)...

How can I have the app run in a different simulator device (like iPhone5s) by default?

Rex Nihilo
5842 gold badges7 silver badges17 bronze badges
asked May 19, 2016 at 16:21
2
  • Xcode --> Product --> Destination ?? Commented May 19, 2016 at 16:38
  • 2
    I don't know how to setup default device, but after running react-native run-ios you can change device in Simulator > Hardware > Device > iOS x.x > iPhone 5. This will work until you quit simulator. Commented Jan 5, 2017 at 14:43

20 Answers 20

780

Specify a simulator using the --simulator flag.

These are the available devices for iOS 14.0 onwards:

npx react-native run-ios --simulator="iPhone 8"
npx react-native run-ios --simulator="iPhone 8 Plus"
npx react-native run-ios --simulator="iPhone 11"
npx react-native run-ios --simulator="iPhone 11 Pro"
npx react-native run-ios --simulator="iPhone 11 Pro Max"
npx react-native run-ios --simulator="iPhone SE (2nd generation)"
npx react-native run-ios --simulator="iPhone 12 mini"
npx react-native run-ios --simulator="iPhone 12"
npx react-native run-ios --simulator="iPhone 12 Pro"
npx react-native run-ios --simulator="iPhone 12 Pro Max"
npx react-native run-ios --simulator="iPhone 13 Pro"
npx react-native run-ios --simulator="iPhone 13 Pro Max"
npx react-native run-ios --simulator="iPhone 13 mini"
npx react-native run-ios --simulator="iPhone 13"
npx react-native run-ios --simulator="iPod touch (7th generation)"
npx react-native run-ios --simulator="iPad Pro (9.7-inch)"
npx react-native run-ios --simulator="iPad (9th generation)"
npx react-native run-ios --simulator="iPad Air (4th generation)"
npx react-native run-ios --simulator="iPad Pro (11-inch) (3rd generation)"
npx react-native run-ios --simulator="iPad Pro (12.9-inch) (5th generation)"
npx react-native run-ios --simulator="iPad mini (6th generation)"

List all available iOS devices:

xcrun simctl list devices

There is currently no way to set a default.

React Native Docs: Running On Simulator

Himanshu padia
7,8002 gold badges50 silver badges45 bronze badges
answered May 19, 2016 at 17:10
Sign up to request clarification or add additional context in comments.

6 Comments

And if you want; react-native run-ios --simulator="iPad Air"
To see all the available devices you can use xcrun simctl list devices more info here
Just in case if you have multiple simulator with same name for example iPhone 6s for ios 11 , iPhone 6s for ios 12 etc, then you can set specific name to simulator from Xcode -> Window -> Devices and Simulators
Why multiple "iPad Pro"s ?
If you need a specific OS version add it in parentheses: react-native run-ios --simulator="iPhone 11 Pro Max (13.4)"
|
71

You can also use npm for this by adding an entry to the scripts element of your package.json file. E.g.

"launch-ios": "react-native run-ios --simulator \"iPad Air 2\""

Then to use this: npm run launch-ios

answered Feb 7, 2017 at 16:06

4 Comments

IMHO this is the best answer as it allows you to store the config in code/version control. Means you dont need to remember the command line syntax.
I agree with this answer. You can also get by with singlequotes: "launch-ios": "react-native run-ios --simulator 'iPad Air 2'"
just a small improvement of = and single qotes as mentioned by @ifkwtz, i used in my scripts like : "ios:tpmx": "npx react-native run-ios --simulator='iPhone 12 Pro Max'"
I also think this should be marked as the answer since it kinda addresses the "default" device issue with the script entry
45

There are multiple ways to achieve this:

  1. By using --simulator flag
  2. By using --udid flag

Firstly you need to list all the available devices. To list all the devices run

xcrun simctl list devices

This will give output as follows:

These are the available devices for iOS 13.0 onwards:

== Devices ==
-- iOS 13.6 --
 iPhone 8 (5C7EF61D-6080-4065-9C6C-B213634408F2) (Shutdown) 
 iPhone 8 Plus (5A694E28-EF4D-4CDD-85DD-640764CAA25B) (Shutdown) 
 iPhone 11 (D6820D3A-875F-4CE0-B907-DAA060F60440) (Shutdown) 
 iPhone 11 Pro (B452E7A1-F21C-430E-98F0-B02F0C1065E1) (Shutdown) 
 iPhone 11 Pro Max (94973B5E-D986-44B1-8A80-116D1C54665B) (Shutdown) 
 iPhone SE (2nd generation) (90953319-BF9A-4C6E-8AB1-594394AD26CE) (Booted) 
 iPad Pro (9.7-inch) (9247BC07-00DB-4673-A353-46184F0B244E) (Shutdown) 
 iPad (7th generation) (3D5B855D-9093-453B-81EB-B45B7DBF0ADF) (Shutdown) 
 iPad Pro (11-inch) (2nd generation) (B3AA4C36-BFB9-4ED8-BF5A-E37CA38394F8) (Shutdown) 
 iPad Pro (12.9-inch) (4th generation) (DBC7B524-9C75-4C61-A568-B94DA0A9BCC4) (Shutdown) 
 iPad Air (3rd generation) (03E3FE18-AB46-481E-80A0-D37383ADCC2C) (Shutdown) 
-- tvOS 13.4 --
 Apple TV (41579EEC-0E68-4D36-9F98-5822CD1A4104) (Shutdown) 
 Apple TV 4K (B168EF40-F2A4-4A91-B4B0-1F541201479B) (Shutdown) 
 Apple TV 4K (at 1080p) (D55F9086-A56E-4893-ACAD-579FB63C561E) (Shutdown) 
-- watchOS 6.2 --
 Apple Watch Series 4 - 40mm (D4BA8A57-F9C1-4F55-B3E0-6042BA7C4ED4) (Shutdown) 
 Apple Watch Series 4 - 44mm (65D5593D-29B9-42CD-9417-FFDBAE9AED87) (Shutdown) 
 Apple Watch Series 5 - 40mm (1B73F8CC-9ECB-4018-A212-EED508A68AE3) (Shutdown) 
 Apple Watch Series 5 - 44mm (5922489B-5CF9-42CD-ACB0-B11FAF88562F) (Shutdown) 

Then from the output you can select the name or the uuid then proceed as you wish.

  1. To run using --simulator run:
npx react-native run-ios --simulator="iPhone SE"
  1. To run using --udid flag run:
npx react-native run-ios --udid 90953319-BF9A-4C6E-8AB1-594394AD26CE

I hope this answer helped you.

Fangxing
6,2152 gold badges55 silver badges58 bronze badges
answered Oct 27, 2020 at 18:25

2 Comments

this is best answer and most straight forward one .... thank you
I managed to run the app from Xcode on my device, but when I was running npx react-native run-ios, it was always running on simulator. npx react-native run-ios --udid [device id] did the trick for me. Thank you! +1
28

You can create an alias at your ~/.bash_profile file:

alias rn-ios="react-native run-ios --simulator \"iPhone 5s (10.0)\""

And then run react-native using the created alias:

$ rn-ios

answered Aug 10, 2016 at 18:07

Comments

28

There is a project setting if you hunt down:

{project}/node_modules/react-native/local-cli/runIOS/runIOS.js

Within there are some options under module.exports including:

options: [{ command: '--simulator [string]', description: 'Explicitly set simulator to use', default: 'iPhone 7', }

Mine was line 231, simply set that to a valid installed simulator and run react-native run-ios it will run to that simulator by default.

Shaked Sayag
5,7922 gold badges33 silver badges41 bronze badges
answered Jul 1, 2017 at 0:55

3 Comments

This actually worked, although file was hidden inside {project}/node_modules/react-native/local-cli/runIOS/
I don't actually have that module under node modules folder.
Yup, adding "runArguments": [ "--simulator", "iPhone 5s" ] to my launch configuration worked perfectly.
24

1) Rename your simulator, If simulator with same name but different iOS version

Xcode -> Window -> Devices and Simulators -> Simulators.

enter image description here

2) Open your react native project folder

3) Edit package.json

"scripts": {
 "start": "node node_modules/react-native/local-cli/cli.js start",
 "test": "jest",
 "flow": "node_modules/.bin/flow",
 "start-iphone6": "react-native run-ios --simulator \"iPhone 6 11.3\""
}

4) npm run start-iphone6

answered Jul 27, 2018 at 9:05

Comments

9

Update:

npx react-native run-ios --simulator="iPhone 14"
npx react-native run-ios --simulator="iPhone 13"

Get device list with this command

xcrun simctl list devices

Console

== Devices ==
-- iOS 13.5 --
 iPhone 6s (9981E5A5-48A8-4B48-B203-1C6E73243E83) (Shutdown) 
 iPhone 8 (FC540A6C-F374-4113-9E71-1291790C8C4C) (Shutting Down) 
 iPhone 8 Plus (CAC37462-D873-4EBB-9D71-7C6D0C915C12) (Shutdown) 
 iPhone 11 (347EFE28-9B41-4C1A-A4C3-D99B49300D8B) (Shutting Down) 
 iPhone 11 Pro (5AE964DC-201C-48C9-BFB5-4506E3A0018F) (Shutdown) 
 iPhone 11 Pro Max (48EE985A-39A6-426C-88A4-AA1E4AFA0133) (Shutdown) 
 iPhone SE (2nd generation) (48B78183-AFD7-4832-A80E-AF70844222BA) (Shutdown) 
 iPad Pro (9.7-inch) (2DEF27C4-6A18-4477-AC7F-FB31CCCB3960) (Shutdown) 
 iPad (7th generation) (36A4AF6B-1232-4BCB-B74F-226E025225E4) (Shutdown) 
 iPad Pro (11-inch) (2nd generation) (79391BD7-0E55-44C8-B1F9-AF92A1D57274) (Shutdown) 
 iPad Pro (12.9-inch) (4th generation) (ED90A31F-6B20-4A6B-9EE9-CF22C01E8793) (Shutdown) 
 iPad Air (3rd generation) (41AD1CF7-CB0D-4F18-AB1E-6F8B6261AD33) (Shutdown) 
-- tvOS 13.4 --
 Apple TV 4K (51925935-97F4-4242-902F-041F34A66B82) (Shutdown) 
-- watchOS 6.2 --
 Apple Watch Series 5 - 40mm (7C50F2E9-A52B-4E0D-8B81-A811FE995502) (Shutdown) 
 Apple Watch Series 5 - 44mm (F7D8C256-DC9F-4FDC-8E65-63275C222B87) (Shutdown) 

Select Simulator string without ID here is an example.

iPad Pro (12.9-inch) (4th generation)

Final command

iPhone

• iPhone 6s

react-native run-ios --simulator="iPhone 6s"

• iPhone 8

react-native run-ios --simulator="iPhone 8"

• iPhone 8 Plus

react-native run-ios --simulator="iPhone 8 Plus"

• iPhone 11

react-native run-ios --simulator="iPhone 11"

• iPhone 11 Pro

react-native run-ios --simulator="iPhone 11 Pro"

• iPhone 11 Pro Max

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

• iPhone SE (2nd generation)

react-native run-ios --simulator="iPhone SE (2nd generation)"

iPad

• iPad Pro (9.7-inch)

react-native run-ios --simulator="iPad Pro (9.7-inch)"

• iPad (7th generation)

react-native run-ios --simulator="iPad (7th generation)"

• iPad Pro (11-inch) (2nd generation)

react-native run-ios --simulator="iPad Pro (11-inch) (2nd generation)"

• iPad Pro (12.9-inch) 4th generation

react-native run-ios --simulator="iPad Pro (12.9-inch) (4th generation)"

• iPad Air (3rd generation)

react-native run-ios --simulator="iPad Air (3rd generation)"
answered Jul 8, 2020 at 7:16

1 Comment

But we don't want to run on simulator. We want to run on physical phone....
6

As answered by Ian L, I also use NPM to manage my scripts.

Example:

{
 "scripts": {
 "ios": "react-native run-ios --simulator=\"iPad Air 2\"",
 "devices": "xcrun simctl list devices"
 }
}

This way, I can quickly get what I need:

  1. List all devices: npm run devices
  2. Run the default simulator: npm run ios
answered Nov 12, 2018 at 2:37

Comments

5

Here is new path for changing iOS simulator you just need to change

default: 'iPhone 6' or something else 

Path:

<project_root>/node_modules/@react-native-community/cli/build/commands/runIOS/runIOS.js
Sourabh
8,51210 gold badges58 silver badges99 bronze badges
answered Apr 2, 2019 at 5:07

1 Comment

In my case file here : node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
5

You can use

npx react-native run-ios --simulator="iPhone 14"

Or Go to xcode and add a new simulator with the name "iPhone 6 (9.2)" (if you don't want to add --simulator="iPhone 14" each time )

answered Nov 7, 2022 at 6:45

Comments

3

SOLVED!

Run this command to see available simulators:

xcrun simctl list devices

and then run the command with the simulator that you want:

npm run ios -- --simulator="iPhone SE (3rd generation)"

Or you can add an entry to the scripts element of your package.json file. E.g.

"launch-ios": "npm run ios -- --simulator=\"iPhone SE (3rd generation)\""

Then just use this:

npm run launch-ios
answered Sep 22, 2023 at 5:48

Comments

2

I had an issue with XCode 10.2 specifying the correct iOS simulator version number, so used:

react-native run-ios --simulator='iPhone X (com.apple.CoreSimulator.SimRuntime.iOS-12-1)'
answered Apr 18, 2019 at 12:42

Comments

2

for iPhone Xʀ Simulator

 "iosxr": "react-native run-ios --simulator=\"iPhone Xʀ\"",

just add this to your scripts in package.json file

the letter "ʀ" used here is a different Unicode than "R"

then hit $ yarn iosxr to launch the app on iPhone Xʀ Simulator

answered May 24, 2021 at 10:31

Comments

1

I developed CLI tool for it.You can just type "rndcli".and select device

https://github.com/nazrdogan/rndcli

answered Dec 14, 2017 at 21:42

Comments

1

If you want to change default device and only have to run react-native run-ios you can search in finder for keyword "runios" then open folder and fixed index.js file change 'iphone X' to your device in need.

[1]: https://i.sstatic.net/BCtR1.png

answered Oct 26, 2019 at 18:32

Comments

1

for RN 0.64.2, the configuration is located at node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js, you can just revise the default simulator in the file

answered Nov 9, 2022 at 7:22

Comments

1

The best and the easiest way to change iOS device is:

  1. Open Simulator

enter image description here

  1. Choose File > Open Simulator > then choose the device you want
Penny Liu
17.9k5 gold badges89 silver badges109 bronze badges
answered Sep 18, 2023 at 11:51

Comments

0

1st case:
It happened on a login screen, where I had autoFocus on an TextInput. Commented that out and everything went back to normal.

2nd case:
With Expo!

After an update of XCode I was getting always the iPhone 12 Max simulator, but I prefered the iPhone 8. So here are the steps I took:

  1. While simulator on focus, go to File -> Open Simulator and choose the one you wish to be the default.
  2. Close the old simulator, close the localhost:19002 and stop the server in your terminal with ctr + C.
  3. Run npm start and then press i.

Now it's running on the simulator you left open.

Happy coding!

answered May 7, 2021 at 6:23

Comments

0

React Native will run the first device it finds in the list of simulators (If no simulator is supplied in the run command). To have it run a specific sim as the "default", you can re-order your x-code simulator list by deleting simulators and re-adding them. The first simulator (the one at the bottom of the list) is the one that will be run.

answered Apr 11, 2023 at 23:25

Comments

-4

change line code of /node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

line 55

 if (
 simulator.availability !== '(available)' &&
 simulator.isAvailable !== true
 ) {
 continue;
 }

replace which:

 if (
 simulator.availability !== '(available)' &&
 simulator.isAvailable !== true
 ) {
 continue;
 }
answered Aug 25, 2020 at 3:15

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.