Up to date

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

Экспорт для iOS

См.также

This page describes how to export a Godot project to iOS. If you're looking to compile export template binaries from source instead, read Compiling for iOS.

Это шаги для загрузки проекта Godot в Xcode. Это позволяет вам создавать и развёртывать на устройстве iOS, создавать выпуск для App Store и делать всё остальное, что вы обычно можете делать с Xcode.

Внимание

Проекты, написанные на C#, можно экспортировать в Android, начиная с Godot 4.2, но поддержка является экспериментальной и присутствуют некоторые ограничения.

Требования

  • Вы должны экспортировать для iOS с компьютера под управлением macOS с установленным Xcode.

  • Загрузите шаблоны экспорта Godot. Используйте меню Godot: Editor > Manage Export Templates (Редактор> Управление шаблонами экспорта)

Экспорт проекта Godot в Xcode

В редакторе Godot откройте окно Export (Экспорт) из меню Project (Проект). Когда откроется окно экспорта, нажмите Add.. (Добавить..) и выберите iOS.

Требуются следующие параметры экспорта: App Store Team ID и**Identifier** в категории Application. Если их не заполнить, экспортёр выдаст ошибку.

Примечание

If you encounter an error during export similar to
JSON text did not start with array or object and option to allow fragments not set
then it might be due to a malformated App Store Team ID!
The exporter expects a (10 characters long) code like ABCDE12XYZ and not, e.g., your name as Xcode likes to display in the Signing & Capabilities tab.
You can find the code over at developer.apple.com next to your name in the top right corner.

После того, как вы нажмете Export Project (экспорт проекта), останутся два важных параметра:

  • Path (Путь) - это пустая папка, которая будет содержать экспортированные файлы проекта Xcode.

  • File (Файл) будет именем проекта Xcode и нескольких файлов и каталогов, относящихся к проекту.

../../_images/ios_export_file.png

Примечание

В этом руководстве используется exported_xcode_project_name, но вы будете использовать имя вашего проекта. Когда вы увидите exported_xcode_project_name на следующих шагах, замените его именем, которое вы использовали вместо этого.

Примечание

Избегайте использования пробелов при выборе exported_xcode_project_name, так как это может привести к повреждению вашего файла проекта XCode.

Когда экспорт завершится, выходная папка должна выглядеть так:

../../_images/ios_export_output.png

Открытие exported_xcode_project_name.xcodeproj позволяет создавать и развёртывать, как и любое другое приложение iOS.

Действующие соглашения о разработке

Вышеупомянутый метод создаёт экспортированный проект, который вы можете создать для выпуска, но вам придется повторно экспортировать каждый раз, когда вы вносите изменения в Godot.

Во время разработки вы можете ускорить этот процесс, связав файлы проекта Godot непосредственно с вашим приложением.

В следующем примере:

  • exported_xcode_project_name - имя экспортированного приложения iOS (как указано выше).

  • godot_project_to_export - это название проекта Godot.

Примечание

godot_project_to_export не должен совпадать с exported_xcode_project_name для предотвращения проблем с подписью в Xcode.

Плагины для iOS

В Godot можно использовать специальные iOS плагины. Посетите страницу doc_services_for_ios.

Environment variables

You can use the following environment variables to set export options outside of the editor. During the export process, these override the values that you set in the export menu.

iOS export environment variables

Export option

Environment variable

Encryption / Encryption Key

GODOT_SCRIPT_ENCRYPTION_KEY

Options / Application / Provisioning Profile UUID Debug

GODOT_IOS_PROVISIONING_PROFILE_UUID_DEBUG

Options / Application / Provisioning Profile UUID Release

GODOT_IOS_PROVISIONING_PROFILE_UUID_RELEASE

Устранение неполадок

xcode-select points at wrong SDK location

xcode-select is a tool that comes with Xcode and among other things points at iOS SDKs on your Mac. If you have Xcode installed, opened it, agreed to the license agreement, and installed the command line tools, xcode-select should point at the right location for the iPhone SDK. If it somehow doesn't, Godot will fail exporting to iOS with an error that may look like this:

MSB3073: The command ""clang" <LOTS OF PATHS AND COMMAND LINE ARGUMENTS HERE>
"/Library/Developer/CommandLineTools/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"" exited with code 1.

In this case, Godot is trying to find the Platforms folder containing the iPhone SDK inside the /Library/Developer/CommandLineTools/ folder, but the Platforms folder with the iPhone SDK is actually located under /Applications/Xcode.app/Contents/Developer. To verify this, you can open up Terminal and run the following command to see what xcode-select points at:

xcode-select -p

To fix xcode-select pointing at a wrong location, enter this command in Terminal:

sudo xcode-select -switch /Applications/Xcode.app

After running this command, Godot should be able to successfully export to iOS.