Skip to content

[macOS][Unity] 自编译 Unity 启动报 damaged 无法打开 #39

@nzcv

Description

@nzcv

[macOS][Unity] 自编译 Unity 启动报 "Unity is damaged and can't be opened"

在 macOS 上启动自编译(或从网络/AirDrop 复制)的 Unity.app 时,系统弹出 "Unity is damaged and can't be opened. You should move it to the Trash.",应用无法打开。

现象

  • 双击 /Applications/Unity.app 无法启动
  • macOS 提示应用已损坏,建议移到废纸篓
  • 实际并非二进制损坏,而是 Gatekeeper 拦截

诊断

检查隔离属性与签名状态:

xattr -l /Applications/Unity.app
codesign -dv --verbose=4 /Applications/Unity.app
spctl -a -vv /Applications/Unity.app

常见发现:

  1. com.apple.quarantine — 来源为 sharingd(AirDrop / 网络共享复制),整个 app bundle 内大量文件都带有此属性
  2. Ad-hoc 签名 — 自编译 Unity 为 linker-signed / adhoc,无 Apple 公证
  3. spctl 报错 — 如 code has no resources but signature indicates they must be present

解决方案

方法一(推荐):清除隔离属性

xattr -cr /Applications/Unity.app

清除后 Unity 即可正常启动。

方法二:若仍无法打开,再 ad-hoc 签名

xattr -cr /Applications/Unity.app
codesign --force --deep --sign - /Applications/Unity.app

注意:Unity 内含 SketchUpAPI.framework 结构特殊,codesign --deep 可能报 bundle format is ambiguous,但通常只清除 quarantine 即可

方法三:系统设置

系统设置 → 隐私与安全性 → 在提示处点击「仍要打开」。

预防建议

  • 自编译 Unity 尽量直接在本机安装,避免通过 AirDrop / 微信 / 网盘传输 .app
  • 若必须传输,接收后先执行 xattr -cr,再打开
  • 若需分发给他人,需用 Developer ID 证书签名并公证(notarize)

推荐组合

xattr -cr /Applications/Unity.app && open /Applications/Unity.app

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions