96

I am unable to launch my app on simulator using Xcode 6 beta and iPhone 5s simulator. First I am getting an error message from Simulator

"Unable to boot the iOS simulator"

and then after Xcode is showing me following error,

Unable to run app in Simulator
An error was encountered while running (Domain = DTiPhoneSimulatorErrorDomain, Code = 2)

Xcode Error

Cœur
  • 37,241
  • 25
  • 195
  • 267
Hemant Chittora
  • 3,152
  • 3
  • 19
  • 25

23 Answers23

132

I solved it following these steps:

  1. Open Xcode 6 beta
  2. Go to the menu Xcode > Open Developer Tool > iOS Simulator
  3. Even if an error dialog shows up, you still would have access to the iOS Simulator's menu
  4. Select Hardware > Device > Manage Devices
  5. Click on the little + sign at the bottom
  6. Add (if missing) all the devices that you want, or delete and recreate the ones malfunctioning.
  7. If anyone of the simulator is not working then right click on it and delete it and then re-create it again

enter image description here

Sam B
  • 27,273
  • 15
  • 84
  • 121
apascual
  • 2,970
  • 1
  • 20
  • 32
  • 3
    If I create (or use) a iOS 7 simulator. It works good. It fails only with iOS 8 simulator. Some link could be broken – Oscar Jun 23 '14 at 16:17
  • This worked for me. I only tried it after changing the command line tools setting as per ayalcinkaya's answer, so that may be necessary as well. – dokkaebi Jul 05 '14 at 17:45
  • 1
    @Dayan Gonzalez I have same issue in my mac mini how can i fix? – PREMKUMAR Sep 12 '14 at 10:54
  • I solved the connection problem with these steps. Neither restart iOS simulator nor restart system can solve. – likid1412 Mar 09 '15 at 09:31
67
  • Make sure you choose Xcode 6 as Command Line Tools in Preferences > Locations Section

Xcode 6 Preferences

  • Make sure you open Xcode 6 from Applications not from the setup file.

  • Finally restarting Mac solve the problem in my case.

Cœur
  • 37,241
  • 25
  • 195
  • 267
ayalcinkaya
  • 3,303
  • 29
  • 25
  • 7
    This didn't work for me either. I had 5.1, I changed it and restart the xcode and mac. And the error is still there – Oscar Jun 04 '14 at 16:15
  • 1
    Did not fix my issue. – Mantas Vidutis Jun 17 '14 at 20:22
  • +1. Selecting the Location for cmd line tools and then rebooting fixed it for me! – Mike Pollard Aug 19 '14 at 19:37
  • Reboot (not even logout/login) does indeed appear to be necessary. WTF Apple? – MattD Sep 08 '14 at 18:29
  • 3
    Nothing this sort of solution is helping. What do I do.? – iAnurag Sep 17 '14 at 09:57
  • Command line tools has nothing to do with the iOS Simulator. The only relevant item in your suggestions was the reboot which indicates that the issue you were seeing was because you likely renamed Xcode.app (or deleted an old one at a different path) after first launching it. This is a documented issue in the release notes. If other users still see this problem, please see my answer regarding DYLD_INSERT_LIBRARIES. – Jeremy Huddleston Sequoia Sep 28 '14 at 07:36
  • Try connecting a device and run any of the app on device directly through xcode . Some download will start automatically for xcode. Once downloading is done you will be able to run your apps on simulator.Problem with simulator launch was caused of missing libraries.There is a direct option also must be available to download those missing libraries somewhere under more simulators i think. – IOS Dev Sep 29 '14 at 20:13
  • I've tried and selected a new xcode I installed on Command Line Tools. I quit xcode and simulator both and opened again. It's started working now. – Kiran Jasvanee Jan 12 '17 at 10:52
6

