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? 🙁
4
Answers
You can debug but you have to set the "Code Signing Inject Base Entitlements" to "Yes" for debugging
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.
This solved it for me on terminal
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:
Read the current entitlements as follows (replace
daw.app
with the actual app name):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 createddaw.entitlements
; otherwise the command keeps appending to the same file.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
totrue
instead of adding a new one.Apply the new entitlements as follows (replace
daw.app
with the actual app name):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.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.