XCode 4 hangs at "Attaching to (app name)"

Rob Source

This is driving me crazy! 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. Any ideas?

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.

Thanks.

iphoneobjective-cxcodeipadxcode4

Answers

answered 7 years ago Rob #1

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!

answered 7 years ago Jason #2

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.

answered 7 years ago macnico #3

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

answered 7 years ago Dunja Lalic #4

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!

answered 7 years ago sfmelon #5

If your app still doesn't work after changing Product Name, try to change "Executable file" also. I'd solved same problem with this method.

answered 7 years ago Premika #6

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 :)

answered 7 years ago Pål Brattberg #7

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!

answered 7 years ago Joseph Bolade Caxton-Idowu #8

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

answered 7 years ago Ken #9

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.

answered 7 years ago gnasher #10

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.

answered 7 years ago TheLearner #11

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 :)

answered 7 years ago jpmtrabbold #12

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!

answered 7 years ago InterThread #13

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).

answered 7 years ago LK. #14

I had this problem but the problem was different.

Another application was trying to add a certificate to the keychain and was hanging for some reason (network?). Reproduced this several time, and only when the keychain was free did was xcode able to run the app.

answered 7 years ago Lior Frenkel #15

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

answered 7 years ago Eric Reiher #16

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.

answered 7 years ago Alexander #17

I had the same issue.
The app suddenly hangs. After restart the simulator was black and the simulator hanged on "Attaching to ..."

My mistake was the following line in my code:

localnotification.repeatInterval = NSCalendarCalendarUnit; // Buggy, don't copy :)

Probably, the wrong assignment in the localnotification caused the wierd behaviour.

So, it also depends on your code!

So when you haven't changed the project setup and this issue appears, check your code before resetting the project setup.

Alex

answered 7 years ago Patrick #18

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

Verify that the Launch Automatically Radio Button is selected.

answered 7 years ago Prabh #19

Restarting simulator works for me :)

answered 7 years ago CReaTuS #20

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 =)

answered 7 years ago zoul #21

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.

answered 7 years ago maros #22

I was trying to use the all solutions, but none worked for me. I realised that the problem occured, when Info.plist had set any Target Membership.

Try to check out all checkboxes in Target Membership (Utilities) of all files called Info.plist.

answered 7 years ago HyLian #23

What worked for me:

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

enter image description here

answered 7 years ago noodl_es #24

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.

answered 7 years ago LondonRon #25

"attaching to ..." issue:

xcode 4.1 solution: Make a new template app in xcode 4.1 and run it in the simulator. This resets the error and xcode-sim bridging correctly :)

answered 7 years ago Morgan #26

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.

answered 7 years ago Le Tuan Hiep #27

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.

answered 7 years ago Øystein #28

I have had the same problem several times as well. Have tried all of the above suggestions, but the only that have worked for me, is to do a restart of my Mac. Seems like there are some process hanging.

If I where to know the name of it (it is not the my applications process) I would probably be able to just kill it, and not having to do the full restart.

answered 7 years ago sapsaldog #29

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

answered 7 years ago Rangel Reale #30

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.

answered 7 years ago RonnyD1978 #31

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

answered 6 years ago Michael Taylor #32

In my case, I tried most of the above solutions and nothing worked. Found that some of my other projects did work. Had an old version of the problem project and noticed that the Bundle Identifier had been removed! (Fat fingers when adding the icon file name!!)

Putting this back in fixed it for me.

answered 6 years ago Kevin Nguyen #33

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.

answered 6 years ago FishStix #34

I had tried everything. My "wrapper extension" was empty and the app wasn't getting installed in the simulator. I changed "wrapper extension" to "app" and it now installs in the simulator.

It's still hanging on Attaching to APP_NAME though...

EDIT Upgraded to Xcode 4.3, a couple more restarts and clean & builds and it's working now....

answered 6 years ago M2tM #35

I had this exact same problem when running on lion with the newest version of xcode. It ran this "helpful" wizard to swap my project settings to use LLDB instead of GDB which I thought was fine.

It was not fine. For our project LLDB just refused to attach and then caused the project to hang without any error messages. Swapping back to GDB manually resolved the problem.

You can do this in "Manage Schemes"

answered 6 years ago Rohit Pathak #36

I think it can be a simulator problem. If your application was built on an old simulator and you are trying to run on the old simulator but your xcode version is new, try to switch your simulator to new version

answered 6 years ago Nir Pengas #37

target -> Build Settings -> Packaging -> Wrapper Extension

the value should be app.

for some reason xcode modified the value above to the value of:

Project -> Build Settings -> Packaging -> Product Name

so in my schema i had a funky executable name, like projectName.productName instead of ProductName.app

so double check your schema before you hit command + R.

answered 6 years ago philippe #38

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.

answered 6 years ago roberto.buratti #39

Unbelievable... I had the same problem, would you like to know which was the exact cause? I added to my project a "blue folder" named "contents". Yes, just renaming the blue folder in anything else resolved the issue. And obviosusly renaming it again to "contents" reproduced the problem.

Hope this may help.

answered 6 years ago James Morris #40

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

answered 6 years ago user470763 #41

