为 macOS 导出

参见

This page describes how to export a Godot project to macOS. If you’re looking to compile editor or export template binaries from source instead, read 为 macOS 平台编译.

macOS App 会被导出为 .app 捆绑包,这是一个具有特殊结构的文件夹,里面存放着可执行文件、库,以及所有项目文件。这个捆绑包可以原样导出,或者打包到 ZIP 归档文件或 DMG 磁盘映像文件中(只有在运行 macOS 的计算机上进行导出时才支持)。

需求

  • 下载 Godot 导出模板。使用 Godot 菜单:编辑器 > 管理导出模板

  • 应当在导出选项的 应用 部分中设置有效且唯一的 捆绑包标识符

警告

导出的项目如果没有进行代码签名和公证,那么如果是从未知来源下载到的,就会被“门禁”(Gatekeeper)阻拦。详情请参阅在 macOS 上运行 Godot 应用页面。

代码签名与公证

默认情况下,macOS 只会运行经过签名和公证的应用程序。如果你使用了其他签名配置,替代方案请参阅在 macOS 上运行 Godot 应用

要公证 App,你必须持有有效的 Apple 开发者 ID 证书

If you have an Apple Developer ID Certificate and exporting from macOS

Install Xcode command line tools and open Xcode at least once or run the sudo xcodebuild -license accept command to accept license agreement.

To sign exported app

  • Select Xcode codesign in the Code Signing > Codesign option.

  • Set valid Apple ID certificate identity (certificate “Common Name”) in the Code Signing > Identity section.

To notarize exported app

  • Select Xcode altool in the Notarization > Notarization option.

  • Disable the Debugging entitlement.

  • Set valid Apple ID login / app. specific password or App Store Connect API UUID / Key in the Notarization section.

你可以使用 xcrun notarytool history 命令检查公证状态,使用 xcrun notarytool log {ID} 命令下载公证日志。

如果你在公证过程中遇到了问题,请在 Resolving common notarization issues 查看更多信息。

完成公证后,请将票证装订到导出的项目上。

If you have an Apple Developer ID Certificate and exporting from Linux or Windows

Install PyOxidizer rcodesign, and configure the path to rcodesign in the Editor Settings > Export > macOS > rcodesign.

To sign exported app

  • Select PyOxidizer rcodesign in the Code Signing > Codesign option.

  • Set valid Apple ID PKCS #12 certificate file and password in the Code Signing section.

To notarize exported app

  • Select PyOxidizer rcodesign in the Notarization > Notarization option.

  • Disable the Debugging entitlement.

  • Set valid App Store Connect API UUID / Key in the Notarization section.

You can use the rcodesign notary-log command to check notarization status.

After notarization is completed, use the rcodesign staple command to staple the ticket to the exported project.

如果你没有 Apple 开发者 ID 证书

  • Select Built-in (ad-hoc only) in the Code Signing > Codesign option.

  • Select Disabled in the Notarization > Notarization option.

In this case Godot will use a ad-hoc signature, which will make running an exported app easier for the end users, see the Running Godot apps on macOS page for more information.

签名选项

选项

描述

Codesign

Tool to use for code signing.

Identity

The “Full Name” or “Common Name” of the signing identity, store in the macOS keychain. 1

Certificate File

The PKCS #12 certificate file. 2

Certificate Password

Password for the certificate file. 2

Custom Options

Array of command line arguments passed to the code signing tool.

1

This option is visible only when signing with Xcode codesign.

2(1,2)

These options are visible only when signing with PyOxidizer rcodesign.

公证选项

选项

描述

Notarization

Tool to use for notarization.

Apple ID Name

Apple ID account name (email address). 3

Apple ID Password

Apple ID 的 App 专用密码。请参阅《使用 App 专用密码》启用双重认证并创建 App 密码。3

Apple Team ID

Team ID (“Organization Unit”), if your Apple ID belongs to multiple teams (optional). 3

API UUID

Apple App Store Connect API issuer UUID.

API Key

Apple App Store Connect API key.

备注

You should set either Apple ID Name/Password or App Store Connect API UUID/Key.

3(1,2,3)

These options are visible only when notarizing with Xcode altool.

详情请参阅 Notarizing macOS Software Before Distribution

授权

强化运行时授权

强化运行时授权(Hardened Runtime entitlements)管理的是安全性选项和资源访问策略。详情请参阅 Hardened Runtime

授权

描述

Allow JIT Code Execution 4

允许为 JIT 代码创建可写可执行的内存。如果你正在使用动态或能够自我修改原生代码的插件,请根据插件文档启用它们。

Allow Unsigned Executable Memory 4

允许创建没有 JIT 限制的可写可执行的内存。如果你正在使用动态或能够自我修改原生代码的插件,请根据插件文档启用它们。

