Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

在 macOS 上运行 Godot 应用

参见

这个页面描述的是在 macOS 上运行 Godot 项目。如果你还没有导出项目,请先阅读 为 macOS 导出

默认情况下,macOS 只会运行签名并公证后的应用程序。

备注

When running an app from the Downloads folder or when still in quarantine, Gatekeeper will perform path randomization as a security measure. This breaks access to relative paths from the app, which the app relies upon to work. To resolve this issue, move the app to the /Applications folder.

In general, macOS apps should avoid relying on relative paths from the application folder.

根据 macOS 应用签名和分发方法的不同,可能出现下列情况:

App 已签名并公证,通过 App Store 分发

备注

App 开发者需要加入 Apple 开发者计划,然后在导出时配置签名和公证选项,最后将 App 上传到 App Store。

App 应该是可以开箱即用的,无需额外的用户交互。

App 已签名并公证,在 App Store 外分发

备注

App 开发者需要加入 Apple 开发者计划,然后在导出时配置签名和公证选项,最后将 App 以“.DMG”或“.ZIP”归档文件的形式分发。

首次运行该 App 时,会出现如下对话框:

../../_images/signed_and_notarized_0.png

单击 打开 启动应用。

如果你看到了如下的警告对话框,那么你的 Mac 是被设置成了只允许来自 App Store 的应用。

../../_images/signed_and_notarized_1.png

要允许第三方程序,请打开 系统设置,点击 安全性与隐私,然后点击 通用,解锁设置,然后选择 App Store 和被认可的开发者

../../_images/sys_pref_0.png

应用已签名(包括 Ad-hoc 签名)但未公证

备注

应用开发者使用了自签名证书或 Ad-hoc 签名(Godot 导出项目的默认行为)。

首次运行该 App 时,会出现如下对话框:

../../_images/signed_0.png

要运行此应用,你可以临时覆盖 Gatekeeper:

  • 可以打开 系统设置,点击 安全性与隐私,然后点击 通用,然后点击 仍然打开

    ../../_images/sys_pref_1.png
  • 也可以在访达窗口中右键单击(Control-单击)应用图标,选择菜单中的 打开

    ../../_images/signed_1.png
  • 然后在确认对话框中单击 打开

    ../../_images/signed_2.png
  • 如出现提示就输入密码。

Another option is to disable Gatekeeper entirely. Note that this does decrease the security of your computer by allowing you to run any software you want. To do this, run sudo spctl --master-disable in the Terminal, enter your password, and then the Anywhere option will be available:

../../_images/macos_allow_from_anywhere.png

Note that Gatekeeper will re-enable itself when macOS updates.

App is not signed, executable is linker-signed

备注

App 使用官方导出模板构建,但未签名。

首次运行该 App 时,会出现如下对话框:

../../_images/linker_signed_1.png

要运行这个 App,你应该手动移除“隔离”(quarantine)扩展文件属性:

  • Open Terminal.app (press Cmd + Space and enter Terminal).

  • 切换到包含目标应用程序的文件夹。

    使用 cd 到_App_文件夹的路径 命令,例如在 Downloads 文件夹中的话就是 cd ~/Downloads/

  • 执行命令 xattr -dr com.apple.quarantine "未签名游戏.app"(包括引号和“.app”扩展名)。

Neither app nor executable is signed (relevant for Apple Silicon Macs only)

备注

App 使用自定义导出模板构建,使用 OSXCross 编译,完全没有签名。

首次运行该 App 时,会出现如下对话框:

../../_images/unsigned_1.png

要运行这个 App,你可以自己进行 Ad-hoc 签名:

  • 从 App Store 安装 Xcode,运行并确认安装命令行工具。

  • Open Terminal.app (press Cmd + Space and enter Terminal).

  • 切换到包含目标应用程序的文件夹。

    使用 cd 到_App_文件夹的路径 命令,例如在 Downloads 文件夹中的话就是 cd ~/Downloads/

  • 运行以下命令:

    xattr -dr com.apple.quarantine "未签名游戏.app"(包括引号和“.app”扩展名)。

    codesign -s - --force --deep "未签名游戏.app"(包括引号和“.app”扩展名)。