I tried all the main tips on this question but it still wouldn't work. Then I went into target Info (in the project settings section). In 'Custom iOS Target Properties' the old product name was appearing in:

  1. Executable file
  2. Bundle display name
  3. Bundle name

I had to change these to match my product name. I then reset the simulator and it worked.

answered 6 years ago DoctorG #42

Here's what worked for me on 4.3.3 (ultimately):

Erase the Derived Data Folder in XCode. Has no apparent untoward effects.

Go to Finder and Go to folder -> ~/Library/Developer/Xcode/DerivedData/ (Shift-Command-G).

Hope this helps someone who has tried everything else...

answered 6 years ago alexandresoli #43

Solved here using Xcode 4.3.3 repairing disk permissions.

answered 6 years ago Isaac #44

For me the solution was (as many of other people solutions) completely bizarre and rare.

What I did was something silly:

1.- Product -> Edit Scheme -> Run
2.- Click on the "Executable name" (Whatever.app), unfold the optons, and click "other"
3.- Navigate to the "Debug-iphonesimulator" directory and "re-choose" your original non-working Whatever.app filename
4.- Try to run/Clean your project.
5.- Build and Run again against the emulator.

Once I did this, my Whatever.app finally worked :)

(But after many minutes trying ALL things here and some other places, gosh! So frustrating!!)

answered 6 years ago Big Papoo #45

I was having this very annoying issue since a long time too. I've 3 different XCode versions installed and I'm not sure whether it's the reason or not that none of the above solutions worked for me. But here is the solution I finally found: I don't kill the running Simulator, I just try to launch it again using a Spotlight search, enter "Simu" and you should find it in Applications, then hit Enter. As it's yet running it will magically start my app that was frozen/locked/waiting for attachment. It works perfectly for me now and I hope it will also work for some (all?) of you.

BTW, I call Spotlight with a Cmd+Space, that way it's very quick to unfreeze the simulator without using the mouse.

answered 6 years ago zhangchiqing #46

This is a bug of XCode 4.4.0 After I updated XCode to 4.4.1, this problem went away.

answered 6 years ago Stanislav Pankevich #47

None of the answers presented here helped me.

I've set up "Launch" radio button in the "Edit Scheme / Info" section to "Wait for MyApp.app to launch" instead of default "Automatically".

It stopped to hang, now it does not start simulator and traces the following in the logs behind the curtains:

error: attach by name 'MyApp' failed
unable to create lldb_private::Process

After trying to google it, this error seems to be a rather rare one.

I do not expect that this error is generic for all cases here, but anyway hope that my post will add some extra details to the discussed issue.

Xcode: Version 4.4.1 (4F1003)

answered 6 years ago Leo Correa #48

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

answered 6 years ago ff10 #49

Xcode failed to attach while the Network Link Conditioner was active. Try to activate it after the attaching has been done.

answered 6 years ago Basheer #50

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 :)

answered 5 years ago Chris Conway #51

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

answered 5 years ago sprockett #52

If you are using any kind of FIREWALL software (little snitch, TCP Block etc)

MAKE SURE YOU MONITOR IF XCODE / RELATED PROCESSES ARE BEING BLOCKED.

Once i whitelisted all relevant proceses, the "attaching" issues were solved.

answered 5 years ago Darshan #53

In Xcode 4.6. Just Change Debugger from LLDB to GDB in Edit Scheme.

Product > Edit Schemes > Run

Change Debugger to GDB

answered 5 years ago andreb #54

I had the problem that in Xcode 4.2 on Snow Leopard 10.6.8 when trying to use GDB as Debugger, it would just show "Running..." but non of the breakpoints would actually work. In fact debugging of the app wouldn't even start.

A quick glimpse at Activity Monitor revealed gdb-i386-apple-darwin would hang at 100% CPU activity.

For me the solution was to reset my heavily customized ~/.gdbinit file (several thousand lines long) which would otherwise work fine when gdb is launched from the command line. As soon as I renamed that file so GDB wouldn't load it everything worked fine.

For the record I had that gdbinit file mess up GDB in Xcode 3.2.6 and Xcode 4.2 on the same machine.

answered 5 years ago Topsakal #55

Xcode 4.6.3 update (June 13, 2013) resolves the following issue:

  • Hang when debugging in iOS Simulator on OS X 10.8.4. 13722320

https://developer.apple.com/library/mac/#releasenotes/DeveloperTools/RN-Xcode/

You can try to update your Xcode to see if that works for you.. After installing new XCode version and restarting the Xcode, the problem is solved.

answered 5 years ago Fahim Parkar #56

The best option would be

  1. Quit Simulator
  2. Open Another Project
  3. Run Project (just for the sake simulator opens)
  4. Delete the earlier project from simulator
  5. Clean the main project
  6. Run again

Enjoy!!!

answered 5 years ago MaheshShanbhag #57

Even if the app is not attaching after cleaning the project, changing the app name, restart the by resetting the simulator, and if you are using LLDB compiler, it is because the LLDB compiler is not able to connect to the local debug server in order to solve this, take a look at this

Why does the LLDB Debugger constantly fail to attach?

This really solves your problem!

comments powered by Disqus