Debugging fails with "Error 1" if hardened runtime is enabled

Hi,


I'm unable to debug my mac application under XCode when Hardened Runtime is enabled. I'm getting 'Message from debugger: Error 1'.


lldb -p <pid> gives the same error:

error: attach failed: Error 1


Disabling hardened runtime solves the problem, but I'm wondering if there's a way to debug with the hardened runtime enabled, and why I'm getting such a cryptic error message.


Using XCode 10.2.1 on macOS 10.14.5.

Replies

"Sometimes" I have similar issue in the a C++ project by Xcode 10.2, MacOS 10.15.6. When I modify Build Settings\User-definded\Ver, and build, Console just shows Message from debugger: Error 1. This project is controlled by GitDesktop, and today I cloned it by SourceTree to another folder and tried to modify Ver, and it works once. Then I pushed it and fetched from GitDesktop, and it shows error again...Then I modified SourceTree Ver, it became showing error 1.

Temporary solution is don't modify ver in Xcode, but edit it in App Info.plist.


This started to happen on one machine, MacPro 10.14.6 XCode 11, the same project on a USB drive works on another MacPro (at the vacation cottage, so far away) same OS version and same XCode version. Even happens with a brand new project. I tried to remove all prefs deleted all derived data, still no luck, even with a new simple project.

What more to remove? This is really annoying now.
OK, seems to have to do with signing (as Quinn mentioned). Has to set signing to Manual and Developer ID Application, then it worked to debug the application, with Hardened Runtime active. I know my account was renewed recently and it might have to do with that. The Apple Development cert is downloaded in XCode as "Untitled" and not with the hostname as key.

I've had related problems to this, in my case it was because I was using an old version of macOS and Xcode, that didn't have the newer Apple Worldwide Developer Relations certificate installed.

You can install it yourself by downloading it from https://www.apple.com/certificateauthority/.