exporting_for_macos.rst 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. .. _doc_exporting_for_macos:
  2. Exporting for macOS
  3. ===================
  4. .. seealso::
  5. This page describes how to export a Godot project to macOS.
  6. If you're looking to compile editor or export template binaries from source instead,
  7. read :ref:`doc_compiling_for_macos`.
  8. macOS apps exported with the official export templates are exported as a single "Universal 2" binary ``.app`` bundle, a folder with a specific structure which stores the executable, libraries and all the project files.
  9. This bundle can be exported as is, packed in a ZIP archive or DMG disk image (only supported when exporting from a computer running macOS).
  10. `Universal binaries for macOS support both Intel x86_64 and ARM64 (Apple Silicon) architectures <https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary>`__.
  11. Requirements
  12. ------------
  13. - Download the Godot export templates. Use the Godot menu: ``Editor > Manage Export Templates``.
  14. - A valid and unique ``Bundle identifier`` should be set in the ``Application`` section of the export options.
  15. .. warning::
  16. Projects exported without code signing and notarization will be blocked by Gatekeeper if they are downloaded from unknown sources, see the :ref:`Running Godot apps on macOS <doc_running_on_macos>` page for more information.
  17. Code signing and notarization
  18. -----------------------------
  19. By default, macOS will run only applications that are signed and notarized. If you use any other signing configuration, see :ref:`Running Godot apps on macOS <doc_running_on_macos>` for workarounds.
  20. To notarize an app, you **must** have a valid `Apple Developer ID Certificate <https://developer.apple.com/>`__.
  21. If you have an Apple Developer ID Certificate and exporting from macOS
  22. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. Install `Xcode <https://developer.apple.com/xcode/>`__ command line tools and open Xcode at least once or run the ``sudo xcodebuild -license accept`` command to accept license agreement.
  24. To sign exported app
  25. ^^^^^^^^^^^^^^^^^^^^
  26. - Select ``Xcode codesign`` in the ``Code Signing > Codesign`` option.
  27. - Set valid Apple ID certificate identity (certificate "Common Name") in the ``Code Signing > Identity`` section.
  28. To notarize exported app
  29. ^^^^^^^^^^^^^^^^^^^^^^^^
  30. - Select ``Xcode altool`` in the ``Notarization > Notarization`` option.
  31. - Disable the ``Debugging`` entitlement.
  32. - Set valid Apple ID login / app. specific password or `App Store Connect <https://developer.apple.com/documentation/appstoreconnectapi>`__ API UUID / Key in the ``Notarization`` section.
  33. You can use the ``xcrun notarytool history`` command to check notarization status and use the ``xcrun notarytool log {ID}`` command to download the notarization log.
  34. If you encounter notarization issues, see `Resolving common notarization issues <https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues>`__ for more info.
  35. After notarization is completed, `staple the ticket <https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/customizing_the_notarization_workflow>`__ to the exported project.
  36. If you have an Apple Developer ID Certificate and exporting from Linux or Windows
  37. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. Install `PyOxidizer rcodesign <https://github.com/indygreg/apple-platform-rs/tree/main/apple-codesign>`__, and configure the path to ``rcodesign`` in the ``Editor Settings > Export > macOS > rcodesign``.
  39. To sign exported app
  40. ^^^^^^^^^^^^^^^^^^^^
  41. - Select ``PyOxidizer rcodesign`` in the ``Code Signing > Codesign`` option.
  42. - Set valid Apple ID PKCS #12 certificate file and password in the ``Code Signing`` section.
  43. To notarize exported app
  44. ^^^^^^^^^^^^^^^^^^^^^^^^
  45. - Select ``PyOxidizer rcodesign`` in the ``Notarization > Notarization`` option.
  46. - Disable the ``Debugging`` entitlement.
  47. - Set valid `App Store Connect <https://developer.apple.com/documentation/appstoreconnectapi>`__ API UUID / Key in the ``Notarization`` section.
  48. You can use the ``rcodesign notary-log`` command to check notarization status.
  49. After notarization is completed, use the ``rcodesign staple`` command to staple the ticket to the exported project.
  50. If you do not have an Apple Developer ID Certificate
  51. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  52. - Select ``Built-in (ad-hoc only)`` in the ``Code Signing > Codesign`` option.
  53. - Select ``Disabled`` in the ``Notarization > Notarization`` option.
  54. In this case Godot will use an ad-hoc signature, which will make running an exported app easier for the end users,
  55. see the :ref:`Running Godot apps on macOS <doc_running_on_macos>` page for more information.
  56. Signing Options
  57. ~~~~~~~~~~~~~~~
  58. +------------------------------+---------------------------------------------------------------------------------------------------+
  59. | Option | Description |
  60. +==============================+===================================================================================================+
  61. | Codesign | Tool to use for code signing. |
  62. +------------------------------+---------------------------------------------------------------------------------------------------+
  63. | Identity | The "Full Name" or "Common Name" of the signing identity, store in the macOS keychain. [1]_ |
  64. +------------------------------+---------------------------------------------------------------------------------------------------+
  65. | Certificate File | The PKCS #12 certificate file. [2]_ |
  66. +------------------------------+---------------------------------------------------------------------------------------------------+
  67. | Certificate Password | Password for the certificate file. [2]_ |
  68. +------------------------------+---------------------------------------------------------------------------------------------------+
  69. | Custom Options | Array of command line arguments passed to the code signing tool. |
  70. +------------------------------+---------------------------------------------------------------------------------------------------+
  71. .. [1] This option is visible only when signing with Xcode codesign.
  72. .. [2] These options are visible only when signing with PyOxidizer rcodesign.
  73. Notarization Options
  74. ~~~~~~~~~~~~~~~~~~~~
  75. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | Option | Description |
  77. +====================+===================================================================================================================================================================================+
  78. | Notarization | Tool to use for notarization. |
  79. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | Apple ID Name | Apple ID account name (email address). [3]_ |
  81. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | Apple ID Password | Apple ID app-specific password. See `Using app-specific passwords <https://support.apple.com/en-us/HT204397>`__ to enable two-factor authentication and create app password. [3]_ |
  83. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | Apple Team ID | Team ID ("Organization Unit"), if your Apple ID belongs to multiple teams (optional). [3]_ |
  85. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | API UUID | Apple `App Store Connect <https://developer.apple.com/documentation/appstoreconnectapi>`__ API issuer UUID. |
  87. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | API Key | Apple `App Store Connect <https://developer.apple.com/documentation/appstoreconnectapi>`__ API key. |
  89. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. .. note::
  91. You should set either Apple ID Name/Password or App Store Connect API UUID/Key.
  92. .. [3] These options are visible only when notarizing with Xcode altool.
  93. See `Notarizing macOS Software Before Distribution <https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution?language=objc>`__ for more info.
  94. Entitlements
  95. ------------
  96. Hardened Runtime Entitlements
  97. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  98. Hardened Runtime entitlements manage security options and resource access policy.
  99. See `Hardened Runtime <https://developer.apple.com/documentation/security/hardened_runtime?language=objc>`__ for more info.
  100. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | Entitlement | Description |
  102. +=======================================+==================================================================================================================================================================================================+
  103. | Allow JIT Code Execution [4]_ | Allows creating writable and executable memory for JIT code. If you are using add-ons with dynamic or self-modifying native code, enable them according to the add-on documentation. |
  104. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | Allow Unsigned Executable Memory [4]_ | Allows creating writable and executable memory without JIT restrictions. If you are using add-ons with dynamic or self-modifying native code, enable them according to the add-on documentation. |
  106. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | 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. |
  108. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | 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. |
  110. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | Audio Input | Enable if you need to use the microphone or other audio input sources, if it's enabled you should also provide usage message in the `privacy/microphone_usage_description` option. |
  112. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | Camera | Enable if you need to use the camera, if it's enabled you should also provide usage message in the `privacy/camera_usage_description` option. |
  114. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | Location | Enable if you need to use location information from Location Services, if it's enabled you should also provide usage message in the `privacy/location_usage_description` option. |
  116. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | 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. |
  118. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | 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. |
  120. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | 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. |
  122. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | Apple Events | [5]_ Enable to allow app to send Apple events to other apps. |
  124. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | Debugging | [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. |
  126. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. .. [4] The ``Allow JIT Code Execution``, ``Allow Unsigned Executable Memory`` and ``Allow DYLD Environment Variables`` entitlements are always enabled for the Godot Mono exports, and are not visible in the export options.
  128. .. [5] These features aren't supported by Godot out of the box, enable them only if you are using add-ons which require them.
  129. .. [6] To notarize an app, you must disable the ``Debugging`` entitlement.
  130. App Sandbox Entitlement
  131. ~~~~~~~~~~~~~~~~~~~~~~~
  132. The App Sandbox restricts access to user data, networking and devices.
  133. Sandboxed apps can't access most of the file system, can't use custom file dialogs and execute binaries (using ``OS.execute`` and ``OS.create_process``) outside the ``.app`` bundle.
  134. See `App Sandbox <https://developer.apple.com/documentation/security/app_sandbox?language=objc>`__ for more info.
  135. .. note::
  136. To distribute an app through the App Store, you must enable the App Sandbox.
  137. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  138. | Entitlement | Description |
  139. +===================================+======================================================================================================================================+
  140. | Enabled | Enables App Sandbox. |
  141. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  142. | Network Server | Enable to allow app to listen for incoming network connections. |
  143. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  144. | Network Client | Enable to allow app to establish outgoing network connections. |
  145. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  146. | Device USB | Enable to allow app to interact with USB devices. This entitlement is required to use wired controllers. |
  147. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  148. | Device Bluetooth | Enable to allow app to interact with Bluetooth devices. This entitlement is required to use wireless controllers. |
  149. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  150. | Files Downloads [7]_ | Allows read or write access to the user's "Downloads" folder. |
  151. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  152. | Files Pictures [7]_ | Allows read or write access to the user's "Pictures" folder. |
  153. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  154. | Files Music [7]_ | Allows read or write access to the user's "Music" folder. |
  155. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  156. | Files Movies [7]_ | Allows read or write access to the user's "Movies" folder. |
  157. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  158. | Files User Selected [7]_ | Allows read or write access to arbitrary folder. To gain access, a folder must be selected from the native file dialog by the user. |
  159. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  160. | Helper Executable | List of helper executables to embedded to the app bundle. Sandboxed app are limited to execute only these executable. |
  161. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  162. .. [7] You can optionally provide usage messages for various folders in the `privacy/*_folder_usage_description` options.
  163. .. note::
  164. You can override default entitlements by selecting custom entitlements file, in this case all other entitlement are ignored.
  165. Environment variables
  166. ---------------------
  167. You can use the following environment variables to set export options outside of
  168. the editor. During the export process, these override the values that you set in
  169. the export menu.
  170. .. list-table:: macOS export environment variables
  171. :header-rows: 1
  172. * - Export option
  173. - Environment variable
  174. * - Encryption / Encryption Key
  175. - ``GODOT_SCRIPT_ENCRYPTION_KEY``
  176. * - Options / Codesign / Certificate File
  177. - ``GODOT_MACOS_CODESIGN_CERTIFICATE_FILE``
  178. * - Options / Codesign / Certificate Password
  179. - ``GODOT_MACOS_CODESIGN_CERTIFICATE_PASSWORD``
  180. * - Options / Codesign / Provisioning Profile
  181. - ``GODOT_MACOS_CODESIGN_PROVISIONING_PROFILE``
  182. * - Options / Notarization / API UUID
  183. - ``GODOT_MACOS_NOTARIZATION_API_UUID``
  184. * - Options / Notarization / API Key
  185. - ``GODOT_MACOS_NOTARIZATION_API_KEY``
  186. * - Options / Notarization / API Key ID
  187. - ``GODOT_MACOS_NOTARIZATION_API_KEY_ID``
  188. * - Options / Notarization / Apple ID Name
  189. - ``GODOT_MACOS_NOTARIZATION_APPLE_ID_NAME``
  190. * - Options / Notarization / Apple ID Password
  191. - ``GODOT_MACOS_NOTARIZATION_APPLE_ID_PASSWORD``