6

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

Tyler Wall
  • 3,747
  • 7
  • 37
  • 52
Johan de Klerk
  • 2,515
  • 3
  • 25
  • 35

7 Answers7

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.

Community
  • 1
  • 1
Bartserk
  • 675
  • 6
  • 18
  • God damnit, you deserve being higher. The Debugger attaches through network, and it looked for the simulator on localhost, not 127.0.0.1. – Can Jun 03 '13 at 20:44
1

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.

  • 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 like 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.037 ms instead of ping: cannot resolve localhost: Unknown host error.
  • Restart your Xcode and simulator.
liuyaodong
  • 2,547
  • 18
  • 31
0

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.

Echilon
  • 10,064
  • 33
  • 131
  • 217
  • I tried this, but it happens every day, so I think it must be something I have wrong in my settings – Johan de Klerk Jun 06 '12 at 11:57
  • I guess by "every day" you mean "every single time" which unlike the former is not normal. – Jano Jun 06 '12 at 13:59
  • 2
    I have the exact same problem - Compiler is set to LLVM, debugger is set to LLDB but it gets stuck at the attaching step. Works perfectly using GDB though. – Salman Nov 03 '12 at 02:53
0

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

epsilonpsi
  • 3,753
  • 3
  • 17
  • 16
0

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

0

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,

MK_iOS
  • 388
  • 5
  • 13
0

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