Xcode 9.2 模拟器调试失败;无法附加到进程 ID

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47942776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:29:20  来源:igfitidea点击:

Xcode 9.2 Simulator Debugging Broken; Could not attach to process id

iosxcodeios-simulatorxcode9.2

提问by n8tr

Xcode 9.2 debugging on an iOS Simulator has completely broken for me.

iOS 模拟器上的 Xcode 9.2 调试对我来说已经完全崩溃了。

I worked on this for hours and tried a ton of suggestions short of completely wiping my hard drive and starting out with a fresh operating system install. I ended up filing a bug with Apple. Posting here in case anyone has encountered this problem and has any suggestions.

我为此工作了几个小时并尝试了大量建议,但没有完全擦除我的硬盘驱动器并从全新的操作系统安装开始。我最终向 Apple 提交了一个错误。如果有人遇到此问题并有任何建议,请在此处发布。

Summary:
When try to build and run in debug mode with a debug executable. The simulator only opens the application to a white screen and then Xcode pops up an error:

摘要:
当尝试使用调试可执行文件在调试模式下构建和运行时。模拟器只打开应用程序白屏,然后Xcode弹出错误:

Could not attach to pid: "<a process id>"
Ensure "<app>" is not already running, and "<user>" has permission to debug it.

Steps to Reproduce:
Make any project and try to run on any simulator.

重现步骤:
制作任何项目并尝试在任何模拟器上运行。

Expected Results:
Debugger successfully attaches to debugger.

预期结果:
调试器成功附加到调试器。

Actual Results:
Debugger is never able to attach to the iOS simulator process/app for debugging. Debugger CAN attach and build and run successfully on a physical device.

实际结果:
调试器永远无法附加到 iOS 模拟器进程/应用程序进行调试。调试器可以在物理设备上成功连接和构建并运行。

Version/Build:
- Xcode Version 9.2 (9C40b)
- macOS Sierra 10.12.6
- Any iOS project
- Any iOS simulator

版本/构建:
- Xcode 版本 9.2 (9C40b)
- macOS Sierra 10.12.6
- 任何 iOS 项目
- 任何 iOS 模拟器

Other notes:
- Xcode 9.2 was working fine until this problem randomly started. The error initially said:

其他注意事项:
- Xcode 9.2 工作正常,直到此问题随机出现。错误最初说:

 Failed to initiate service connection to simulator
 DTServiceHubClient failed to bless service hub for 
 simulator iPhone 8 Plus <simulator identifier>

- After rebooting computer, the error shifted to "Could not attached to pid..."

- 重新启动计算机后,错误变为“无法连接到 pid...”

I tried dozens of suggested solutions short of completely wiping my computer including:

我尝试了数十种建议的解决方案,但都没有完全擦除我的计算机,包括:

  • Resetting device contents and settings on simulators
  • Create a new device (even different device and OS combinations)
  • Try different Xcode projects, even simple one-off single view applications
  • Looking at the etc/hosts file and verifying localhost can be pinged
  • Restarting computer multiple times
  • Deleting out derived data (multiple times)
  • Let it build and run without attaching debugger, then try to attach debugger by "attach to process id"
  • Completely uninstalling Xcode and all simulators, and reinstalling.
  • Removing any invalid certificates in keychain
  • 在模拟器上重置设备内容和设置
  • 创建新设备(甚至不同的设备和操作系统组合)
  • 尝试不同的 Xcode 项目,甚至是简单的一次性单视图应用程序
  • 查看etc/hosts文件,验证localhost可以ping通
  • 多次重启电脑
  • 删除派生数据(多次)
  • 让它在不附加调试器的情况下构建和运行,然后尝试通过“附加到进程 ID”来附加调试器
  • 完全卸载 Xcode 和所有模拟器,然后重新安装。
  • 删除钥匙串中的任何无效证书

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

回答by n8tr

It turns out our security softwarewas blocking the debugger. Running sudo sysdiagnosehelped me find a log entry showing that it was being blocked. The software is Cb Defense(Carbon Black Defense). Apparently the only workaround is for your security team to whitelist by a hash, and that hash could change in the future.

事实证明,我们的安全软件阻止了调试器。运行sudo sysdiagnose帮助我找到了一个显示它被阻止的日志条目。软件是Cb Defense(碳黑防御)。显然,唯一的解决方法是让您的安全团队通过散列将其列入白名单,并且该散列将来可能会发生变化。

回答by russbishop

There is a bug in Xcode 9.0-9.2 that causes this issue to appear after running for a while. If you log out and back in it should resolve it for you.

Xcode 9.0-9.2 有一个bug,运行一段时间后会出现这个问题。如果您注销并重新登录,它应该会为您解决。