2
0

compiling_for_ios.rst 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. - SCons 3.0+ (you can install it via `Homebrew <https://brew.sh/>`_ or
  11. `MacPorts <https://www.macports.org/>`_, you should be able
  12. to run ``scons`` in a terminal when installed).
  13. - Xcode 11.0 (or later) with the iOS (13.0) SDK and the command line tools.
  14. If you are building the ``master`` branch:
  15. - Download and follow README instructions to build a static ``.a`` library
  16. from the `MoltenVK SDK <https://github.com/KhronosGroup/MoltenVK#fetching-moltenvk-source-code>`__.
  17. .. seealso:: To get the Godot source code for compiling, see
  18. :ref:`doc_getting_source`.
  19. For a general overview of SCons usage for Godot, see
  20. :ref:`doc_introduction_to_the_buildsystem`.
  21. Compiling
  22. ---------
  23. Open a Terminal, go to the root dir of the engine source code and type:
  24. ::
  25. $ scons p=iphone target=debug
  26. for a debug build, or:
  27. ::
  28. $ scons p=iphone target=release
  29. for a release build (check ``platform/iphone/detect.py`` for the compiler
  30. flags used for each configuration).
  31. Alternatively, you can run
  32. ::
  33. $ scons p=iphone arch=x86_64 target=debug
  34. for a Simulator executable.
  35. For recent devices, Apple requires 64-bit versions of application binaries when you are uploading to the Apple Store.
  36. The best way to provide these is to create a bundle in which there are both 32-bit and 64-bit binaries, so every device will be able to run the game.
  37. It can be done in three steps: first compile the 32-bit version, then compile the 64-bit version and then use ``lipo`` to bundle them into one "universal" binary.
  38. All those steps can be performed with following commands:
  39. ::
  40. $ scons p=iphone tools=no target=release arch=arm
  41. $ scons p=iphone tools=no target=release arch=arm64
  42. $ lipo -create bin/libgodot.iphone.opt.arm.a bin/libgodot.iphone.opt.arm64.a -output bin/libgodot.iphone.release.fat.a
  43. $ lipo -create bin/libgodot_camera_module.iphone.opt.arm.a bin/libgodot_camera_module.iphone.opt.arm64.a -output bin/libgodot_camera_module.iphone.release.fat.a
  44. $ lipo -create bin/libgodot_arkit_module.iphone.opt.arm.a bin/libgodot_arkit_module.iphone.opt.arm64.a -output bin/libgodot_arkit_module.iphone.release.fat.a
  45. If you also want to provide a simulator build (reduces the chance of any linker errors with dependencies), you'll need to build and lipo the ``x86_64`` architecture as well.
  46. ::
  47. $ scons p=iphone tools=no target=release arch=arm
  48. $ scons p=iphone tools=no target=release arch=arm64
  49. $ scons p=iphone tools=no target=release arch=x86_64
  50. $ lipo -create bin/libgodot.iphone.opt.arm.a bin/libgodot.iphone.opt.arm64.a bin/libgodot.iphone.opt.x86_64.a -output bin/libgodot.iphone.release.fat.a
  51. $ lipo -create bin/libgodot_camera_module.iphone.opt.arm.a bin/libgodot_camera_module.iphone.opt.arm64.a bin/libgodot_camera_module.iphone.opt.x86_64.a -output bin/libgodot_camera_module.iphone.release.fat.a
  52. $ lipo -create bin/libgodot_arkit_module.iphone.opt.arm.a bin/libgodot_arkit_module.iphone.opt.arm64.a bin/libgodot_arkit_module.iphone.opt.x86_64.a -output bin/libgodot_arkit_module.iphone.release.fat.a
  53. Run
  54. ---
  55. To run on a device or simulator, follow these instructions:
  56. :ref:`doc_exporting_for_ios`.
  57. Replace or add your executable to the Xcode project, and change the
  58. "executable name" property on Info.plist accordingly if you use an
  59. alternative build.