修复 macOS「应用已损坏,无法打开」
排查 macOS 提示应用已损坏的原因,通过单独放行或清除隔离标记来修复,无需关闭系统级防护。
快速开始
macOS 打开从网上下载的应用时提示「已损坏,无法打开」,应用本身往往没问题——是 Gatekeeper 拦截了它的隔离元数据或签名。本指南带你从诊断到针对性修复一步步解决。
症状
确认应用的签名是否真的损坏
「已损坏,无法打开」通常意味着代码签名校验未通过。先验证应用包的签名:如果结果正常,问题多半出在隔离标记上;如果提示「未签名」或「资源已被修改」,说明应用包本身有问题。输出末尾出现 valid on disk 即表示签名完好。
检查应用包的签名是否有效、是否在签名后被修改过。
$ codesign --verify --deep --strict --verbose=2 /Applications/SomeApp.app检查是否存在隔离标记
如果签名验证通过,macOS 拒绝打开多半是因为从网上下载的文件会带上 com.apple.quarantine 扩展属性。列出该应用的扩展属性,确认是否有这个标记。只要看到 com.apple.quarantine,就说明这是 Gatekeeper 拦截,而非应用真的损坏。
查看 Gatekeeper 附加在下载文件上的隐藏元数据,并在充分了解后再决定是否清除。
$ xattr -l ~/Downloads/SomeApp.app▾ 撤销
$ xattr -d com.apple.quarantine ~/Downloads/SomeApp.app了解 Gatekeeper 当前的严格程度
先确认 Gatekeeper 校验是否开启,才能选对修复方式:如果处于严格模式,可以为单个应用添加放行规则;如果已被关闭,问题可能出在别处。运行状态检查,留意输出是 assessments enabled 还是 disabled,再进行下一步。
查看门禁评估是否开启,并从终端控制这项全局安全策略。
$ spctl --status▾ 撤销
$ sudo spctl --master-enable仅放行这一个应用
不要全局放宽 Gatekeeper,而是为这个应用单独插入一条放行规则,让它在其他下载仍被拦截的情况下正常启动。当签名有效、只是被隔离标记拦截时,这是首选方案。添加规则后重新打开应用,应该不会再出现「已损坏」提示。
spctl --add 会添加按应用的评估规则,让某一个工具可以启动,同时 Gatekeeper 对其他软件保持严格。
$ sudo spctl --add /Applications/MyTool.app --label "Approved Tools"▾ 撤销
$ sudo spctl --remove /Applications/MyTool.app直接清除隔离属性
如果单独放行仍不起作用(或应用不在 /Applications 下、规则覆盖不到),可以递归删除应用包上的隔离标记,直接去掉 Gatekeeper 用来拦截下载应用的元数据。成功的标志是之后应用能正常打开,不再弹出安全提示。
查看并删除扩展属性——包括触发 Gatekeeper 拦截的隔离标记和 Finder 标签。
$ xattr -r -d com.apple.quarantine /Applications/SomeApp.app确认 Gatekeeper 仍在保护你的 Mac
修复应用后,检查 Gatekeeper 的总开关没有在之前的排查中被关闭——逐个放行的意义就在于保持全局防护不变。状态应显示 assessments enabled。最后再打开一次应用,确认能顺利启动即大功告成。
用 spctl --status 查看 macOS 对下载应用的验证机制(门禁)当前是否启用。
$ spctl --status▾ 撤销
$ sudo spctl --global-enable如何确认已解决
应用能正常打开且不再出现损坏提示,同时 Gatekeeper 状态仍为 assessments enabled。
一键全部撤销
上面每一条命令都可以撤销。按此顺序执行即可全部还原。
$ sudo spctl --global-enable
sudo spctl --remove /Applications/MyTool.app
sudo spctl --master-enable
xattr -d com.apple.quarantine ~/Downloads/SomeApp.app执行前请先确认——部分步骤之间可能并非相互独立。
来源
- macOS codesign — create and manipulate code signatures依据: Documents codesign --verify, --deep, --strict and --display flags.
- Safely open apps on your Mac - Apple Support依据: Apple's guidance on Gatekeeper app-safety checks that spctl reports on and controls.
- Code Signing Guide依据: Apple explains code signature validation and why deep verification checks nested code.
- Protecting users from malware on Mac依据: Explains Gatekeeper's role in verifying that downloaded apps come from identified developers before they are allowed to run.
- xattr — display and manipulate extended attributes (macOS)依据: Documents -l to list all extended attributes, -d to delete one, and -r for recursive operation on bundles.
- SPCTL Command: Manage security assessment policy in macOS依据: Documents spctl --status, --master-enable, and --master-disable for the Gatekeeper assessment policy.
最后验证: 2026-09-21