为什么Xcode有些程序无法附加?

Why Xcode can not attach to some programs?

我不得不重新安装我的 MacBook Pro。我已经安装了最新的 macOS & Xcode 版本所以

macOS 蒙特雷 12.0.1 (21A559) 和 版本 13.1 (13A1030d)

我正在编写音频插件,因此为了测试我的插件,我通常是 运行 DAW(数字音频工作站),就我而言,我大部分时间都在使用 Ableton 或 Bitwig。

所以如果我开始调试过程,我会得到以下错误: 无法附加到 pid XXXXXX 附加失败(不允许附加到进程。查看控制台消息 (Console.app),在调试服务器条目附近,当附加失败时。拒绝附加权限的子系统可能会记录一条信息性消息,说明它的原因被拒绝了。)

如果我关注 console.app 以下几行:

[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)

我做了一些研究,发现了这个: Whosebug 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).

所以我无法使用该软件调试我的程序。那是对的吗? :(

您可以调试,但必须将“代码签名注入基本权利”设置为“”以进行调试

然后您必须添加配置文件。转到 developer.apple.com,然后 select“证书、ID 和配置文件”,为您正在测试的捆绑包 ID 创建配置文件。

这在终端上为我解决了

sudo DevToolsSecurity -enable