Cannot perform debug

As I am writing, my 10th try to debug a plug-in was unsuccessful following the latest Xcode update. I cannot make the main app to launch for debugging and nothing I do changes the situation. This is the message I get so any help would great:

Could not attach to pid : “2121”

Domain: IDEDebugSessionErrorDomain

Code: 3

Failure Reason: Error 1

Error 1

Domain: IDEDebugSessionErrorDomain

Code: 3

3 Likes

Hi @Rob,

Let’s try a basic test:

  1. Run the host app from the Finder.

  2. In Xcode, create a new test project from the macOS > Bundle template.

  3. Choose Debug > Attach to Process > HostAppName .

After performing above steps, Please share the result so that we can help you better.

Thanks

Hi @Rob,

I recommend that you create a new test project and try things there. If that works, you know that Xcode is behaving itself in general, and that the problem you’re seeing is tied to your main project. At that point you can start comparing your main project to your test project to see what’s different.

Let me know if this worked out. :slightly_smiling_face:

Hi,

Try to disable system integrity protection as mentioned below and check if its work after.

Configuring System Integrity Protection

Security configuration is stored in NVRAM rather than in the file system itself. As a result, this configuration applies to all installations of macOS across the entire machine and persists across macOS installations that support System Integrity Protection.

Note: To safeguard against disabling System Integrity Protection by modifying security configuration from another OS, the startup disk can no longer be set programmatically, such as by invoking the bless(8) command.

System Integrity Protection can be configured using the csrutil(1) command.

You can check whether System Integrity Protection is currently enabled on your system by running the following command in the Terminal:

$ csrutil status
System Integrity Protection status: enabled.

To enable or disable System Integrity Protection, you must boot to Recovery OS and run the csrutil(1) command from the Terminal.

  1. Boot to Recovery OS by restarting your machine and holding down the Command and R keys at startup.
  2. Launch Terminal from the Utilities menu.
  3. Enter the following command: $ csrutil enable

After enabling or disabling System Integrity Protection on a machine, a reboot is required.

1 Like

Hello
I saw this problem too, with a simple command-line C++ tool. My project(s) have “Automatically manage signing” checked, and I verified CODE_SIGN_INJECT_BASE_ENTITLEMENTS was Yes for Debug and Release. I’m on Xcode 10.3, Mac OS 10.14.6.

Debugging the tool worked fine on the machine where I created the project (same Xcode/OSX versions), but checking the project out of git on a different machine, this problem occurred - I hit run but it never hits the entry point of main and the same error is reported (but oddly it hides the console & you have to open it to see it). Like the poster above, running as root works around the issue, but for many reasons I do not want to do that.

Messing with my signing certificate ended up fixing the problem. In Keychain access I noticed my Mac OS Developer certificate was in System Roots but not in login. I dragged it into login. Then in the Xcode project Info settings (showing signing setup), there was an error message saying I needed to remove the current signing certificate in order to pick up the correct one. I clicked okay and the warning went away. Now, for some reason, there are two different copies of my Mac Developer signing certificate in keychain - same ID#, one dated a month ago, another dated today.

The good news is, it seems to be fixed, though there seems to be something a little off with the “Automatically manage signing” setting and keychain’s management of certificates - either that or I did something wrong while setting it up (with a different project).

1 Like

This problem is most likely related to entitlements. In general, the hardened runtime prevents the debugger from attaching to your process. When you do a Product > Run, Xcode adds an entitlement to your app ( com.apple.security.get-task-allow ) that allows the debugger to attach. In other situations — for example, when you do a Product > Archive — that’s not the case.

IMPORTANT This entitlement isn’t added to your .entitlements file, but directly to the app. Use this command to see it:

  1. $ codesign -d --entitlements :- /path/to/your.app

It sounds like Xcode isn’t adding this entitlement for you. One possibility is that you’ve disabled the Code Signing Inject Base Entitlements ( CODE_SIGN_INJECT_BASE_ENTITLEMENTS ) build setting.

1 Like