3

i had to reinstall my MacBook Pro. I have installed the newest macOS & Xcode version so

macOS Monterey 12.0.1 (21A559) and Version 13.1 (13A1030d)

I'm programming Audio plugins so to test my plugins I'm normally running a DAW (Digital Audio Workstation) in my case I'm working the most of the time with Ableton or Bitwig.

So if I start the debuging process, I get the follow error: Could not attach to pid XXXXXX attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries, when the attach failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)

If I have an eye to the console.app the the following lines:

[LaunchAttach] (3277) about to task_for_pid(2930)

error: [LaunchAttach] MachTask::TaskPortForProcessID task_for_pid(2930) failed: ::task_for_pid ( target_tport = 0x0203, pid = 2930, &task ) => err = 0x00000005 ((os/kern) failure)

macOSTaskPolicy: (com.apple.debugserver) may not get the task control port of (BitwigStudio) (pid: 2930): (BitwigStudio) is hardened, (BitwigStudio) doesn't have get-task-allow, (com.apple.debugserver) is a declared debugger(com.apple.debugserver) is not a declared read-only debugger

1 +0.000000 sec [0ccd/0103]: error: ::task_for_pid ( target_tport = 0x0203, pid = 2930, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0203, pid = 2930, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005)

I have done some research and found this: Stackoverflow link about What does get-task-allow do

get-task-allow, when signed into an application, allows other processes (like the debugger) to attach to your app. Distribution profiles require that this value be turned off, while development profiles require this value to be turned on (otherwise Xcode would never be able to launch and attach to your app).

So there is nothing I can do to debug my programs with that software. Is that correct? :(

TheRealLife
  • 375
  • 4
  • 20

4 Answers4

6

When you don't have access to the original source code or don't want to rebuild it, such as when developing plug-ins for another app (a DAW in your case), you can easily change the entitlements of the application as follows to enable debugging:

  1. Read the current entitlements as follows (replace daw.app with the actual app name):

    codesign --display --xml --entitlements daw.entitlements daw.app
    

    Note: Run this in the Terminal app. It will create a file named daw.entitlements in the current folder. Run the command only once or delete any previously created daw.entitlements; otherwise the command keeps appending to the same file.

  2. Open daw.entitlements in any text editor and insert the following text just before </dict></plist> at the end of the file:

    <key>com.apple.security.get-task-allow</key><true/>

    Note: If there’s already an entry with the same name, change its value from false to true instead of adding a new one.

  3. Apply the new entitlements as follows (replace daw.app with the actual app name):

    codesign -s - --deep --force --options=runtime --entitlements daw.entitlements daw.app
    

This should do it. In the unlikely chance that you already have a file named daw.entitlements in the same folder, use a different file name in all steps.

Arda
  • 757
  • 10
  • 18
  • Tried this and got: `/Applications/Ableton Live 11 Trial.app: replacing existing signature /Applications/Ableton Live 11 Trial.app: resource fork, Finder information, or similar detritus not allowed` – Tobiq Jan 27 '23 at 05:35
  • @Tobiq, I get lots of info when I search for the error message you get, including some helpful solutions on Stackoverflow. Apple has a page dedicated to it too at https://developer.apple.com/library/archive/qa/qa1940/_index.html . I didn't read them in detail, but it sounds like one or more files in the app bundle may be preventing you from changing the entitlements. Please look for the suggested solutions for that (for the specific error message you get). – Arda Jan 27 '23 at 19:54
5

You can debug but you have to set the "Code Signing Inject Base Entitlements" to "Yes" for debugging

enter image description here

And then you have to add a provisioning profile. Go to developer.apple.com then select "Certificates, IDs & Profiles" to create a provisioning profile for the bundle ID you are testing.

spartygw
  • 3,289
  • 2
  • 27
  • 51
  • 2
    Does this cope with debugging plugins in 3rd party software? In OP's question they are trying to debug an AU or VST plugin (their software) in BitwigStudio (3rd party, hardened software). – Dave E Jul 13 '22 at 12:35
4

This solved it for me on terminal

sudo DevToolsSecurity -enable
Mostafa Sultan
  • 2,268
  • 2
  • 20
  • 36
0

I tried all of these and had no luck until I figured out that I also had to disable SIP (system integrity protection) to attach to the audio server plugin I am working on.

Hopefully this helps someone to not lose a whole day on it as I did.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Konstantin
  • 83
  • 6
  • This is is *very* bad advice to give, and should only be used as an absolute last resort when all other avenues have been exhausted. The link given puts it succinctly: "Disable SIP only temporarily to perform necessary tasks, and reenable it as soon as possible. Failure to reenable SIP when you are done testing leaves your computer vulnerable to malicious code." – Rick B Feb 28 '23 at 21:27