xcode.rst 4.1 KB

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