error: failed to attach to process ID 0

江枫思渺然 提交于 2019-11-27 11:45:02
juan

I've met the same problem

1.you can delete the App directy under

~/Library/Application Support/iPhone Simulator/6.0/Applications

and

~/Library/Developer/Xcode/DerivedData

2.then you can start Xcode ; in the menubar you can find Project -> Clean

EDIT: before copy/pasting 1 above change the Simulator Version to what you are using!

Go to IOS Simulator tool bar and click Reset Content and Settings...

Click on Simulator and reset the simulator by going to the “iOS Simulator” main menu and choose “Reset Content and Settings…

Back in XCode, choose the menu "Product" > "Edit Scheme". On the left menu panel, click on "Run _Your_Project_Name_.app" > "Run _Your_Project_Name.app". The info display on the right should have the "Debug Process As" radio button picked as "Me (your-user-name)". If not, make sure you do not login as root. On Stackoverflow there are many reports of running as root will have problems

Next, still in Xcode, go to the menu "Window" > "Organizer". On the top menu, click on "Projects". Go ahead and delete "Derived Data".

Finally, go to "~/Library/Application Support/iPhone Simulator/6.0/Applications" and delete everything that’s in there

Finally, I found out the problem was I had a folder called "resources" that I used to store all my images. When I changed the name of the folder to something less likely to be used by XCode somewhere else, I did the whole delete derived data/clean/restart XCode and it worked!

Nothing from mentioned above helped me. But as I found that few moments before, I (or some other entity) had somehow removed records from my /etc/hosts file and I got the same error.

You should check whether you have in your /etc/hosts file the line "127.0.0.1 localhost". As this line is missing, the LLDB debugger is generating issues.

So just add 127.0.0.1 if you have it missing in your /etc/hosts.

This helped me!

Delete the app on the iOS simulator. It works for me.

Reset Simulator and quit simulator then Rebuild-Run.Its works for me

Cleaning (either deleting folders, or Product->Clean) did not worked.

I saw that in my .plist the bundle id had been removed. Thanks to git. I checkouted-- the file, and bam! deployed to simulator no problem.

Just sharing...

Sometimes this problem arises from having two targets in a project, both using the same bundle identifier but building products with distinct names.

Deleting the application on the device/simulator solves the problem, as it has been said earlier.

This happend to me after changing the Product name.

After resetting the simulator, cleaning the project, and restarting XCode, nothing worked. After shutting down and restarting the simulator everything worked as expected.

user1837979

I guess there exists someone who is in case the matter happens only in a project, not in every project and failed to resolve the matter after doing a lot of solutions posted on this Question page, such as 'deleting the App directy under ~/Library/Application Support/iPhone Simulator/6.0/Applications and ~/Library/Developer/Xcode/DerivedData', 'Cleaning all the logs by doing Project -> Clean' and 'Cleaning all the log and contents in the iOS Simulator Menu' and anything else.

Yes, I also finally failed to resolve that.

For you, It might be a solution if you are in the problem I mentioned above: Create a new project with a similar name, and copy and paste all of your classes and resourse files existing in your previous project folder to the new one and link the references between your new project and the copied files in Xcode. Then, clean the build logs by pressing 'Shift + Command + K'.

In my case, this made me able to continue my work...

My App didn't have a proper BundleID after deleting some xcconfig files.

I had the same problem and I found that you can't be using the root account on your Mac. If you are logged in as root you are not able to attach process to the Simulator. You have to be logged in as a different account.

Every time I have this issue (that is quite often actualy), I uninstall the app from the simulator (like a user would on the device) and do a clean on XCode. Next build and run works.

I can also reset the simulator content and settings to make it work but this seems like using a bazooka to kill a fly.

This also happens if you prepare your file for enterprise distribution and end up saving the resulting .ipa and .plist in the project directory, thus overwriting your project plist. When that happens you'll know because the version information and main window in your project configuration will be blanked. If this happens restore your old plist from source control... and save your product files elsewhere !

This happens when you switch between versions of xcode. Simple solution is to quit xcode and simulator. Relaunch xcode and at the same time clean the simulator befor running. This should solve the problem.

I had this problem because I had another user on the same machine running the iOS simulator. Logging in as the other user and quitting the simulator (and Xcode) solved it in my case.

Step1: ping

$ ping localhost

This should return something like

PING localhost (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.028 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.048 ms ...

If this works, this answer won't fix your problem, try something else.

If ping return something else for example: ping: cannot resolve localhost: Unknown host something is screwed up with your /etc/hosts file, go to Step 2 Step2: Check /etc/hosts

Check that the top of your /etc/hosts file looks like this

127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost

If it doesn't have these entries in the file, enter them at the top of the file, flush the dns cache using $ dscacheutil -flushcache and go back to Step 1, otherwise continue to Step 3. Step3: Correct File Format: It should be unix or LF *

$ file /etc/hosts

This should return: /etc/hosts: ASCII English text

If it returns something like /etc/hosts: ASCII English text, with CR line terminators then the file is in the wrong format and is likely being ignored.

Change the file line endings to unix or LF using your favorite text editor.

In Sublime Text 2 this can be done throught the view menue: View > Line Endings > Unix

Flush the dns cache ($ dscacheutil -flushcache) and go back to step 1

Embarrassing late-night moment, but just for completeness... when you click "reset content and settings" on the emulator, of course the big blue default button says "DON'T reset", and the little white other button says "reset". If you're not paying attention it can be quite difficult to remember to read the buttons. I can't believe I'm admitting this but hey, happens to us all (right? :))

I restart the simulator and it worked for me

guru

Some times it happens because you have two projects with same name. Try this:

  1. go to xCode preference choose location and click on DerivedData delete the DerivedData
  2. Reset and force Quit Simulator
  3. Force Quit The Xcode and restart

If it has not worked than restart your PC.

and another one for the record: (none of the suggestions worked for me)

Mountain Lion: XCode 4.6.3

  • I moved the whole Application to Trash and deleted following other folders
  • /Users/[USERNAME]/Library/Developer
  • /Users/[USERNAME]/Library/Caches/com.apple.dt.XCode
  • /Users/[USERNAME]/Library/Application Support/iPhone Simulator

  • reboot System and reinstall XCode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!