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.