6

当我在模拟器中运行应用程序时,Xcode 会挂在 Attaching to (App name) 上,但这仅在调试器设置为 LLDB 时才会发生。当调试器设置为 GDB(产品-> 编辑方案 -> 运行 -> 调试器)时,应用程序运行良好我如何解决这个问题以使用 LLDB 进行调试,而 Xcode 不会挂在附加到(应用程序名称)?

4

7 回答 7

2

我有同样的问题,并按照这些说明解决了为什么 LLDB 调试器总是无法附加?我刚刚在 /etc/hosts 中添加了一个条目,将 localhost 翻译为 127.0.0.1 并且效果很好。

于 2013-03-22T15:10:18.207 回答
1

我发现当调试器设置为 LLDB 时,Xcode 需要访问 localhost。因此,当您的主机文件未正确配置时,您将始终收到“无法附加到进程 ID xxxx”错误。这是诀窍:

  • 试试$sudo file /etc/hosts。如果输出为/etc/hosts: ASCII English text, with CRLF line terminators,则需要将其文件格式更改为 UNIX 格式。有很多方法可以实现这一目标。我的偏好是:

    • 通过打开主机文件$sudo vim /etc/hosts
    • :set ff=unix输入 vim 命令行模式并通过键入并返回来更改文件格式。
    • 确保您的主机文件包含这样的行:127.0.0.1 localhost
    • :wq输入并返回保存并退出。

    现在再试$sudo file /etc/hosts一次,你会得到/etc/hosts: ASCII English text.

  • 更改 hosts 文件的权限。$sudo chmod 644 /etc/hosts
  • 完成上述所有操作后,尝试这样做,您会得到类似而不是错误的$ping localhost响应。64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.037 msping: cannot resolve localhost: Unknown host
  • 重新启动您的 Xcode 和模拟器。
于 2013-08-01T04:19:55.730 回答
0

这是一个非常简单的步骤......对我来说这是一个大问题,因为我每次都被困在“附加到 myApp”中,而且 Xcode 也会变得无响应。

在菜单栏中的产品下,转到方案并单击“编辑方案”。将打开一个框,并在信息选项卡下将每个项目的“调试器”从 LLDB 更改为GDB。每次都为我工作!希望这个答案可以结束每个人对这个问题的问题

于 2013-06-28T19:27:17.487 回答
0

打开终端并输入以下命令。

 sudo nano /private/etc/hosts 

按回车。然后它会询问你的mac密码。输入密码后。

GNU nano 2.0.6 文件:/private/etc/hosts

## # Host Database # # localhost 用于在系统启动时配置环回接口#。不要更改此条目。##

127.0.0.1 本地主机

255.255.255.255 广播主机

::1 本地主机

fe80::1%lo0 本地主机

完成更改后,按 Control-X 退出编辑器,按 Y 保存,

于 2014-09-08T11:01:32.220 回答
0

我发现这种情况时有发生,但通常重新启动模拟器或设备,重新启动 XCode 并清理您的派生数据目录就可以了。

于 2012-06-06T10:37:38.550 回答
0

Xcode 4.5.x 为我破坏了 lldb(所以改用 gdb)和 git(改用 SourceTree),当升级到 XCode 4.6.2 时它们神奇地解决了

于 2013-05-21T23:35:20.977 回答
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

于 2015-11-19T09:21:41.200 回答