Xcode fails to attach to process when building to the Simulator

When trying to build and run our iOS app on the simulator we're hitting the following error:

Could not attach to pid: "XXXXX"

failed to get reply to handshake packet within timeout of 6.0 seconds

I've included some more details on our project/setup below:

  • We're working on a large project with multiple schemes / app targets.
  • The error only affects one of our targets - however the dependencies between the problematic target and the others are very similar.
  • The issue only affects building to the simulator; building to a physical device works fine.
  • Scheme configuration is the same across all targets.
  • We've faced this issue on multiple versions of Xcode, from 15.x through to the latest 16.3 RC.

We've tried a number of workarounds, some of which work intermittently for some colleagues - but none of which have provided a durable solution. These include varying combinations of:

  • Setting the IDEPreferLogStreaming=YES environment variable
  • Unchecking Debug Executable under Edit Scheme -> Run
  • Manually launching the app on the Simulator and then attaching the debugger using Debug -> Attach in Xcode
  • Erasing all contents and settings on the simulator (this sometimes fixes things for a single build, but we run into the same issue again for all subsequent builds, and it doesn't work for all developers).
  • Clearing out Derived Data and running a clean build (this doesn't seem to help).

We'd really appreciate any input on how we can diagnose what's causing this issue or any suggested steps to help resolve it.

Out of curiosity, do your systems have any Endpoint Security software installed? Such products sometimes affect performance in scenarios like this, and it would be interesting to know if such software were removed and the problem resolves itself.

Beyond that, it would be helpful to get more information from you in a bug report for us to look into. With that report, please attach a sysdiagnose from your Mac, and another from the simulator (by running xcrun simctl diagnose in Terminal). Once that's filed, please post the FB number here.

— Ed Ford,  DTS Engineer

Hi Ed, thanks very much for the response! We do have a couple of endpoint security applications installed - specifically BeyondTrust and Zscaler. Do you happen to know if either of those has caused similar issues in the past?

I’ve also created a feedback with a sysdiagnose and a screen recording showing the issue - FB17054509.

I can't comment on specific vendors, but we have seen the Endpoint Security product category introduce notable performance constraints on Xcode and the Simulator. Regardless of the history of any one vendor's influence on those performance impacts in the past, the nature of Endpoint Security software — where it sits in the system very low in the stack and the event processing it does to achieve its goal, and how all of that might intersect a debugger attaching to a process — means that its always a good place to start with a question like yours.

I appreciate you filing FB17054509 for us to investigate. Are you able to do your own verification here to rule out if those pieces of software have a bering on what you're seeing in your environment? Knowing that will focus what can happen from here, both in terms of actions you can take within your environment, and how our investigation into FB17054509 proceeds. Perhaps the issue here isn't related at all to Endpoint Security, and ruling it out of your environment will help clarify that.

— Ed Ford,  DTS Engineer

Thank you! We're working with our corporate IT team to try and run some tests without the endpoint security software installed, so we'll get back to you if we're able to confirm either way whether this was the cause.

Xcode fails to attach to process when building to the Simulator
 
 
Q