Xcode: Could not attach to pid

Every single time I try to launch the simulator I get this:


Cold not attach to pid : "12345"

Domain: IDEDebugSessionErrorDomain

Code: 3

Failure Reason: Error 1

--

Error 1

Domain: IDEDebugSessionErrorDomain

Code: 3

--


I'd REALLY like to be able to debug. Can anyone offer some help?


On google, I found suggestions to build it again, to restart xcode, to restart Xcode and rebuild, to reboot the computer, to set to release instead of debug. NONE of thelse things helped in any way. 😟


-Verxion

Answered by Hunter in 373436022

It's an issue with authorization. Try this in the Terminal:


sudo DevToolsSecurity -enable

Hitting the same thing. Newly wiped machine, installed fresh macOS 11.1 & Xcode 12.3, enabled developer mode from the command line as per one of the responses here. App for macOS builds fine but debug fails with:

Could not attach to pid : “3034”

Domain: IDEDebugSessionErrorDomain

Code: 3

Failure Reason: attach failed (Not allowed to attach to process.  Look in the console messages (Console.app), near the debugserver entries when the attached failed.  The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)

User Info: {

    DVTRadarComponentKey = 855031;

    RawLLDBErrorMessage = "attach failed (Not allowed to attach to process.  Look in the console messages (Console.app), near the debugserver entries when the attached failed.  The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)";

}

In the system log I'm seeing some logging around DTServiceHub but there are no clearly-related error messages in the log.
My fix: go to settings>general>device management. Make sure that you trust the developer by clicking "trust".
Thanks tangqiyang008! 
still have the problem

Developer mode is already enabled in terminal.
Mac and iPhone after reboot.

but still
Domain: IDEDebugSessionErrorDomain
I only have the issue when debugging @IBDesignable views from IB. It just doesn't work (and hasn't for a long time), and fails with this error.

Debugging the app in the simulator works fine for me.
CODE_SIGN_INJECT_BASE_ENTITLEMENTS set to YES and everything began to work
Hi,
I'm having this issue when running XCUITest but just on MBP M1 (still with all suggested solutions here) . Does anyone have similar problem, and is there some solution for this. Thanks
I resolved my on issue by unchecking the "Open using Rosetta" in Xcode Info (Applications>Xcode CMD+I).
I had the exact same error as darrylfromredwoodcity above, nothing in the thread seemed to fix it.

Check your system.log, it turned out security software on my macbook pro was blocking the debugserver from attaching to the simulator. It was also blocking dtarbiter from reading DTServiceHub, which prevented my Xcode from running SwiftUI previews.

I had to contact my IT team in charge of this security software to get this fixed. This might be worth checking if you have this issue and nothing else works.

Here is a very similar issue on an older version of Xcode that was posted on Stack Overflow, where the top answer mentions security software that was blocking processes:

https://stackoverflow.com/questions/47942776/xcode-9-2-simulator-debugging-broken-could-not-attach-to-process-id

Hope this helps!

FWIW, I have yet another solution... I used Console.app -> system.log; Clear; launch and attach and noticed I got this line:


May 14 14:35:26 my-mac Photos[30591]: objc[30591]: Class _NSZombie_NSPathStore2 is implemented in both ?? (0x7ff33ec26e30) and ?? (0x7ff34ed330f0). One of the two will be used. Which one is undefined.

This stack overflow solution did the trick:

NSZombies is turned on. Go to product -> scheme -> edit scheme (CMD+SHIFT+.) and under run -> diagnostics uncheck "Enable Zombies".

I am using MacOS 12.0 beta and Xcode 12.5.1 from App Store and have same problem. Edit Scheme -> Run -> unchecking Debug excitable worked for me.

Just like @mitas95, I'm also having the same issue on an M1 Mac. The only thing that worked for me was Product>Scheme>Edit Scheme>Run>[ ] Debug Executable, which is unideal.

Deleting DerivedData, closing and reopening Xcode did the trick for me on Xcode 12.5.1

I have fixed this by fixing certifications. the project was manually set with provisioning profiles and maybe the wrong development account. I solved it be deleting all hard coded provisioning profiles and making all signing auto, and then select the suitable developer account.

I hope this helps!

Muhamad Akoum aka. Ancient Prayers ancientprayers.com

For me this scenario happened after a merge. The Solution was to remove an environment variable in Edit Scheme-> Run-> Arguments. I removed the environment variable and then added it again. That solved the issue.

Xcode: Could not attach to pid
 
 
Q