2 Replies
      Latest reply on Jul 15, 2019 12:42 PM by eskimo
      joostn Level 1 Level 1 (0 points)



        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.

        • Re: Debugging fails with "Error 1" if hardened runtime is enabled
          philknock Level 1 Level 1 (0 points)

          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.


          • Re: Debugging fails with "Error 1" if hardened runtime is enabled
            eskimo Apple Staff Apple Staff (11,485 points)

            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:

            $ 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"