為 iOS 進行編譯¶
也參考
This page describes how to compile iOS export template binaries from source. If you're looking to export your project to iOS instead, read 為 iOS 匯出.
系統需求¶
編譯¶
開啟終端機,前往 Godot 原始碼的根目錄並輸入:
$ scons p=iphone target=debug
若要建置除錯版,則:
$ scons p=iphone target=release
若要建置釋出版本 (請檢查用於各個設定的 platform/iphone/detect.py
編譯旗標)。
另外,也可以執行
$ scons p=iphone arch=x86_64 target=debug
來執行模擬器。
在最近的新裝置上,如果要上傳至 Apple Store,則 Apple 要求要用 64 位元的應用程式二進位檔。提供 64 位元版本最好的方法就是將 32 位元與 64 位元捆綁在一起,這樣所有裝置都能執行遊戲。
要這麼做,可以分為三個步驟:先編譯 32 位元版本,然後編譯 64 位元版本,接著再使用 lipo
來將這兩個版本捆綁在一起,成為「universal」二進位檔。這幾個步驟可以通過下列指令來進行:
$ scons p=iphone tools=no target=release arch=arm
$ scons p=iphone tools=no target=release arch=arm64
$ lipo -create bin/libgodot.iphone.opt.arm.a bin/libgodot.iphone.opt.arm64.a -output bin/libgodot.iphone.release.fat.a
$ lipo -create bin/libgodot_camera_module.iphone.opt.arm.a bin/libgodot_camera_module.iphone.opt.arm64.a -output bin/libgodot_camera_module.iphone.release.fat.a
$ lipo -create bin/libgodot_arkit_module.iphone.opt.arm.a bin/libgodot_arkit_module.iphone.opt.arm64.a -output bin/libgodot_arkit_module.iphone.release.fat.a
若也想同時提供模擬器建置 (來減少相依性套件造成連結錯誤的機會),則還需要建置 x86_64
架構,並 lipo。
$ scons p=iphone tools=no target=release arch=arm
$ scons p=iphone tools=no target=release arch=arm64
$ scons p=iphone tools=no target=release arch=x86_64
$ lipo -create bin/libgodot.iphone.opt.arm.a bin/libgodot.iphone.opt.arm64.a bin/libgodot.iphone.opt.x86_64.a -output bin/libgodot.iphone.release.fat.a
$ lipo -create bin/libgodot_camera_module.iphone.opt.arm.a bin/libgodot_camera_module.iphone.opt.arm64.a bin/libgodot_camera_module.iphone.opt.x86_64.a -output bin/libgodot_camera_module.iphone.release.fat.a
$ lipo -create bin/libgodot_arkit_module.iphone.opt.arm.a bin/libgodot_arkit_module.iphone.opt.arm64.a bin/libgodot_arkit_module.iphone.opt.x86_64.a -output bin/libgodot_arkit_module.iphone.release.fat.a
執行¶
若要在一台裝置或模擬器上執行,請依照下列指示: 為 iOS 匯出 。
將執行檔取代或新增至 Xcode 專案,接著若有使用其他建置,請更改 Info.plist 中的「executable name」屬性為相應的設定。