How to change the default Xcode iphone simulator when testing
Asked Answered
G

14

44

I don't know why but now the default iphone simulator launched when I build the project is "ipad", but I want it to use iphone 3g instead.

Any way to set this preference?

Gessner answered 4/9, 2010 at 17:27 Comment(0)
C
3

For me works changing active SDK from 3.2 to 4.0. If your project is mentioned to work on iPad and iPhone (or for compatibility matters) I believe the only way is manually switching active executable before running your app on simulator. Apple:"iPhone OS 3.2 does not support iPhone and iPod touch devices. It runs only on iPad.".

Coppice answered 5/9, 2010 at 11:53 Comment(1)
may be this helps too. It works for me #2332714Gondar
F
63

On Mac, if you right click on the Simulator icon, you can select devices and it will open a new device.enter image description here

Or go to File -> Open Simulator

Flicker answered 14/9, 2021 at 14:14 Comment(0)
R
21

In Xcode,

Click Product -> Destination -> iOS Simulator -> Choose Device to run.

Then build and execute Xcode project.

It works..

Raab answered 9/12, 2015 at 11:3 Comment(0)
I
12

2022 Fix:

You have two options!

  1. With the simulator running go to File > Open Simulator > iOS [current version] and select the desired device.
  2. With the simulator running, right click the icon in the bottom toolbar, select Device > iOS [current version] and select the desired device

If you are using Expo, after selecting the new device will open in a new window, so you'll have both. Heres how to get Expo to run on the new device:

  1. Close the device window you don't want (cmd + w)
  2. You will now be able to "Run on iOS Simulator" and it will open up Expo Go on the new device.

2020 Fix:

  1. With the simulator running go to File > Open Device > iOS > iPhone 11 and select the device. It will open up the device as another window but there won't be the Expo app.
  2. Close the device window you don't want (cmd + w), then close the window with the device you would like.
  3. Restart Expo (in the command window with it running do ctrl + c then re-run Expo with expo start
  4. You will now be able to "Run on iOS Simulator" and it will open up with the selected device type.
Immersed answered 21/9, 2020 at 22:36 Comment(1)
i didn't understand the 3th point. you should start excode using terminal then quit it and start it again??Bateman
A
8

In the chance that anyone reading this is building their app in react-native, the solution is the --simulator option.

For example:

$ react-native run-ios --simulator "iPhone X"
Anglian answered 11/7, 2018 at 17:26 Comment(1)
Thanks mate, you have given a solution which doesn't require to build the project again and again.Brutus
G
6

Go to Hardware > Device from simulator menu.

Garris answered 11/8, 2017 at 13:55 Comment(0)
C
3

For me works changing active SDK from 3.2 to 4.0. If your project is mentioned to work on iPad and iPhone (or for compatibility matters) I believe the only way is manually switching active executable before running your app on simulator. Apple:"iPhone OS 3.2 does not support iPhone and iPod touch devices. It runs only on iPad.".

Coppice answered 5/9, 2010 at 11:53 Comment(1)
may be this helps too. It works for me #2332714Gondar
T
3

You can select the device from the menu inthe simulator.

Tabling answered 5/9, 2010 at 22:40 Comment(0)
L
3

Try Project > Active Executable , and select the one you want the most.

Lo answered 30/12, 2010 at 14:1 Comment(0)
D
2

None of the above worked for me, but the following took care of the issue :

Source: http://www.cocoabuilder.com/archive/xcode/301182-xcode-3-2-6-keeps-switching-to-ipad-simulator.html

Excerpt:

This works for Xcode 3.2.6. I don't yet use Xcode 4.x so don't know if this will work for it or not. I would also quit Xcode before doing this, just in case.

Go to the project folder and find the .xcodeproj file. Right-click (or Control-click) it and select Show Package Contents. When the package contents window appears, find the .pbxuser file (there might be multiple such files if the project was worked on by multiple folks and/or multiple computers). Open this file, which is XML, in your preferred text editor. Find the section with the comment "/* Project object */". There is most likely not a line in that section for the key "activeSDKPreference". If there is no such key, add the following:

activeSDKPreference = iphonesimulator4.2;

I found it after the "activeExecutable" key in that section, so I've been adding it in that same order.

If there is already an "activeSDKPreference" entry, change it to "iphonesimulator4.2".

Close the editor and the package contents window and then double click the .xcodeproj file to reopen the project. Now you should have entries for iPhone Simulator 4.2 and iPad Simulator 4.2 in the project settings pull down menu, with iPhone Simulator 4.2 probably already checked.

Additional Notes:

  1. In my particular case, my entry in .pbxuser file had said iphonesimulator4.3, even though under Project-Project Settings menu it said iphonesimulaor4.2!. However, once I changed it to iphonesimulator4.2 in the .pbxuser file it stop auto selecting iPad all the time.
  1. If you use SVN you will not see an "M" in SVN column showing that you changed the project (even if you refresh/update). However, just do a "Commit Entire Project" and your changes to .pbxuser file will get updated. I also suggest referencing this post in your check-in comment in case you ever need to change it back for whatever reason.
Durwood answered 21/7, 2011 at 17:31 Comment(0)
C
2

This worked for me. When I already have the app open on an iphone in "Simulator". I click File -> Open Simulator -> iOS 14.0 -> iPhone 8 (or iPad (7th generation))

Cheapjack answered 3/8, 2020 at 13:40 Comment(0)
R
1

I finally solved this problem myself.

First, install new version of Xcode, which is Xcode 4.

Then set project scheme to iPhone Simulator and run app in Xcode several times.

And re-install Xcode 3 and the problem will be gone!

Ramtil answered 26/4, 2011 at 5:31 Comment(0)
G
0

Yes, it's annoying. This worked for me: Open the .plist file in group/folder resources and check the checkbox for key "Application requires iPhone environment".

Georgie answered 12/3, 2011 at 12:51 Comment(0)
G
0

For Xcode Version 3.2.6 the following helps: Project->Active Executable->iPhone Simulator 4.3

I don't know if it is working for newer Xcode environments. Gary Tsui has also pointed out this approach previously.

Gwenette answered 10/3, 2015 at 8:22 Comment(0)
W
0

If you are using Flutter, open the Runner.xcodeproj file in ios/ folder. Then right next to the Runner breadcrumb, you can click >and select what device to launch.

Wicklund answered 7/7, 2020 at 0:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.