Allow DYLD Environment Variables 4

Allows app to uss dynamic linker environment variables to inject code. If you are using add-ons with dynamic or self-modifying native code, enable them according to the add-on documentation.

Disable Library Validation

Allows app to load arbitrary libraries and frameworks. Enable it if you are using GDExtension add-ons or ad-hoc signing, or want to support user-provided external add-ons.

Audio Input

请在需要使用麦克风或者其他音频输入源时启用。启用时,你应该还要在 privacy/microphone_usage_description 中提供用途信息。

Camera

请在需要使用摄像头时启用。启用时,你应该还要在 privacy/camera_usage_description 中提供用途信息。

位置

请在需要使用位置服务时启用。启用时,你应该还要在 privacy/location_usage_description 中提供用途信息。

Address Book

5 Enable to allow access contacts in the user’s address book, if it’s enabled you should also provide usage message in the privacy/address_book_usage_description option.

Calendars

5 Enable to allow access to the user’s calendar, if it’s enabled you should also provide usage message in the privacy/calendar_usage_description option.

Photo Library

5 Enable to allow access to the user’s Photos library, if it’s enabled you should also provide usage message in the privacy/photos_library_usage_description option.

Apple Events

5 Enable to allow app to send Apple events to other apps.

调试

6 You can temporarily enable this entitlement to use native debugger (GDB, LLDB) with the exported app. This entitlement should be disabled for production export.

4(1,2,3)

Allow JIT Code ExecutionAllow Unsigned Executable MemoryAllow DYLD Environment Variables 授权在 Godot Mono 导出中始终启用,在导出选项中不可见。

5(1,2,3,4)

Godot 并不支持这些特性的开箱即用,请在使用需要用到它们的插件时启用。

6

要对 App 进行公证,你必须禁用 Debugging 授权。

App 沙盒授权

App 沙盒会限制对用户数据、网络、设备的访问。沙盒 App 无法访问文件系统的大部分位置,无法使用自定义文件对话框,也无法执行 .app 捆绑包以外的可执行文件(通过 OS.executeOS.create_process)。详情请参阅 App Sandbox

备注

要通过 App Store 分发 App,必须启用 App 沙盒。

授权

描述

Enabled

启用 App 沙盒。

Network Server

允许 App 监听入站网络请求。

Network Client

允许 App 监听出站网络请求。

Device USB

允许 App 与 USB 设备交互。使用有线控制器需要这项授权。

Device Bluetooth

允许 App 与蓝牙设备交互。使用无线控制器需要这项授权。

Files Downloads 7

允许对用户的“ Downloads”文件夹进行读写。

Files Pictures 7

允许对用户的“ Pictures”文件夹进行读写。

Files Music 7

允许对用户的“ Music”文件夹进行读写。

Files Movies 7

允许对用户的“ Movies”文件夹进行读写。

Files User Selected 7

允许对用户的任意文件夹进行读写。要获取访问权限,必须由用户在原生文件对话框中选中该文件夹。

Helper Executable

要在 App 捆绑包中嵌入的辅助可执行文件列表。沙盒 App 仅限于执行这些可执行文件。

7(1,2,3,4,5)

针对不同的文件夹,你还可以通过 privacy/*_folder_usage_description 选项提供用途信息。

备注

选择自定义授权文件即可覆盖默认授权,此时其他所有授权都会被忽略。

环境变量

You can use the following environment variables to set export options outside of the editor. During the export process, these override the values that you set in the export menu.

macOS 导出环境变量

导出选项

环境变量

加密 / 密钥

GODOT_SCRIPT_ENCRYPTION_KEY

选项 / 代码签名 / 证书文件

GODOT_MACOS_CODESIGN_CERTIFICATE_FILE

选项 / 代码签名 / 证书密码

GODOT_MACOS_CODESIGN_CERTIFICATE_PASSWORD

选项 / 代码签名 / 预置描述文件

GODOT_MACOS_CODESIGN_PROVISIONING_PROFILE

选项 / 公证 / API UUID

GODOT_MACOS_NOTARIZATION_API_UUID

选项 / 公证 / API 密钥

GODOT_MACOS_NOTARIZATION_API_KEY

选项 / 公证 / API 密钥 ID

GODOT_MACOS_NOTARIZATION_API_KEY_ID

选项 / 公证 / Apple ID 名称

GODOT_MACOS_NOTARIZATION_APPLE_ID_NAME

选项 / 公证 / Apple ID 密码

GODOT_MACOS_NOTARIZATION_APPLE_ID_PASSWORD

Previous Next


© 版权所有 2014-present Juan Linietsky, Ariel Manzur and the Godot community (CC BY 3.0). Revision b1c660f7.

Built with Sphinx using a theme provided by Read the Docs.