Xcode compiles my App, but can't run it in the simulator

Ios5Ios Simulatorxcode4.3

Ios5 Problem Overview


when i compile my app, Xcode just says "Attaching to Projectname..." and gets stuck there. The debugger just prints this out: > error: failed to attach to process ID 0

I tried to clean & build again and it still doesn't work out. I googled but couldn't find anything helpful. How can I fix this problem? Thank You!

Ios5 Solutions


Solution 1 - Ios5

The solution for me was to delete everything Xcode has generated earlier:

  • the App on the Simulator...if this is not possible because you cant reach the Homescreen, you can delete the App directly under ~/Library/Application Support/iPhoneSimulator/6.0/Applications
  • delete the Derived Data in the Organizer under Projects or directly in ~/Library/Developer/Xcode/DerivedData
  • clean the Build Folder by choosing "Product" in the MenuBar and click while you press the Alt-key on "Clean Build Folder"
  • Restart Xcode

Solution 2 - Ios5

Have you tried closing down the simulator entirely, or failing that, reset the simulator and all its contents usually does the trick.

Solution 3 - Ios5

What finally got the simulator working again for me was deleting everything under Library/Application Support/iPhone Simulator/ within the user directory. What I think caused the problem for me in the first place was trying to use a directory named 'Resources' as described here: https://stackoverflow.com/a/1265168/649

Solution 4 - Ios5

This happened to me when I had two xcode projects open with the same bundle identifier.

Solution: leave only one project open which has the same bundle id.

Solution 5 - Ios5

Lindemann's solution worked for me. Nonetheless, during further development I came across another situation that generates this problem: if you create a folder reference (blue folder on Xcode's file explorer, as opposed to the yellow ones which are just groups) called "Resources" the same issue will arise. The solution in this case is to simply rename that folder. After this, follow Lindemann's solution.

Solution 6 - Ios5

I had similar issues when i installed XCode 4.5 on OS X Mountain Lion. I searched a while and tried some fixes but what finally solved the problem was adding "127.0.0.1 localhost" to my hosts file (/etc/hosts).

Here is what i have done:

Open a terminal shell with cmd+space > terminal
type in "cd /etc"
type in "sudo nano hosts"
type in your root password
add "127.0.0.1 localhost"
save with ctrl+o > return
close with ctrl+x
log out and log in again or restart

Solution 7 - Ios5

Ctrl-Shift-Option-K (same as holding down option and selecting Product ... Clean Build Folder) has always worked for me.

Solution 8 - Ios5

What seemed to work for me was build & run my code so that it opened the Simulator, then hold down on the Simulator Icon in the Dock and select Options -> Keep In Dock

After this I just closed the simulator and launched it from the dock and deleted the app from the home screen on the simulator.

Build & Run the app from XCode and everything seemed to be OK again.

Solution 9 - Ios5

There seems to be quite a lot of things that can cause this error, but for me it turned out to be that I was missing the key CFBundleIdentifier from my plist.

Added it back, and the simulator started normally.

Solution 10 - Ios5

Also make sure none of your file/group name collide with the projects default settings.

Things started breaking for me when I added an info.plist file to my project (Bad Idea). Same happens when you add a "Resource" Group. I don't have an exhaustive list, but if someone does please do share.

Cleaning out / Renaming these conflicting files and following the solution provided by Lindemann(https://stackoverflow.com/a/12504712/2069749) solved the problem for me.

Solution 11 - Ios5

Make sure you do not have an invalid build rule, that will cause this error, happened to me once (I had added a build rule by mistake and left it invalid).

Solution 12 - Ios5

You need to change the debbugger LLDB to GDB. This helped me start my program in the simulator.

Solution 13 - Ios5

What worked for me was that I realized i was messing with the project settings and accidently removed the info-plist section. After specifying the plist file again properly, it worked. Hope that helps someone.

Solution 14 - Ios5

If you are using a network account, you should replace the "~/Library/Application Support/iPhone Simulator" with a link to a local directory. This worked for me after trying everything else.

Solution 15 - Ios5

I had the same problem, in my case i have left the ios simulator open in one user account and switched (without logout the previous one) to another user account. I couldn't event able to open ios simulator to clear and reset its settings. [Shows could no open ios simulator OSStatus - 10829]

My solution: I quit the simulator in the first user account and then came back to second user account, every thing is working fine.

Solution 16 - Ios5

try to do next steps:

  • Go to Product/Scheme/Edit Scheme then select Run section.
  • Select Info Tan and set Debugger None.
  • Run project. It must be working (without debugger)
  • Go back to Edit Scheme and selecet debugger LLDB
  • Run project. It is working.

Maybe additionally you need to delete derived data and do Product/Clean

Solution 17 - Ios5

Can't tell you how frustrated I am trying to narrow down the cause of this one. Took me hours. Trial and error here and there.. all leads to nothing until one comment in one of the threads relating to this mentioned about "Executable". Boom! I remember the plist key "Executable file" in my project plist (PROJECT-info.plist). So I got there and found out that that entry was missing. I filled it in with whatever default you see when creating new project, "Executable file" paired with "${EXECUTABLE_NAME}". Build + Run. Then it finally worked!

Btw, I did try all those deleting/resetting stuff found all over SO. None of them works.

Solution 18 - Ios5

If resetting content and settings in the Simulator doe snot work for you, make sure that there is an entry for localhost in your /etc/hosts file:

127.0.0.1 localhost

Some programs can delete the line or comment it out (#) or even delete your /etc/hosts/ file completely. I tried everything described, but once I added localhost back to the file, the simulator worked perfectly for me.

Solution 19 - Ios5

What worked for me was to select 'Delete Derived Data' from the Projects tab in the organiser.

Solution 20 - Ios5

I fixed my problem by I making a new blank project and importing all the old files.

It must have been a problem with Xcode because it worked before iOS 5.1.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionlarsschwegmannView Question on Stackoverflow
Solution 1 - Ios5LindemannView Answer on Stackoverflow
Solution 2 - Ios5twilsonView Answer on Stackoverflow
Solution 3 - Ios5benoView Answer on Stackoverflow
Solution 4 - Ios5Ran RubinsteinView Answer on Stackoverflow
Solution 5 - Ios5PabloView Answer on Stackoverflow
Solution 6 - Ios5xxtesaxxView Answer on Stackoverflow
Solution 7 - Ios5nzeltzerView Answer on Stackoverflow
Solution 8 - Ios5JasonView Answer on Stackoverflow
Solution 9 - Ios5TobyView Answer on Stackoverflow
Solution 10 - Ios5PrashantView Answer on Stackoverflow
Solution 11 - Ios5j-aView Answer on Stackoverflow
Solution 12 - Ios5vovtilView Answer on Stackoverflow
Solution 13 - Ios5zakishaheenView Answer on Stackoverflow
Solution 14 - Ios5Cedric GuignardView Answer on Stackoverflow
Solution 15 - Ios5krishnanView Answer on Stackoverflow
Solution 16 - Ios5Philip J. FryView Answer on Stackoverflow
Solution 17 - Ios5MkValView Answer on Stackoverflow
Solution 18 - Ios5rmadamsView Answer on Stackoverflow
Solution 19 - Ios5PetrosView Answer on Stackoverflow
Solution 20 - Ios5larsschwegmannView Answer on Stackoverflow