Up to date

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

为 iOS 平台编译

参见

这个页面描述的是如何从源码编译 iOS 导出模板二进制。如果你想要找的是导出项目到 iOS,请阅读 为 iOS 导出

需求

If you are building the master branch:

  • 下载并遵循其 README 的说明,以从 MoltenVK SDK <https://github.com/KhronosGroup/MoltenVK#fetching-moltenvk-source-code> 构建静态的 .xcframework

备注

If you have Homebrew installed, you can easily install SCons using the following command:

brew install scons

如果你还没有 Xcode 命令行工具,安装 Homebrew 也会自动进行获取。

Similarly, if you have MacPorts installed, you can easily install SCons using the following command:

sudo port install scons

参见

要获取编译所需的 Godot 源码,请参阅 获取源代码

有关 Godot 的 SCons 用法的一般概述,请参阅 构建系统介绍

编译

打开终端, 转到引擎源代码的根目录并键入:

$ scons p=ios target=template_debug

针对调试版本, 或:

$ scons p=ios target=template_release

for a release build (check platform/ios/detect.py for the compiler flags used for each configuration).

或者, 你可以运行

$ scons p=ios target=template_debug ios_simulator=yes arch=x86_64
$ scons p=ios target=template_debug ios_simulator=yes arch=arm64

for a Simulator libraries.

要创建一个像官方构建的 .app 捆绑包,你需要使用位于 misc/dist/osx_tools.app 的模板。通常,对于用 target=release_debug' 构建的优化编辑器可执行文件。

$ cp -r misc/dist/ios_xcode .

$ cp libgodot.ios.template_debug.arm64.a ios_xcode/libgodot.ios.debug.xcframework/ios-arm64/libgodot.a
$ lipo -create libgodot.ios.template_debug.arm64.simulator.a libgodot.ios.template_debug.x86_64.simulator.a -output ios_xcode/libgodot.ios.debug.xcframework/ios-arm64_x86_64-simulator/libgodot.a

$ cp libgodot.ios.template_release.arm64.a ios_xcode/libgodot.ios.release.xcframework/ios-arm64/libgodot.a
$ lipo -create libgodot.ios.template_release.arm64.simulator.a libgodot.ios.template_release.x86_64.simulator.a -output ios_xcode/libgodot.ios.release.xcframework/ios-arm64_x86_64-simulator/libgodot.a

MoltenVK 的静态 .xcframework 文件夹如果被创建,必须也被放在 ios_xcode 目录里。

运行

要在设备或模拟器上运行, 请按照以下说明操作: 为 iOS 导出.