206

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.
Cœur
  • 37,241
  • 25
  • 195
  • 267
Rob
  • 7,028
  • 15
  • 63
  • 95
  • I also have this problem, a restart of xcode often fixes it temporarily, but it always comes back. – NWCoder Mar 21 '11 at 20:14
  • 5
    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 works – Rob Mar 21 '11 at 20:58
  • 4
    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 Sep 26 '11 at 16:09
  • 4
    I got this issue when I draged a `resources` folder into the project. Deleting it doesn't fix it. – Kit Sunde Nov 03 '11 at 18:52
  • @KitSunde I dragged a `resources` folder into my project as well. Maybe that's the problem? How did you resolve it? – joshim5 Nov 10 '11 at 20:47
  • @joshim5 I just deleted the project and created a new one since I was only doing a simple UIWebView app that took 5 minutes to setup. – Kit Sunde Nov 11 '11 at 02:43
  • 4
    Just change the debug option from LLDB to GDB by editing the scheme. (Worked For Me) http://stackoverflow.com/questions/10147356/xcode-4-3-2-wont-attach-to-debugger – Ansari Jun 25 '12 at 13:35
  • It solved the problem: Make sure that you haven't included the Info.plst file in your Building Phases -> Copy Bundle Resources.By @RonnyD1978 – user739711 Aug 12 '12 at 12:50

54 Answers54

104

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.
starball
  • 20,030
  • 7
  • 43
  • 238
Rob
  • 7,028
  • 15
  • 63
  • 95
  • Yea I don't think it always works, but it's definitely one of the issues you might encounter – Rob Apr 01 '11 at 05:41
  • This doesn't fix the error for me. Using XCode 4.0.1, I start a new project, build and run it without modifying the default template - works. Without quitting the simulator, I make some changes, run again, still works. Then I quit XCode and the simulator, next time I run - hangs at "attaching to ". – Tomas Andrle Apr 04 '11 at 23:16
  • And clean all targets (Xcode 3.x) or Clean product (Xcode 4.x). This helped me when I thought this solution does not work. – Lukasz Apr 18 '11 at 09:37
  • Thanks, this resolved the problem for me too. For some reason the debug product name was incorrect whereas the release one was correct. – Andy Bowskill Apr 25 '11 at 22:09
  • I had the same behaviour, but I had to change the iOS target property "Application requires iPhone environment" from "YES" to "NO" to get it to work. – nikkumang May 07 '11 at 06:43
  • 17
    Try this: Reset Simulator, Clean Build, Quit Simulator, Run Project. Should work. – Jordan Jun 16 '11 at 11:38
  • I don't know how ya's done it, but I know YA'S DONE IT!! Dude, saved me tons of time. Thanks! – gonzobrains Jul 08 '11 at 06:39
  • 4
    @Jordan: didn't help, but rebooting did. Lion bugs bigtime for me and my Mac mini. – Jonas Byström Nov 02 '11 at 10:20
  • One additional note; if you've tried **everything** discussed here and you still get this problem, check to see if your app is deadlocking on the main thread. I was having a lot of frustration with this issue, and finally found that a coding bug was causing the main thread to get stuck. – aroth Jul 22 '12 at 13:48
  • This fixed my problem, however it does not fix the problem that I need to rename my product for this specific target. How can I get around this problem by changing XCode's expectations rather than having to change my product name to fit XCode's expectations? – Ahab Aug 16 '12 at 19:20
72

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

Himanshu
  • 31,810
  • 31
  • 111
  • 133
InterThread
  • 61
  • 3
  • 2
  • This helps for me too, but obviously, there is no bug reporting on errors, just NSLog support – oberbaum Jan 09 '12 at 18:23
  • 13
    This fixes it for me, but I really wish I knew why/how to actually fix it. It was actually LLDB that was causing it. Switching to GDB works fine. – justinxreese Apr 30 '12 at 00:30
  • 4
    Thanks, fixed the issue but not the problem. Apple needs to try using their crap before releasing it. – Stephen Punwasi Mar 31 '13 at 22:25
  • I tried all the other tips on this page. Then, switching debugger from LLDB to none did the trick. Thanks! – thomax Oct 17 '13 at 18:27
  • Works, and working with NO debugger it enables you to work faster.. Of course, if you need to debug, switch it back on. – Matej Dec 20 '13 at 23:47
  • It's worth noting that this solution mentions 'Project > [...]' this might be available in other (older) versions of Xcode but in mine it's named 'Product > [...]' (as in the answer of @macnico ;) – Tommy Bravo Jan 11 '14 at 22:51
40

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!

Pål Brattberg
  • 4,568
  • 29
  • 40
  • 7
    believe it or not, I tried everything on this page and restarting xcode multiple times without success. I finally just rebooted my machine, and then it worked. Crazy. I thought that was only a Windows solution :) – dreyln May 11 '11 at 19:40
  • 1
    I had exactly the same problem and deleting everything with my userid and restarting Xcode resolved it. – Nikita Zhuk May 17 '11 at 07:28
  • Deleting the derived data worked for me (3rd tip). This problem happened when I added files to an XCode project and this solved it. – Jonathon Horsman Jun 30 '11 at 07:44
28

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

sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161
macnico
  • 206
  • 2
  • 3
21

For everyone still trying to resolve this after everything you tried from above, try reseting the iPhone Simulator.

Simulator > Device > Erase All Content and Settings...

This will erase all apps from simulator, but now you can finally use simulator!

pkamb
  • 33,281
  • 23
  • 160
  • 191
Dunja Lalic
  • 752
  • 13
  • 26
