compiling_for_ios.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. .. _doc_compiling_for_ios:
  2. Compiling for iOS
  3. =================
  4. .. highlight:: shell
  5. .. seealso::
  6. This page describes how to compile iOS export template binaries from source.
  7. If you're looking to export your project to iOS instead, read :ref:`doc_exporting_for_ios`.
  8. Requirements
  9. ------------
  10. - `Python 3.8+ <https://www.python.org/downloads/macos/>`_.
  11. - `SCons 4.0+ <https://scons.org/pages/download.html>`_ build system.
  12. - `Xcode <https://apps.apple.com/us/app/xcode/id497799835>`_.
  13. - Launch Xcode once and install iOS support. If you have already launched
  14. Xcode and need to install iOS support, go to *Xcode -> Settings... -> Platforms*.
  15. - Go to *Xcode -> Settings... -> Locations -> Command Line Tools* and select
  16. an installed version. Even if one is already selected, re-select it.
  17. - Download and follow README instructions to build a static ``.xcframework``
  18. from the `MoltenVK SDK <https://github.com/KhronosGroup/MoltenVK#fetching-moltenvk-source-code>`__.
  19. .. note:: If you have `Homebrew <https://brew.sh/>`_ installed, you can easily
  20. install SCons using the following command:
  21. ::
  22. brew install scons
  23. Installing Homebrew will also fetch the Command Line Tools
  24. for Xcode automatically if you don't have them already.
  25. Similarly, if you have `MacPorts <https://www.macports.org/>`_
  26. installed, you can easily install SCons using the
  27. following command:
  28. ::
  29. sudo port install scons
  30. .. seealso:: To get the Godot source code for compiling, see
  31. :ref:`doc_getting_source`.
  32. For a general overview of SCons usage for Godot, see
  33. :ref:`doc_introduction_to_the_buildsystem`.
  34. Compiling
  35. ---------
  36. Open a Terminal, go to the root folder of the engine source code and type
  37. the following to compile a debug build:
  38. ::
  39. scons platform=ios target=template_debug generate_bundle=yes
  40. To compile a release build:
  41. ::
  42. scons platform=ios target=template_release generate_bundle=yes
  43. To create an Xcode project like in the official builds, you need to use the
  44. template located in ``misc/dist/ios_xcode``. The release and debug libraries
  45. should be placed in ``libgodot.ios.debug.xcframework`` and
  46. ``libgodot.ios.release.xcframework`` respectively. This process can be automated
  47. by using the ``generate_bundle=yes`` option on the *last* SCons command used to
  48. build export templates (so that all binaries can be included).
  49. The MoltenVK static ``.xcframework`` folder must also be placed in the
  50. ``ios_xcode`` folder once it has been created. MoltenVK is always statically
  51. linked on iOS; there is no dynamic linking option available, unlike macOS.
  52. Run
  53. ---
  54. To run on a device, follow these instructions:
  55. :ref:`doc_exporting_for_ios`.
  56. iOS exports can run directly on an Apple Silicon Mac. To run exported iOS project
  57. on Mac, open exported project in Xcode and select ``My Mac`` in the ``Run Destinations``
  58. dropdown.
  59. Troubleshooting
  60. ---------------
  61. Fatal error: 'cstdint' file not found
  62. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  63. If you get a compilation error of this form early on, it's likely because
  64. the Xcode command line tools installation needs to be repaired after
  65. a macOS or Xcode update:
  66. ::
  67. ./core/typedefs.h:45:10: fatal error: 'cstdint' file not found
  68. 45 | #include <cstdint>
  69. | ^~~~~~~~~
  70. Run these two commands to reinstall Xcode command line tools
  71. (enter your administrator password as needed):
  72. ::
  73. sudo rm -rf /Library/Developer/CommandLineTools
  74. sudo xcode-select --install
  75. If it still does not work, try updating Xcode from the Mac App Store and try again.