You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调试macOS Action Extension遇阻:出现"Attach failed"错误

调试macOS Action Extension时的Attach失败问题

运行带Action Extension目标的新项目(指定Finder为宿主应用)时,触发如下错误:

Attach failed: Could not attach to pid : “647”. (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.)

Console.app对应的日志信息:

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

此前可正常调试的旧项目也出现相同问题,已尝试清理派生数据、重启Mac,均无效果,按官方文档说明Build & Run应支持正常调试。

可行解决方案

  • 检查系统权限配置

    1. 打开「系统设置」→「隐私与安全性」→「完全磁盘访问权限」,确认Xcode已被勾选。
    2. 切换到「开发者工具」选项,确保Xcode和debugserver的权限已启用。
  • 调整系统完整性保护(SIP)设置

    1. 重启Mac进入恢复模式:Intel芯片按住Command+R;Apple芯片长按电源键直到出现启动选项,选择「选项」进入。
    2. 打开终端,执行命令:
    csrutil enable --without debug
    
    1. 重启Mac,回到正常系统后重试调试。
  • 验证Extension签名与硬运行时配置

    1. 在Xcode中选中Extension目标,进入「Signing & Capabilities」标签页。
    2. 确认使用的是有效开发者账号签名;若开启了「Hardened Runtime」,需勾选「Debugging Tools」权限。
  • 手动附加调试进程

    1. 先运行Extension目标,等待Finder加载扩展。
    2. 在Xcode顶部菜单点击「Debug」→「Attach to Process by PID or Name」,输入「Finder」并完成附加。

内容的提问来源于stack exchange,提问作者Vojta Böhm

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 07:17:42