11

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

RonnyD1978
  • 1
  • 1
  • 2
10

Restarting simulator works for me :)

Prabh
  • 2,466
  • 2
  • 24
  • 27
8

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.

zoul
  • 102,279
  • 44
  • 260
  • 354
5

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

sapsaldog
  • 41
  • 1
  • 3
4

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

CReaTuS
  • 2,593
  • 1
  • 19
  • 31
3

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.

Nate
  • 31,017
  • 13
  • 83
  • 207
philippe
  • 1,877
  • 2
  • 20
  • 25
3

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

Basheer
  • 1,207
  • 9
  • 10
3

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.

Jason
  • 650
  • 2
  • 10
  • 33
  • You solved it for me! Curious to know the correct way to change "yourcompany". – Andrew May 05 '11 at 23:31
  • check out this link to change it the correct way. (http://stackoverflow.com/questions/2956464/where-do-i-set-my-company-name/5264348#5264348) – Jason May 06 '11 at 02:22
  • Thanks a ton.. I tried all of the above but nothing worked!! wish I could give you 100 votes up :P – Ahmed Dec 14 '11 at 15:39
3

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.

Morgan
  • 1,765
  • 2
  • 19
  • 26
  • I had setup a folder structure by drag & drop and Xcode added them to the "Copy Bundle Resources" build phase. Removing the folders from that phase fixed it for me. – fphilipe Mar 05 '12 at 14:29
3

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.

Rangel Reale
  • 698
  • 6
  • 7
2

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

Leo Correa
  • 19,131
  • 2
  • 53
  • 71
2

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!

PengOne
  • 48,188
  • 17
  • 130
  • 149
  • This was it for me, I tried many other things suggested by others. If you created a new Xcode4 project and tried to add in your old files, this might be your culprit. – zekel Jan 10 '12 at 19:56
2

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.

  • +1 Renaming MyApp-Info.plist to something else broke my build, but renaming it back again magically fixed the hang at "Attaching..." for me. – Ergwun May 01 '12 at 05:23
2

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.

noodl_es
  • 1,467
  • 1
  • 17
  • 28
1

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

James Morris
  • 163
  • 1
  • 10
1

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

Chris
  • 4,403
  • 4
  • 42
  • 54
  • Same here, restarts to the apps didn't work, and restarting the mac did. Also, this problem, for me, cropped up suddenly and mysteriously in the middle of the workday, not as a result of upgrading xcode or any other bigger task. – Joey Mar 19 '13 at 21:09
1

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

Premika
  • 3
  • 3
1

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.

Ken Roy
  • 915
  • 1
  • 10
  • 15
1

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

TheLearner
  • 19,387
  • 35
  • 95
  • 163
1

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

Lior Frenkel
  • 806
  • 11
  • 25
  • 1
    +1 This didn't work for me, but at least I could verify that a release build still worked even if debug didn't. – Ergwun May 01 '12 at 05:24
1

What worked for me:

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

enter image description here

HyLian
  • 4,999
  • 5
  • 33
  • 40
1

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.

Le Tuan Hiep
  • 91
  • 1
  • 3
1

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.

Kevin Nguyen
  • 61
  • 1
  • 4
0

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

BBog
  • 3,630
  • 5
  • 33
  • 64
Rohit Pathak
  • 359
  • 4
  • 16
0

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.

Nir Pengas
  • 990
  • 9
  • 16
0

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.

roberto.buratti
  • 2,487
  • 1
  • 16
  • 10
0

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.

0

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

DoctorG
  • 1,168
  • 7
  • 11
0

Solved here using Xcode 4.3.3 repairing disk permissions.

alexandresoli
  • 918
  • 1
  • 9
  • 18
0

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

Isaac
  • 1,794
  • 4
  • 21
  • 41
0

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.

Big Papoo
  • 167
  • 1
  • 13
0

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

Leo Zhang
  • 3,040
  • 3
  • 24
  • 38
0

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)

Stanislav Pankevich
  • 11,044
  • 8
  • 69
  • 129
0

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

ff10
  • 3,046
  • 1
  • 32
  • 55
0

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.

sprockett
  • 35
  • 5
0

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

Product > Edit Schemes > Run

Change Debugger to GDB

Darshan
  • 750
  • 7
  • 19
0

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.

andreb
  • 596
  • 3
  • 16
0

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.

Topsakal
  • 447
  • 5
  • 11
0

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

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.

gnasher
  • 1,513
  • 12
  • 17
0

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.

LK.
  • 4,499
  • 8
  • 38
  • 48
0

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

Luca
  • 9,259
  • 5
  • 46
  • 59
0

Xcode 12.5 broke iMessage app debugging for me. I can still debug the main app, but when I activate the scheme for the iMessage app Xcode hangs attaching to the app. Downgrading to Xcode 12.4 restored my ability to debug the iMessage app.

0

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

Verify that the Launch Automatically Radio Button is selected.

Echilon
  • 10,064
  • 33
  • 131
  • 217
0

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.

Rimian
  • 36,864
  • 16
  • 117
  • 117
maros
  • 432
  • 3
  • 17
0

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

LondonRon
  • 21
  • 1
  • Didn't work for me. I was able to run another app in the simulator, but when I re-opened the problem project, it continued to have the same problem. – Tyler Collier Nov 03 '11 at 00:10
0

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.

Øystein
  • 1,163
  • 1
  • 12
  • 23
0

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

FishStix
  • 4,994
  • 9
  • 38
  • 53
0

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"

M2tM
  • 4,415
  • 1
  • 34
  • 43