Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
在 Linux 平台上为 iOS 做交叉编译¶
The procedure for this is somewhat complex and requires a lot of steps, but once you have the environment properly configured you can compile Godot for iOS anytime you want.
免责声明¶
While it is possible to compile for iOS on a Linux environment, Apple is very restrictive about the tools to be used (especially hardware-wise), allowing pretty much only their products to be used for development. So this is not official. However, in 2010 Apple said they relaxed some of the App Store review guidelines to allow any tool to be used, as long as the resulting binary does not download any code, which means it should be OK to use the procedure described here and cross-compiling the binary.
需求¶
XCode with the iOS SDK (a dmg image, for newer versions a xip file is going to be downloaded.)
Clang >= 3.5 for your development machine installed and in the
PATH
. It has to be version >= 3.5 to targetarm64
architecture.Fuse for mounting and unmounting the dmg image.
darling-dmg, 需要从源码构建. 下面说明其过程.
要构建darling-dmg, 你需要以下库的开发包:fuse,icu,openssl,zlib,bzip2.
For building xar and pbzx you may want to follow this guide.
cctools-port 用于所需的构建工具. 构建过程非常特殊, 下面将进行描述.
这也有一些额外的依赖:automake,autogen,libtool.
配置环境¶
darling-dmg¶
在你的机器上克隆该仓库:
$ git clone https://github.com/darlinghq/darling-dmg.git
构建它:
$ cd darling-dmg
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Release
$ make -j 4 # The number is the amount of cores your processor has, for faster build
$ cd ../..
准备 SDK¶
挂载 XCode 镜像:
$ mkdir xcode
$ ./darling-dmg/build/darling-dmg /path/to/Xcode_7.1.1.dmg xcode
[...]
Everything looks OK, disk mounted
For newer versions you should extract the xip file:
$ mkdir xcode
$ xar -xf /path/to/Xcode_X.x.xip -C xcode
$ pbzx -n Content | cpio -i
[...]
######### Blocks
Note that for the commands below, you may need to replace the version (X.x) with whatever iOS SDK version you're using.
解压缩 iOS SDK:
$ # If you don't know your iPhone SDK version you can see the json file inside of Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
$ mkdir -p iPhoneSDK/iPhoneOSX.x.sdk
$ cp -r xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/* iPhoneSDK/iPhoneOSX.x.sdk
$ cp -r xcode/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/* iPhoneSDK/iPhoneOSX.x.sdk/usr/include/c++
$ fusermount -u xcode # unmount the image
打包 SDK:
$ cd iPhoneSDK
$ tar -cf - * | xz -9 -c - > iPhoneOSX.x.sdk.tar.xz
工具链¶
构建 cctools:
$ git clone https://github.com/tpoechtrager/cctools-port.git
$ cd cctools-port/usage_examples/ios_toolchain
$ ./build.sh /path/iPhoneOSX.x.sdk.tar.xz arm64
将工具复制到更好的位置. 请注意, 用于构建的SCons脚本将在你为工具链二进制文件提供的目录中的 usr/bin
下查找, 因此, 你必须复制到这样的子目录, 类似于以下命令:
$ mkdir -p /home/user/iostoolchain/usr
$ cp -r target/bin /home/user/iostoolchain/usr/
现在你应该在 /home/user/iostoolchain/usr/bin
中拥有iOS工具链二进制文件.
为 iPhone 编译 Godot¶
完成上述步骤后, 应在环境中保留两件事: 构建的工具链和iPhoneOS SDK目录. 那些可以留在你想要的任何地方, 因此你必须提供它们的路径给SCons构建命令.
为了检测iPhone平台, 你需要将 OSXCROSS_IOS
环境变量定义为 anything
.
$ export OSXCROSS_IOS=anything
现在你可以使用SCons像标准Godot方式一样编译iPhone, 带有一些其他参数以提供正确的路径:
$ scons -j 4 platform=ios arch=arm64 target=template_release IOS_SDK_PATH="/path/to/iPhoneSDK" IOS_TOOLCHAIN_PATH="/path/to/iostoolchain" ios_triple="arm-apple-darwin11-"