206
votes

I just upgraded to Xcode 4 and for some reason my app won't run in the simulator or iOS device. It was working perfectly in Xcode 3, but all of a sudden now when I press run the program stops at "Attaching to...". There doesn't seem to be any other info to help with this problem either.

For summary you can try following things to tackle the issue:

  1. Restart the simulator.
  2. Make sure that you haven't included the Info.plist file in your Building Phases -> Copy Bundle Resources.
  3. Resources folder added to the project as a folder reference (the blue folder icon). That caused the trouble, after adding the folder as a group the problem went away.
30
I also have this problem, a restart of xcode often fixes it temporarily, but it always comes back.NWCoder
Yea I had it with my other app too and was able to solve it by restarting, but this one won't run no matter what. Tried restart, iphone sim, ipad sim, ios device... nothing worksRob
I have been getting this when i added a directory to the project that is not a group but a regular folder. Specifically, when there is an added folder that has a name conflict with a group or file in the main project.yeahdixon
I got this issue when I draged a resources folder into the project. Deleting it doesn't fix it.Kit Sunde
Just change the debug option from LLDB to GDB by editing the scheme. (Worked For Me) stackoverflow.com/questions/10147356/…Ansari

30 Answers

104
votes

Fixed it!! Hopefully this helps some people avoid a very frustrating couple hours. I solved this by:

  1. Clicking on the project name in the left pane (at the very top). This will bring up a new menu to the right, something like the project/ target editors in XCode 3.
  2. Click on Build Settings up at the top.
  3. Under Packaging make sure your product name is the same for every build, and equal to whatever it says it's attaching to. Eg if XCode is Hanging at "Attaching to myLCBO" but your product name is "LCBO Finder" then it won't build. That was exactly my problem because I renamed my app half way through development.

Hope this helps!

72
votes

Here was our fix:

In Project > Edit Schemes > Run.

Change the Debugger from GDB to None (directly above the green circle in the image above).

40
votes

A tip I found at the Apple Developer Forums:

Go into your ProjectName.xcodeproj/ directory and delete anything named with your userid. Re-open the project in xcode and all that will get recreated and it should work. At least it did for me.

Another tip is to manually delete the build directory.

Yet another tip is to navigate to the Organizer (Shift ⇧ Command ⌘ 2 in xcode 4), select Projects, select you application in the left hand side and then the Delete...-button to the right of Derived Data.

And never forget the universally useful tip: restart your computer and try again.

Good luck!

28
votes

Solution provided didn't fix the problem in my case.

In order to solve it (XCode 4 only), I had to go to Product -> Edit Scheme. Then select the "Run " scheme, and marked "Automatically" which wasn't enabled.

Hope it helps someone.

http://tinyurl.com/3ma9xv7

18
votes

For everyone still trying to resolve this after everything you tried from above, try starting iphone simulator, clicking iOS Simulator in menu on top, Reset Contents and Warnings. This will erase all apps from simulator, but now you can finally use simulator!

11
votes

Restarting simulator works for me :)

11
votes

Also: make sure that you haven't included the Info.plst file in your Building Phases -> Copy Bundle Resources. If so, remove it from that list! I small mistake which could happen, but something that messes things up quite nasty :S

8
votes

One more possible solution: I had my Resources folder added to the project as a folder reference (the blue folder icon). That caused the trouble, after adding the folder as a group the problem went away.

5
votes

I really find the answer for me :)

for me,

project setting -> your target -> build phases -> validate setting -> perform

and now the problem is gone.

:)

I hope someone it help

3
votes

Like Rob said, but also check the "identifier" should read by default "com.yourcompany.YourAppName" I had changed the "yourcompany" by mistake and this caused the same issue noted above.

3
votes

I solved this problem how:

1) iOS Simulator->Reset Contents and Settings...

2) Sure project name, scheme name and target name is identical. "AppName" and "Appname" is not true. Must be "AppName" and "AppName", or "Appname" and "Appname".

3) Restart XCode and Quit Simulator.

Project name at Build Settings->Product Name.

Scheme name at Product->Manage Schemes. Click on current scheme once for rename.

Target name at Column of Project with Targets. Click once on current target for rename.