After I found some solutions on the web, a combination of procedures worked for me:

  1. Close Xcode and iOS Simulator (and all related applications)

  2. Install (or reinstall) Xcode6-Beta to Applications folder (direct from the .dmg file)

  3. Open Xcode6-Beta and go to Xcode -> Preferences -> Locations -> Command Line Tools and select "Xcode 6.0" (be sure that you've selected the one in Applications folder)

  4. Launch the iOS Simulator and go to iOS Simulator -> Reset Content and Settings...

  5. Close all the applications and restart your mac (I unchecked "Reopen windows...")

  6. Open Xcode6-beta and test the iOS Simulator

Good luck

ugo
  • 2,705
  • 2
  • 30
  • 34
Alexandre
  • 564
  • 4
  • 6
5

I'm using Xcode 6 beta 2 and has problem (error code = 4 in my case) running iPad simulators. I think I had the issue because I'm running dual Mac OS boot and the Xcode is launched from another startup disk

I did both steps recommended by @ayalcinkaya and @apascual, and this worked for me.

  • Change the "Command Line Tool" to Xcode BETA2 (from 5.1.1 in my case) in "Xcode->Preference->Locations"
  • Open Xcode 6 beta 2
  • Go to the menu Xcode > Open Developer Tool > iOS Simulator
  • Even if an error dialog shows up, you still would have access to the iOS Simulator's menu Select Hardware > Devices, and switch between iPad devices and this apparently made the simulators reconfigured
  • While the simulator is running, run the app with the selected simulator.
  • After going through this manual process once, everything is fine.
Cœur
  • 37,241
  • 25
  • 195
  • 267
Fred Yang
  • 179
  • 6
  • 1
    The "error code = 4" (in some FBS domain) issue is not related to this issue. That issue pertains to a race condition in app install and launch. The workaround for that is unfortunately just to retry the build&run. – Jeremy Huddleston Sequoia Sep 28 '14 at 07:35
4

This happens most of the times because another instance of the simulator is running in the dock.

Kill the other instance & things should work fine.

footyapps27
  • 3,982
  • 2
  • 25
  • 42
3

I also had this problem and found the solution by doing following steps:

  1. Initially I downloaded Xcode 6 library in Documentation section under the path Xcode --> Preferences --> Downloads and restart my xcode but didn't solve my problem.

After that ->

  1. Downloaded and installed the iOS 7.1 Simulator under the path Xcode --> Preferences --> Downloads.

Restart xcode again and the problem solved.

  1. I am facing same issue again next morning.

Unsetting the DYLD_INSERT_LIBRARIES variable solves my problem:

a) Open terminal and type "sudo vi /etc/launchd.conf" command and press Enter
b) Press I "Insert" mode and change this

    "setenv DYLD_INSERT_LIBRARIES /usr/lib/libimckit.dylib" 

to this

    "unsetenv DYLD_INSERT_LIBRARIES /usr/lib/libimckit.dylib" 

and press esc to exit from insert mode.

c) Save changes by typing ":wq" Press Enter
d) Reboot your system and problem solved.

enter image description here

Prior to that I didn't found any iOS version in front of each listed devices but after installation or by unsetting DYLD_INSERT_LIBRARIES variable I found the same in front of each devices.

enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267
iGW
  • 633
  • 5
  • 14
2

I got this problem after renaming the default folder name "Xcode-Beta2" to "Xcode". When I renamed it back to "Xcode-Beta2", the simulator worked as before.

Golden Thumb
  • 2,531
  • 21
  • 20
2

What worked for me was removing all of the devices in "Manage Devices" and adding them back after rebooting

lubert
  • 109
  • 1
  • 6
  • OMG thank you for this post... this has been the second time the simulator has been shut down for me this beta period. FIXED – Leif Ashley Aug 20 '14 at 15:13
  • In my case, rebooting did the trick. No need to remove and readd devices. – Ziconic Aug 23 '14 at 02:45
  • The only relevant bit there was the reboot. You didn't need to delete and re-add devices. I suspect that you renamed Xcode.app after first launch which causes you to no longer be able to use the iOS Simulator in that Xcode.app. – Jeremy Huddleston Sequoia Sep 28 '14 at 07:32
1

Clean -> Run fixed it for me.

I've tried the rest, nothing helped. Although it may be required too.

Kof
  • 23,893
  • 9
  • 56
  • 81
1

I've had the same problem, when running an app with the same name as a previously run different app.

Run "foo" -> make a new project named "foo" -> run -> error.

Whatsoever - it seems to me that there are several reasons for iOS-Simulator to say "ehm, what do you want from me? OK, I'll throw an error..." ;-)

