exporting_for_macos.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. .. warning::
  12. Due to file system limitations, raw ``.app`` bundles exported from Windows lack ``executable`` flag and won't run on macOS.
  13. To fix it, use the ``chmod +x {executable_name}`` command after transferring the exported ``.app`` to macOS or Linux. Projects exported as ``.zip`` aren't affected by this issue.
  14. The main executable located in the ``Contents/MacOS/`` subfolder, as well as optional helper executables in the ``Contents/Helpers/`` subfolder, should have ``executable`` permission for the ``.app`` bundle to be valid.
  15. Requirements
  16. ------------
  17. - Download the Godot export templates. Use the Godot menu: ``Editor > Manage Export Templates``.
  18. - A valid and unique ``Bundle identifier`` should be set in the ``Application`` section of the export options.
  19. .. warning::
  20. 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.
  21. Code signing and notarization
  22. -----------------------------
  23. 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.
  24. To notarize an app, you **must** have a valid `Apple Developer ID Certificate <https://developer.apple.com/>`__.
  25. If you have an Apple Developer ID Certificate and exporting from macOS
  26. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  27. 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.
  28. To sign exported app
  29. ^^^^^^^^^^^^^^^^^^^^
  30. - Select ``Xcode codesign`` in the ``Code Signing > Codesign`` option.
  31. - Set valid Apple ID certificate identity (certificate "Common Name") in the ``Code Signing > Identity`` section.
  32. To notarize exported app
  33. ^^^^^^^^^^^^^^^^^^^^^^^^
  34. - Select ``Xcode altool`` in the ``Notarization > Notarization`` option.
  35. - Disable the ``Debugging`` entitlement.
  36. - 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.
  37. 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.
  38. 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.
  39. 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.
  40. If you have an Apple Developer ID Certificate and exporting from Linux or Windows
  41. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  42. 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``.
  43. To sign exported app
  44. ^^^^^^^^^^^^^^^^^^^^
  45. - Select ``PyOxidizer rcodesign`` in the ``Code Signing > Codesign`` option.
  46. - Set valid Apple ID PKCS #12 certificate file and password in the ``Code Signing`` section.
  47. To notarize exported app
  48. ^^^^^^^^^^^^^^^^^^^^^^^^
  49. - Select ``PyOxidizer rcodesign`` in the ``Notarization > Notarization`` option.
  50. - Disable the ``Debugging`` entitlement.
  51. - Set valid `App Store Connect <https://developer.apple.com/documentation/appstoreconnectapi>`__ API UUID / Key in the ``Notarization`` section.
  52. You can use the ``rcodesign notary-log`` command to check notarization status.
  53. After notarization is completed, use the ``rcodesign staple`` command to staple the ticket to the exported project.
  54. If you do not have an Apple Developer ID Certificate
  55. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  56. - Select ``Built-in (ad-hoc only)`` in the ``Code Signing > Codesign`` option.
  57. - Select ``Disabled`` in the ``Notarization > Notarization`` option.
  58. In this case Godot will use an ad-hoc signature, which will make running an exported app easier for the end users,
  59. see the :ref:`Running Godot apps on macOS <doc_running_on_macos>` page for more information.
  60. Signing Options
  61. ~~~~~~~~~~~~~~~
  62. +------------------------------+---------------------------------------------------------------------------------------------------+
  63. | Option | Description |
  64. +==============================+===================================================================================================+
  65. | Codesign | Tool to use for code signing. |
  66. +------------------------------+---------------------------------------------------------------------------------------------------+
  67. | Identity | The "Full Name" or "Common Name" of the signing identity, store in the macOS keychain. [1]_ |
  68. +------------------------------+---------------------------------------------------------------------------------------------------+
  69. | Certificate File | The PKCS #12 certificate file. [2]_ |
  70. +------------------------------+---------------------------------------------------------------------------------------------------+
  71. | Certificate Password | Password for the certificate file. [2]_ |
  72. +------------------------------+---------------------------------------------------------------------------------------------------+
  73. | Custom Options | Array of command line arguments passed to the code signing tool. |
  74. +------------------------------+---------------------------------------------------------------------------------------------------+
  75. .. [1] This option is visible only when signing with Xcode codesign.
  76. .. [2] These options are visible only when signing with PyOxidizer rcodesign.
  77. Notarization Options
  78. ~~~~~~~~~~~~~~~~~~~~
  79. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | Option | Description |
  81. +====================+===================================================================================================================================================================================+
  82. | Notarization | Tool to use for notarization. |
  83. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | Apple ID Name | Apple ID account name (email address). [3]_ |
  85. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | 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]_ |
  87. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | Apple Team ID | Team ID ("Organization Unit"), if your Apple ID belongs to multiple teams (optional). [3]_ |
  89. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | API UUID | Apple `App Store Connect <https://developer.apple.com/documentation/appstoreconnectapi>`__ API issuer UUID. |
  91. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | API Key | Apple `App Store Connect <https://developer.apple.com/documentation/appstoreconnectapi>`__ API key. |
  93. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. .. note::
  95. You should set either Apple ID Name/Password or App Store Connect API UUID/Key.
  96. .. [3] These options are visible only when notarizing with Xcode altool.
  97. See `Notarizing macOS Software Before Distribution <https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution?language=objc>`__ for more info.
  98. Entitlements
  99. ------------
  100. Hardened Runtime Entitlements
  101. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102. Hardened Runtime entitlements manage security options and resource access policy.
  103. See `Hardened Runtime <https://developer.apple.com/documentation/security/hardened_runtime?language=objc>`__ for more info.
  104. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | Entitlement | Description |
  106. +=======================================+==================================================================================================================================================================================================+
  107. | 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. |
  108. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | 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. |
  110. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | 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. |
  112. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | 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. |
  114. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | 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. |
  116. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | 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. |
  118. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | 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. |
  120. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | 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. |
  122. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | 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. |
  124. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | 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. |
  126. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | Apple Events | [5]_ Enable to allow app to send Apple events to other apps. |
  128. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | 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. |
  130. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. .. [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.
  132. .. [5] These features aren't supported by Godot out of the box, enable them only if you are using add-ons which require them.
  133. .. [6] To notarize an app, you must disable the ``Debugging`` entitlement.
  134. App Sandbox Entitlement
  135. ~~~~~~~~~~~~~~~~~~~~~~~
  136. The App Sandbox restricts access to user data, networking and devices.
  137. 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.
  138. See `App Sandbox <https://developer.apple.com/documentation/security/app_sandbox?language=objc>`__ for more info.
  139. .. note::
  140. To distribute an app through the App Store, you must enable the App Sandbox.
  141. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  142. | Entitlement | Description |
  143. +===================================+======================================================================================================================================+
  144. | Enabled | Enables App Sandbox. |
  145. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  146. | Network Server | Enable to allow app to listen for incoming network connections. |
  147. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  148. | Network Client | Enable to allow app to establish outgoing network connections. |
  149. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  150. | Device USB | Enable to allow app to interact with USB devices. This entitlement is required to use wired controllers. |
  151. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  152. | Device Bluetooth | Enable to allow app to interact with Bluetooth devices. This entitlement is required to use wireless controllers. |
  153. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  154. | Files Downloads [7]_ | Allows read or write access to the user's "Downloads" folder. |
  155. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  156. | Files Pictures [7]_ | Allows read or write access to the user's "Pictures" folder. |
  157. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  158. | Files Music [7]_ | Allows read or write access to the user's "Music" folder. |
  159. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  160. | Files Movies [7]_ | Allows read or write access to the user's "Movies" folder. |
  161. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  162. | 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. |
  163. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  164. | Helper Executable | List of helper executables to embedded to the app bundle. Sandboxed app are limited to execute only these executable. |
  165. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  166. .. [7] You can optionally provide usage messages for various folders in the `privacy/*_folder_usage_description` options.
  167. .. note::
  168. You can override default entitlements by selecting custom entitlements file, in this case all other entitlement are ignored.
  169. Environment variables
  170. ---------------------
  171. You can use the following environment variables to set export options outside of
  172. the editor. During the export process, these override the values that you set in
  173. the export menu.
  174. .. list-table:: macOS export environment variables
  175. :header-rows: 1
  176. * - Export option
  177. - Environment variable
  178. * - Encryption / Encryption Key
  179. - ``GODOT_SCRIPT_ENCRYPTION_KEY``
  180. * - Options / Codesign / Certificate File
  181. - ``GODOT_MACOS_CODESIGN_CERTIFICATE_FILE``
  182. * - Options / Codesign / Certificate Password
  183. - ``GODOT_MACOS_CODESIGN_CERTIFICATE_PASSWORD``
  184. * - Options / Codesign / Provisioning Profile
  185. - ``GODOT_MACOS_CODESIGN_PROVISIONING_PROFILE``
  186. * - Options / Notarization / API UUID
  187. - ``GODOT_MACOS_NOTARIZATION_API_UUID``
  188. * - Options / Notarization / API Key
  189. - ``GODOT_MACOS_NOTARIZATION_API_KEY``
  190. * - Options / Notarization / API Key ID
  191. - ``GODOT_MACOS_NOTARIZATION_API_KEY_ID``
  192. * - Options / Notarization / Apple ID Name
  193. - ``GODOT_MACOS_NOTARIZATION_APPLE_ID_NAME``
  194. * - Options / Notarization / Apple ID Password
  195. - ``GODOT_MACOS_NOTARIZATION_APPLE_ID_PASSWORD``