I am new in expo
and react-native
Whenever i run the app from IOS simulator (inside expo) it always boots up the IphoneX. If i need to change the simulator,I have to open it through Xcode, is there any way we can change the default simulator ?
14 Answers
expo included an option in recent commits regarding this issue.
now you can tap shift+i
on terminal which expo server is running.It will list all simulators and you need to select your choice.
-
It doesn't work until I clean the expo cash with
expo start -c
, as @jonathan-sanchez said.– ArthurCommented Feb 25, 2022 at 11:01 -
3
Currently there is no way of changing the simulator from Expo. Expo just uses the last opened simulator in Xcode.
If that doesn't work, try this (updated here from my comment) :
When the simulator is open click on Hardware>Device> Select the other iphone.
Now both will be open. Next exit the simulator from the dock.
- Now try and open your project in the ios simulator from expo. It should open in the Simulator you selected from the hardware menu.
-
2No, it doesn't my last phone is always iphone6 but it opens iphonex Commented Dec 8, 2017 at 11:33
-
1This didn't work for me. Added answer for the method that did, see "Change the iOS simulator device that is open, and Expo will use it." Commented May 22, 2019 at 15:43
This worked for me on Feb 2021
on Mac OS with Big sur, expo v4.1.6
- Clean your EXPO cache with
expo start -c
(on your project location) - In the expo terminal press
shift + i
(see screenshot below)
- Then press
shift + i
and you should be able to select the Simulator by pressing enter on the one you need (see screnshot)
lastly Just wanted to share all the available options if you just press i
in the metro terminal window.
-
for me at least, I didn't need to clear the expo cache. Just shift-i in the terminal was enough. Thanks! Commented Mar 16, 2021 at 10:39
It is possible, but you can't target it from the command line. Expo will just target the last opened simulator.
Click on Hardware > Device and choose the device you desire
You now have two simulators open, make sure the one you want is active.
Now quit the simulator app with Command + Q
Now in your command line, when running the expo server, just click i
The simulator will open with your targeted device.
(As of December 3, 2020)
- Open Simulator
- Click on File ... (in the top-left menu bar)
- Click on Open Device ... (in the drop down list)
- Select your desired device and let it launch completely
- Quit Simulator ... (command + Q)
- Done
Running your app on iOS Simulator will automatically launch to this desired device now =)
Change the open iOS simulator device(s), and Expo will use it.
Expo directs its output to the open iOS simulator, so this must be done in the simulator itself rather than in Expo. It is simple to do. You can direct expo output to different devices. Here's how. BTW, other approaches described here didn't work when I tried them.
Open a second simulator in iOS Simulator by:
1) select eg Simulator->Hardware->Device->iOS12.1->iPhone 8
2) Select the simulator that you don't want to use (eg the current default as of writing, iPhone XR). Press Command-W to close the simulator window, leaving the iPhone 8 simulator still running.
3) In Expo, deploy the code to simulator as usual, either using the i at the command line, or selecting 'run on iOS Simulator' from the browser version of Expo.
4) It is possible to get expo to display to more than one simulator that is running at once (eg to test rendering on multiple screen sizes). Once you get expo running on one device (steps 1-3), you can repeat on an additional device (or presumably more). Expo will then be running on multiple simulators. They will simultaneously display the output. When I change my code, it immediately updates to multiple simulators/screen sizes without requiring any additional steps. Haven't re-tested exactly the order of steps to do this most easily, but it's working.
Hope this works for you!
Go to /Users/username/.expo/ios-simulator-app-cache/
and remove all files in there.
Run the ios simulator you want and run your expo project.
You just need to open the desirable simulator through Xcode, and then just run:
npm run ios
from your project directory or a similar command to start your app
I believe that yarn passes unrecognized arguments through to react-native run-ios
, so you should be able to pass --simulator="foo"
as described here: https://facebook.github.io/react-native/docs/running-on-simulator-ios.
I know the exact answer Once you open the Simulator from the Expo, go to Help menu and Search for "iphone11", "iphoneX" .... Then you should be fine
-
2Just to clarify, using the top menu, go to File > Open Device and then select the device. Commented Aug 19, 2020 at 15:59
-
Yes you are also right, I am using Mac that's why I said in different way– GuvanchCommented Aug 25, 2020 at 1:59
Restarting the computer was the only thing that worked for me. Without it pressing "Shift+i" had no effect. Neither Expo client would be installed on new simulator instance.
This was on macOS and M1 MacBook Pro for me.
-
1Closing the active simulator (close window ⌘W) -> Opening the one I want -> Restart worked for me.– alpereCommented May 7, 2021 at 12:59
You will likely get this error message: "No development build for this project is installed. Please make and install a development build on the device first." if you use the command expo start
and then choose a device using +i
.
Instead, the quickest solution to switch simulators AND get the build on the device is:
expo run:ios --device
This will then prompt you with a list of simulators, and after making a selection it will install the build and run it.
-
This was the only solution I've seen so far that worked for choosing the physical device and not just the simulator!
Shift + i
only listed simulators– ZoutCommented May 7 at 18:50
It would help if you launched your simulator on your specific device, or you can run this command:
npx expo run:ios --device "iPhone X"
Just launch simulator on which you want to run app and then run command i.e. "yarn run ios" or "npm run ios" to run on simulator. App will run on both simulator.
If it doesn't work then quit all simulator and then run the command i.e. "yarn run ios" or "npm run ios", then app automatically run on simulator which was latter launched.
Hope this may help you!