Good luck =)

3
votes

This also seemed to happen to me when the info.plist file was in the copy build phase. It appears that sometimes Xcode will warn you about this, and other times it won't. Very strange. But if you are experiencing this issue, make sure that info.plist is NOT in your copy build phase.

3
votes

My problem was also a folder named "resources" on the root source folder. Looks like it conflicts with some internal build naming.

Renaming the folder to "res" solved the problem for me.

3
votes

I tried everything in this page, and the "new" solution that worked for me was to go into the simulator, and "Reset Content and Settings" in the iOS simulator main menu.

3
votes

This solution is not technical but it worked for me.

When Attaching to Process shows up in xcode and it hangs for a while, just quite the iOS simulator and re-launch the app by pressing Command + R.

It will launch the app without any issues :)

2
votes

I tried everything and nothing worked. I have an old project from XCode 3. I simply renamed info.plist in the project to another name, restarted the simulator and everything is working fine since.

2
votes

I frequently encountered this problem after renaming a project in Xcode 4.

I was able to fix it by editing the Bundle Identifier in the .plist file.

After I renamed the project, the Bundle Identifier would change to something like this:

com.yourcompany.${PRODUCT_NAME:rfc1034identifier}

changing it back to this:

com.yourcompany.${PRODUCT_NAME}

will stop Xcode from hanging and allow the App to run.

2
votes

For me, none of these has worked. I realized that my project had 2 info.plist files (with two different names, like info.plist and Project-info.plist), so XCode got confused. I just removed the incorrect plist file, and it worked!

2
votes

Under Product > Edit Scheme > Run > Info, changed the Debugger from LLDB to GDB worked perfect for me!

1
votes

I had the same problem. The issue was there was one more user who was logged in and had the simulator running. Think there can be only one instance of iphone simulator running on a machine even for different users. Hope this info would be useful for somebody :)

1
votes

What worked for me is the following:

In XCode:

  • Click on project name
  • Click on target name
  • Click on "Build Settings"
  • Reveal "Product Name" contents (click on triangle)
  • Make sure the name of all items matches that of project name
    • Example
      • Product Name myapp
        • Debug myapp
        • Release myapp
  • Reveal "Deployment" contents (click on triangle)
  • Make sure there is a "IOS Deployment Target" item
    • Example
      • IOS Deployment Target IOS 3.0
        • Debug IOS 3.0
        • Release IOS 3.0

Then clean and run.

1
votes

This is what worked for me:

In Xcode navigate to the Product menu and choose EDIT SCHEMES.

In the list on the left choose Run YourAppName.app. From the Executable menu choose OTHER.

Navigate and choose your .app file in your project directory.

Now run and it works :)

1
votes

I noticed it happened to me when I edited the scheme from Build Release to Build Debug. I changed back, and it worked :)

1
votes

What worked for me:

  • Launch "Monitor" and kill gdb-i386-apple-darwin which was supposedly hung
  • Restart iOS simulator

enter image description here

1
votes

My solution is correcting the nib name. (I changed my nib name before for an iPad version but then I deleted the iPad nib file). Then it works well again.

1
votes

All of the above suggestion didn't resolve my problem. After I added the Resources folder and and compile, it hangs on attaching to app-name. I removed Resources folder, still hang. I removed the project and recreate a new one ( with the same name ) but still having problem. If it was different name then it's ok. I restarted the OS but still doesn't help.

To solve the issue, I did the following: 1. ps -ef | grep Xcode, and kill all the "Xcode" processes. 2. Reset the content of Simulator, and quit the Simulator. 3. Product > Clean to clean up the build. 4. Compile and run the product. It should work at this point.

Hope it helps some else having this similar issue.

1
votes

I encountered this error after incorporating another project inside my new one. Make sure you delete the project that you have added's info.plist and .app

1
votes

Just came across the same problem: restarting the simulator and Xcode didn't work for me, while restarting my mac worked out pretty well!

0
votes

After all said and done. I had to stop the simulator. Then the message change to downloading Mac OS X 10.6 core library.

0
votes

Create a new user account, switch to account, open XCode and try running the project. After trying all of the other suggestions with no success, not only was I again able to run on sim, but the original account now works.