MY SOLUTION: Close iOS simulator, run app again.

That's it in most of cases like this.

HBublitz
  • 670
  • 4
  • 6
0

The most common cause for the error reporting is that DYLD_INSERT_LIBRARIES is set. Most people reporting this issue have had it set in /etc/launchd.conf. You can edit that file to remove it (or just delete the file as that's likely the only line) and reboot to address the issue.

Another possible cause for this problem is that you may have renamed Xcode.app after running it the first time. If that's the case, just reboot (or rename it back to what it was before).

Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
0

I found that I have to update to newest OS X 10.10.1 (From OS X 10.9.5) to get iOS 8.1 to work.

Cœur
  • 37,241
  • 25
  • 195
  • 267
IQn
  • 133
  • 1
  • 4
  • 11
0

Yes apascual is correct https://stackoverflow.com/a/24080160/2905967

But for me, before step 5, I have deleted the simulator device (select and by pressing Delete key from keyboard) Which device is giving the Problem. Reference: apascual answer

Community
  • 1
  • 1
Manab Kumar Mal
  • 20,788
  • 5
  • 31
  • 43
0

These steps may help you with your problem. Try this:

  1. Click iOS Simulator at the top of your screen

  2. Click Reset Contents and Settings

  3. Click Reset when the Alert comes up

  4. Run the App again on the Simulator

This will simply reset all the contents and settings on the iOS Simulator previously.

Bigfoot11
  • 911
  • 2
  • 11
  • 25
0

I had the same problem and only solution that helped me to fix this was to reinstall Xcode.

zvjerka24
  • 1,772
  • 1
  • 21
  • 27
0

Delete simulator/s and create again in Xcode/Window/Devices worked for me...

Renetik
  • 5,887
  • 1
  • 47
  • 66
0

Perfect answer for this fix is here

In this case, launchd is crashing when trying to launch.

This could be as a result of deleting the /private/tmp folder.

To resolve this, I typed the following commands on my terminal:

sudo mkdir /private/tmp 
sudo chmod 1777 /private/tmp
Noor
  • 967
  • 7
  • 18
0

In Xcode 11, I found running the following in Terminal worked:

sudo xcode-select --reset

Src: https://ekartco.com/2019/10/xcode-11-unable-to-boot-simulator-diehard/

lewis
  • 2,936
  • 2
  • 37
  • 72
0

None of the above suggestions worked for me.

Changed the Embed setting for the complained framework to Do Not Embed resolved the issue.

Build Setting

Vittal Pai
  • 3,317
  • 25
  • 36
0

What worked for me is just open the simulator and leave it open for a while it will probably boot up. I think in my case it was just trying to load the things or something like that or just my mac is slow.

Try leaving the simulator open for some time if it still does not boot then you may try any of the solutions here.

Viraj Doshi
  • 771
  • 6
  • 26
-1

I had this problem until I put the Xcode 6-beta application file from inside a folder I had in my application directory to the Application directory itself. Restarted computer. Then it worked.

To test, I created a folder in my Application directory again and put my Xcode application in there and, again, it did not work. Put it back into Application directory itself; it worked. I didn't even have to restart in these cases.

I would really hope Apple is beyond hardcoding paths.

  • The paths aren't hard-coded. The issue is that you loose access to the simulator if you rename Xcode.app after the first time you launch it. This is a known issue and is indeed in the release notes for Xcode 6. – Jeremy Huddleston Sequoia Sep 28 '14 at 07:30
-1

i was facing the same problem, what i done is I downloaded simulator for IOS7 what you need to do is go to:- 1.Xcode->preferences->Downloads->Components 2.after that in your project under general settings-select Deployment target as 7.0 3.the last thing is select any simulator under 7.0 :)

guri23
  • 65
  • 5
-1

I received this error trying to run one of my iPad only apps on the iPhone Simulator. It's built as a universal app, I've run it multiple times on the iPhone for testing, and I only recently checked the "iPad" only checkbox in the Target config.

When trying to run it on my iPhone Device, I got the much more helpful error message: "The application at [/location/..../Name.app] can only be installed on iPads."

FishStix
  • 4,994
  • 9
  • 38
  • 53