Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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.

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:

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.

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

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

 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..."

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

enter image description here

enter image description here

like image 378
n8tr Avatar asked Dec 22 '17 14:12

n8tr


Video Answer


2 Answers

It turns out our security software was blocking the debugger. Running sudo sysdiagnose helped 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.

like image 168
n8tr Avatar answered Nov 08 '22 18:11

n8tr


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.

like image 26
russbishop Avatar answered Nov 08 '22 18:11

russbishop