20

In xcode 4.2, sometimes when you're going to run your ios proj on simulator, the status windows says "Attaching to myapp", and just gets stuck there... until you cancel. Now, this has been asked before: XCode 4 hangs at "Attaching to (app name)"

and surprisingly, besides the accepted answer on that thread, there are at least 10 other possible solutions others have been adding, all for the same issue, people says one of them worked while the others didn't...

please note, this is not a sequence of steps. each one is a possible solution:

1- restart xcode and/or restart simulator (reset content and settings) and/or restart computer.

2- click on project name in project navigator. in build settings tab, go to packaging and make sure that "Product Name" is the same that the one xcode says simulator is attaching to when running. if they are different, it will fail.

3- go to your projectname.xcodeproj folder. inside there delete anything named with your userid. when you reopen xcode those files will be recreated and it should work…

4- Manually delete the build directory for your project.

5- Go to organizer window. select Projects, select your app in the left hand side and then delete over "Derived Data"

6- Check Launch option is set to "Automatically" in Product->Edit Scheme, "Run" scheme.

7- In Project->"Edit Schemes"->Run. Change the Debugger from GDB to None (this doesn't make sense to me..).

8- Kill the process gdb-i386-apple-darwin from Activity Monitor. this is assuming gdb is not responding.

9- In "Product"->Edit Scheme. in Run, click yourappname.app, choose other, navigate to your .app in your project. now run.

10- Check that you don't have two different Info.plist in your project. if you do, remove the bad one.


In my case, none of them do the job. My project builds succesfully, everything seems fine, .plist, bundle identifier, name, etc.. and still can't pass the "attaching" part. i don't understand the reason of this, so any suggestions to fix it and possibly understand the problem i'll really appreciate it.

Community
  • 1
  • 1
Alexander Fradiani
  • 1,001
  • 3
  • 13
  • 33

12 Answers12

18

New projects were failing to launch in the simulator, getting stuck on the attach step.

This seems to be after Xcode 4.3 was installed, but I can't recall the last new project I created.

This is what worked for me, the clue coming from this thread...

Project->"Edit Schemes"->Run. Change the Debugger from LLDB to GDB

Another computer with the same version of Xcode works fine. Maybe my LLDB is corrupt?

Nick
  • 1,451
  • 1
  • 11
  • 6
  • This worked for me as well - unfortunately it seems that GDB is tremendously slower then LLDB. So while its a working solution - im still not happy with it at all :( – Salman Nov 03 '12 at 03:06
3

Did you recently upgrade to OSX 10.7.2? I started having the same problem after I upgraded. I noticed that the Simulator always get stuck if I'm connected to a Wi-Fi network that forces Captive Portal authentication. This happens with other apps as well (Chrome, Safari). I'm not really sure why this happens, but I did read that 10.7.2 has issues with Captive Portal authentication.

Anyway, in my case, I repaired disk permission from Disk Utility and rebooted my machine. This seems to resolve the issue.

nekoichan
  • 31
  • 4
2

Just rebooting the computer worked for me.

Z S
  • 7,039
  • 12
  • 53
  • 105
1

I also tried all solutions in that topic but all failed. But finally it was found out that what was went wrong.

What made this issue occurred is that some settings in Target->Build Settings was got modified by me for including C headers. And after I added all C headers and make it built. This issue occurred.

It might be only works on the situation I described before.

I just created an empty project and check all items in Target->Build Settings between the attaching-stuck app and the empty one. It was found that some items in the attaching-stuck one was different from the empty one.

So I deleted it and make it attached successfully.

WeZZard
  • 21
  • 3
1

It seems different in my case and also solved in a different way. If you got stuck every time after drop some files or folders into your project with the 'Create folder references for any added folders' way, this will be the solution.

Click the project node(the root node) on Xcode's project navigator and select target node. It's under the 'TARGETS'. Then click the 'Build Phases' tab. There are 4 sections of some list and you can click the triangle to expand the list. You need to concentrate on the 'Compile Sources' and 'Copy Bundle Resources' section. Code files like .m must be placed on the 'Compile Sources' section and are compiled automatically. Resource files like .jpg must be placed on the 'Copy Bundle Resources' section and are copied into the project's package. So, if the dropped files and folders are not in the 'Copy Bundle Resources' list, just drag it form the project navigator and drop onto the list. That will solve the problem.

If it doesn't work, delete all the referenced files and folders, click '+' button on the resource (or compile) section and click 'Add other...' button. Then you can include files and folders as the 'Create folder references for any added folders' way. I think the 'drag and drop' works well after the '+ button' way is done once.

In addition, 'Resource' may not allowed for folder name.

I experienced the 'stuck' problem every time when I attach files and folders as reference on Xcode 4.2 ~ 4.3.3. Reinstalling mac was a useless effort for me.

Wisebee
  • 390
  • 2
  • 10
1

Tried all the solutions but none applied to my case. XCode 4.2, OS X 10.6.8 Found that the Info.plist bundle identifier had been accidentally deleted when adding a custom app icon. Adding that back fixed the problem. Anyway that's my fix, hope it helps someone.

Also before figuring out that, found I could start the simulator from another app and then use the app icon on the simulator for the app that would not attach, and start it up that way.

sdjuan
  • 709
  • 6
  • 15
1

seems like there seem to be a lot of things causing this, but one thing that worked for me was simply cleaning out the build folder by pressing Cmd+Option+Shift+K or alternately if you select the Product dropdown in the toolbar and hold the Option button you should see the "Clean Build Folder" option appear

Will Ayd
  • 6,767
  • 2
  • 36
  • 39
0

I tried all of the solutions above but without luck ... When I search for simular problem here : Xcode error: failed to launch [directory] -- invalid host string: 'localhost'

I found it fixed my problem! Hope this helps those who are still searching for a clue .

Community
  • 1
  • 1
Berby Huang
  • 166
  • 1
  • 7
0

Upgrading to XCode 4.6.2 resolved this issue for me

epsilonpsi
  • 3,753
  • 3
  • 17
  • 16
0

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!

Community
  • 1
  • 1
MaheshShanbhag
  • 1,484
  • 15
  • 14
0

I have noted in Lion that when the iOS sim locks up or hangs the app, that if I go to a shell, and do ps -ef |grep SDK, I will see many, many processes running associated with the simulator.

I tried to kill off these processes but they rapidly respawn and the only solution then is to reboot. Also, in the ps output, you will also see instances of your app running as well.

So the Simulator issue is caused by previously running processes that appear to block the correct running of the latest one. I guess Apple will have a fix for this eventually, as it is quite onerous.

rachel
  • 1
0

Rebooting works for me, too, but this shouldn't be necessary. I'd recommend filing a bug at bugreport.apple.com. You can duplicate the one I created - the more it's duplicated, the more likely Apple is to fix the problem.

Josh Brown
  • 52,385
  • 10
  • 54
  • 80