xcode.rst 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. .. _doc_configuring_an_ide_xcode:
  2. Xcode
  3. =====
  4. `Xcode <https://developer.apple.com/xcode>`_ is a free macOS-only IDE. You can
  5. download it from the Mac App Store.
  6. Importing the project
  7. ---------------------
  8. - From Xcode's main screen create a new project using the **Other > External Build System** template.
  9. .. figure:: img/xcode_1_create_external_build_project.png
  10. :figclass: figure-w480
  11. :align: center
  12. - Open your build targets from the **Targets** section and select the **Info** tab.
  13. - Fill out the form with the following settings:
  14. +------------+------------------------------------------------------------------------------+
  15. | Build Tool | A full path to the **scons** executable, e.g. **/usr/local/bin/scons** |
  16. +------------+------------------------------------------------------------------------------+
  17. | Arguments | See :ref:`doc_introduction_to_the_buildsystem` for a full list of arguments. |
  18. +------------+------------------------------------------------------------------------------+
  19. | Directory | A full path to the Godot root folder |
  20. +------------+------------------------------------------------------------------------------+
  21. .. figure:: img/xcode_2_configure_scons.png
  22. :figclass: figure-w480
  23. :align: center
  24. - Add a Command Line Tool target which will be used for indexing the project by
  25. choosing **File > New > Target...**.
  26. .. figure:: img/xcode_3_add_new_target.png
  27. :figclass: figure-w480
  28. :align: center
  29. - Select **OS X > Application > Command Line Tool**.
  30. .. figure:: img/xcode_4_select_command_line_target.png
  31. :figclass: figure-w480
  32. :align: center
  33. .. note:: Name it something so you know not to compile with this target (e.g. ``GodotXcodeIndex``).
  34. - For this target open the **Build Settings** tab and look for **Header Search Paths**.
  35. - Set **Header Search Paths** to the absolute path to the Godot root folder. You need to
  36. include subdirectories as well. To achieve that, add two two asterisks (``**``) to the
  37. end of the path, e.g. ``/Users/me/repos/godot-source/**``.
  38. - Add the Godot source to the project by dragging and dropping it into the project file browser.
  39. - Uncheck **Create external build system project**.
  40. .. figure:: img/xcode_5_after_add_godot_source_to_project.png
  41. :figclass: figure-w480
  42. :align: center
  43. - Next select **Create groups** for the **Added folders** option and check *only*
  44. your command line indexing target in the **Add to targets** section.
  45. .. figure:: img/xcode_6_after_add_godot_source_to_project_2.png
  46. :figclass: figure-w480
  47. :align: center
  48. - Xcode will now index the files. This may take a few minutes.
  49. - Once Xcode is done indexing, you should have jump-to-definition,
  50. autocompletion, and full syntax highlighting.
  51. Debugging the project
  52. ---------------------
  53. To enable debugging support you need to edit the external build target's build and run schemes.
  54. - Open the scheme editor of the external build target.
  55. - Locate the **Build > Post Actions** section.
  56. - Add a new script run action
  57. - Under **Provide build settings from** select your project. This allows to reference
  58. the project directory within the script.
  59. - Create a script that will give the binary a name that Xcode can recognize, e.g.:
  60. .. code-block:: shell
  61. ln -f ${PROJECT_DIR}/godot/bin/godot.osx.tools.64 ${PROJECT_DIR}/godot/bin/godot
  62. .. figure:: img/xcode_7_setup_build_post_action.png
  63. :figclass: figure-w480
  64. :align: center
  65. - Build the external build target.
  66. - Open the scheme editor again and select **Run**.
  67. .. figure:: img/xcode_8_setup_run_scheme.png
  68. :figclass: figure-w480
  69. :align: center
  70. - Set the **Executable** to the file you linked in your post-build action script.
  71. - Check **Debug executable**.
  72. - You can add two arguments on the **Arguments** tab:
  73. the ``-e`` flag opens the editor instead of the project manager, and the ``--path`` argument
  74. tells the executable to open the specified project (must be provided as an *absolute* path
  75. to the project root, not the ``project.godot`` file).
  76. To check that everything is working, put a breakpoint in ``platform/osx/godot_main_osx.mm`` and
  77. run the project.
  78. If you run into any issues, ask for help in one of
  79. `Godot's community channels <https://godotengine.org/community>`__.