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:
Fixed it!! Hopefully this helps some people avoid a very frustrating couple hours. I solved this by:
Hope this helps!
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.
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.
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!
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.
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 :)
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
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.
After all said and done. I had to stop the simulator. Then the message change to downloading Mac OS X 10.6 core library.
What worked for me is the following:
Then clean and run.
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.
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 :)
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!
Here was our fix:
In Project > Edit Schemes > Run.
Change the Debugger from
None (directly above the green circle in the image above).
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.
I noticed it happened to me when I edited the scheme from Build Release to Build Debug. I changed back, and it worked :)
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.
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.
In Xcode navigate to the Product menu and choose EDIT SCHEMES.
Verify that the
Launch Automatically Radio Button is selected.
Restarting simulator works for me :)
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 =)
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.
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.
What worked for me:
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:
changing it back to this:
will stop Xcode from hanging and allow the App to run.
"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 :)
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.
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.
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.
I really find the answer for me :)
project setting -> your target -> build phases -> validate setting -> perform
and now the problem is gone.
I hope someone it help
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.
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
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.
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.
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....
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"
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
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.
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.
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.
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
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:
I had to change these to match my product name. I then reset the simulator and it worked.
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...
Solved here using Xcode 4.3.3 repairing disk permissions.
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!!)
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.
This is a bug of XCode 4.4.0 After I updated XCode to 4.4.1, this problem went away.
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)
Under Product > Edit Scheme > Run > Info, changed the Debugger from LLDB to GDB worked perfect for me!
Xcode failed to attach while the Network Link Conditioner was active. Try to activate it after the attaching has been done.
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 :)
Just came across the same problem: restarting the simulator and Xcode didn't work for me, while restarting my mac worked out pretty well!
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.
In Xcode 4.6. Just Change Debugger from LLDB to GDB in Edit Scheme.
Product > Edit Schemes > Run
Change Debugger to GDB
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.
Xcode 4.6.3 update (June 13, 2013) resolves the following issue:
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.
The best option would be
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
This really solves your problem!