Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Xcode

Xcode 是一个免费的macOS专用IDE, 你可以从Mac App Store下载它.

导入项目

  • 在Xcode的主屏幕上, 使用 Other > External Build System [其他>外部构建系统]模板创建一个新项目.

../../../_images/xcode_1_create_external_build_project.webp
  • 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).

../../../_images/xcode_2_set_external_build_project_parameters.webp
  • Open the main target from the Targets section and select the Info tab.

../../../_images/xcode_3_configure_scons.webp
  • 按以下设置填写表格:

    参数

    参见 构建系统介绍, 获取完整的参数列表.

    目录

    到Godot根文件夹的完整路径

  • 通过选择 File > New > Target... [文件 > 新建 > 目标...], 添加一个命令行工具目标, 它将用于为项目建立索引.

../../../_images/xcode_4_add_new_target.webp
  • Select macOS > Application > Command Line Tool.

../../../_images/xcode_5_select_command_line_target.webp

备注

为它命名, 以使你知道不使用该目标进行编译(例如 GodotXcodeIndex).

  • 前往新创建的目标(target)的 构建设置(Build Settings) 选项卡, 搜索 标头搜索路径(标头搜索路径) .

  • Header Search Paths 设置为 Godot 根文件夹的绝对路径。子目录也需要包含进来,为此,请在路径末尾添加两个星号(**),例如 /Users/me/repos/godot-source/**

  • 将Godot源码拖放到项目文件浏览器中, 将其添加到项目中.

  • Select Create groups for the Added folders option and check only your command line indexing target in the Add to targets section.

../../../_images/xcode_6_after_add_godot_source_to_project.webp
  • Xcode现在将索引这些文件. 这可能需要几分钟的时间.

  • 一旦Xcode完成了索引, 你应该有跳转定义, 自动完成和完整的语法突出显示.

调试项目

要启用调试支持, 需要编辑外部构建目标的构建和运行方案.

  • 打开外部构建目标的方案编辑器.

  • 定位到 Build > Post Actions 区.

  • 增加一个新的脚本运行操作

  • Provide build settings from [提供构建设置]下选择你的项目. 这允许在脚本中引用项目目录.

  • 创建一个脚本, 给二进制文件起一个Xcode可以识别的名字, 例如:

ln -f ${PROJECT_DIR}/godot/bin/godot.macos.tools.64 ${PROJECT_DIR