可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
when i compile my app, Xcode just says "Attaching to Projectname..." and gets stuck there.
The debugger just prints this out:
error: failed to attach to process ID 0
I tried to clean & build again and it still doesn't work out. I googled but couldn't find anything helpful.
How can I fix this problem? Thank You!
回答1:
The solution for me was to delete everything Xcode has generated earlier:
- the App on the Simulator...if this is not possible because you cant
reach the Homescreen, you can delete the App directly under
~/Library/Application Support/iPhoneSimulator/6.0/Applications
- delete the Derived Data in the Organizer under Projects or directly
in
~/Library/Developer/Xcode/DerivedData
- clean the Build Folder by choosing "Product" in the MenuBar and click
while you press the Alt-key on "Clean Build Folder"
- Restart Xcode
回答2:
Have you tried closing down the simulator entirely, or failing that, reset the simulator and all its contents usually does the trick.
回答3:
What finally got the simulator working again for me was deleting everything under Library/Application Support/iPhone Simulator/
within the user directory. What I think caused the problem for me in the first place was trying to use a directory named 'Resources' as described here: https://stackoverflow.com/a/1265168/649
回答4:
This happened to me when I had two xcode projects open with the same bundle identifier.
Solution: leave only one project open which has the same bundle id.
回答5:
Lindemann's solution worked for me. Nonetheless, during further development I came across another situation that generates this problem: if you create a folder reference (blue folder on Xcode's file explorer, as opposed to the yellow ones which are just groups) called "Resources" the same issue will arise. The solution in this case is to simply rename that folder.
After this, follow Lindemann's solution.
回答6:
I had similar issues when i installed XCode 4.5 on OS X Mountain Lion. I searched a while and tried some fixes but what finally solved the problem was adding "127.0.0.1 localhost" to my hosts file (/etc/hosts).
Here is what i have done:
Open a terminal shell with cmd+space > terminal
type in "cd /etc"
type in "sudo nano hosts"
type in your root password
add "127.0.0.1 localhost"
save with ctrl+o > return
close with ctrl+x
log out and log in again or restart
回答7:
Ctrl-Shift-Option-K (same as holding down option and selecting Product ... Clean Build Folder) has always worked for me.
回答8:
What seemed to work for me was build & run my code so that it opened the Simulator, then hold down on the Simulator Icon in the Dock and select Options -> Keep In Dock
After this I just closed the simulator and launched it from the dock and deleted the app from the home screen on the simulator.
Build & Run the app from XCode and everything seemed to be OK again.
回答9:
There seems to be quite a lot of things that can cause this error, but for me it turned out to be that I was missing the key CFBundleIdentifier
from my plist.
Added it back, and the simulator started normally.
回答10:
Also make sure none of your file/group name collide with the projects default settings.
Things started breaking for me when I added an info.plist file to my project (Bad Idea). Same happens when you add a "Resource" Group. I don't have an exhaustive list, but if someone does please do share.
Cleaning out / Renaming these conflicting files and following the solution provided by Lindemann(https://stackoverflow.com/a/12504712/2069749) solved the problem for me.
回答11:
What worked for me was that I realized i was messing with the project settings and accidently removed the info-plist section. After specifying the plist file again properly, it worked. Hope that helps someone.
回答12:
You need to change the debbugger LLDB to GDB. This helped me start my program in the simulator.
回答13:
If you are using a network account, you should replace the "~/Library/Application Support/iPhone Simulator
" with a link to a local directory. This worked for me after trying everything else.
回答14:
Make sure you do not have an invalid build rule, that will cause this error, happened to me once (I had added a build rule by mistake and left it invalid).
回答15:
I had the same problem, in my case i have left the ios simulator open in one user account and switched (without logout the previous one) to another user account. I couldn't event able to open ios simulator to clear and reset its settings. [Shows could no open ios simulator OSStatus - 10829]
My solution:
I quit the simulator in the first user account and then came back to second user account, every thing is working fine.
回答16:
try to do next steps:
- Go to Product/Scheme/Edit Scheme then select Run section.
- Select Info Tan and set Debugger None.
- Run project. It must be working (without debugger)
- Go back to Edit Scheme and selecet debugger LLDB
- Run project. It is working.
Maybe additionally you need to delete derived data and do Product/Clean
回答17:
Can't tell you how frustrated I am trying to narrow down the cause of this one. Took me hours. Trial and error here and there.. all leads to nothing until one comment in one of the threads relating to this mentioned about "Executable". Boom! I remember the plist key "Executable file" in my project plist (PROJECT-info.plist). So I got there and found out that that entry was missing. I filled it in with whatever default you see when creating new project, "Executable file" paired with "${EXECUTABLE_NAME}". Build + Run. Then it finally worked!
Btw, I did try all those deleting/resetting stuff found all over SO. None of them works.
回答18:
If resetting content and settings in the Simulator doe snot work for you, make sure that there is an entry for localhost in your /etc/hosts file:
127.0.0.1 localhost
Some programs can delete the line or comment it out (#) or even delete your /etc/hosts/ file completely. I tried everything described, but once I added localhost back to the file, the simulator worked perfectly for me.
回答19:
What worked for me was to select 'Delete Derived Data' from the Projects tab in the organiser.
回答20:
I fixed my problem by I making a new blank project and importing all the old files.
It must have been a problem with Xcode because it worked before iOS 5.1.