I encountered this error too running XCode 10.2.1 on macOS 10.14.5.
In my case, this didn't have to do with Hardened Runtime, but rather my "Debug Process As" setting.
I had to edit my scheme settings, and instead of debugging the process as me, I had to debug process as root. Not sure why this works, but hope it's helpful.
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
.entitlementsfile, but directly to the app. Use this command to see it:
$ 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.
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"