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

  • Also happens on a brand new M1 Max with the latest stable OS (12.12.1) and XCode (13.2.1) when creating a completely new Watch App.

  • happening for m1 pro and debugging a desktop app with xcode 12.3. I have tried all solutions mentioned in this thread but to no avail. I am able to to atttach it after edit Scheme -> Run -> Debug executable but i have the need to debug the app. any suggestions are welcome.

Add a Comment

Accepted Reply

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


sudo DevToolsSecurity -enable

Add a Comment

Replies

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).
Add a Comment
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.

  • I'm also running Monterey beta and can confirm that this worked for me as well.

  • Hey Bro, Will you tell me how to remove macOS 12 Beta ?? Even though I did my Mac Format, I have come back to Macos 12 beta. please give me solution

  • Same specs MacOS 12.0 Monterrey and Xcode 12.5.1 from Appstore and the same thing worked.. by disabling Debug executable.. BUT.. this prevents debugging which is quite essential for a developer right?

    Although when I use the newest beta, Xcode 13, currently on the 4th iteration.. it works no problem, really weird..

    I have deleted my app, deleted everything Xcode related, deleted every simulator, followed the advice in the popular post on stackoverflow

    Nothing. I think the issue will be resolved once I get off of beta.. I hope.. also the last beta I install.

Add a Comment

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

Add a Comment

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.