问题
When I run a app in the simulator the Xcode hangs on Attaching to (App name), but this only happens when the debugger is set to LLDB. The app runs fine when the debugger is set to GDB (Product->Edit Scheme -> Run -> Debugger) How can I fix this to debug with LLDB without the Xcode hanging at Attaching to (App name)?
回答1:
I've found this happens from time to time, but generally restarting either the simulator or the device, restarting XCode and cleaning your derived data directory does the trick.
回答2:
I had the same issue, and solved it following these instructions Why does the LLDB Debugger constantly fail to attach? I just added an entry to /etc/hosts translating localhost as 127.0.0.1 and it worked fine.
回答3:
I found that the Xcode needs to access localhost when the debugger is set to LLDB. So you will always get "failed to attach to process ID xxxx" error when your hosts file is not properly configured. Here is the trick:
Try
$sudo file /etc/hosts
. If the output is/etc/hosts: ASCII English text, with CRLF line terminators
, you need to change its file format to UNIX format. There are many ways to achieve this. My preference is:- Open hosts file via
$sudo vim /etc/hosts
. - Enter vim command line mode and change file format by typing
:set ff=unix
and return. - Ensure that your hosts file includes a line like this:
127.0.0.1 localhost
- Save and quit by typing
:wq
and return.
Now try
$sudo file /etc/hosts
again, you will get/etc/hosts: ASCII English text
.- Open hosts file via
- Change the permission of the hosts file.
$sudo chmod 644 /etc/hosts
- After you have done all of the above, try to
$ping localhost
and you would get response like64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.037 ms
instead ofping: cannot resolve localhost: Unknown host
error. - Restart your Xcode and simulator.
回答4:
Xcode 4.5.x scuppered lldb(so used gdb instead) and git(used SourceTree instead) for me, and they were magically resolved when upgraded to XCode 4.6.2
回答5:
Its a very simple step...For me it was a big problem as i was stuck in "attaching to myApp" every time and Xcode would also become unresponsive.
Under Product in the Menu bar, goto schemes and click on "edit schemes". A box will open and under the info tab change "debugger" from LLDB to GDB for every project. Works everytime for me! Hope this answer brings an end to everyone's problem with this issue
回答6:
open your Terminal and type the following command.
sudo nano /private/etc/hosts
press enter. then it will ask your mac password. Once you enter your password.
GNU nano 2.0.6 File: /private/etc/hosts
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
When you’re done making changes, press Control-X to exit the editor, Y to save,
回答7:
Updating to latest OS available resolves the issue. In my case I was using Yosemite 10.10.5 and I updated it to El Capitan 10.11.1. Then I launched Xcode 7.0.1, additional components got installed for xcode and the issue got resolved.
I believe the additional components for xcode were missing. Or may be force update of OS was required for Xcode and Simulator to work properly
来源:https://stackoverflow.com/questions/10911117/xcode-4-hangs-on-attaching-to-app-name-when-debugger-is-set-to-lldb