How to cross-compile for iOS from Linux

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bluabito

I’ve been trying to build the Godot template for iOS from Linux and I get a bunch of errors.

I am using a docker container for the build but this shouldn’t matter. In fact, the official Godot builds are done via docker too. Since the official documentation for cross-compiling seems very old (uses dmg which is an old format of XCode distribution) I am using the official docker containers of Godot from here as a reference, and I’ve also seen how the build command is actually executed in the build-scripts repository.

You can see my efforts in this repository. Here is what I did:

I am building with this command (using the docker image):

scons -j6 platform=iphone tools=no target=release arch=arm64 IPHONESDK=/ioscross/arm64/SDK/iPhoneOS14.2.sdk IPHONEPATH=/ioscross/arm64 ios_triple=arm-apple-darwin11-

The compiler complains that it cannot find various headers from the iPhone SDK. Here is an excerpt of the error messages (there are a lot more similar to these):

While building module 'AVFoundation' imported from platform/iphone/gl_view.h:31:
While building module 'CoreMedia' imported from /ioscross/arm64/SDK/iPhoneOS14.2.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVAsset.h:20:
In file included from <module-includes>:1:
In file included from /ioscross/arm64/SDK/iPhoneOS14.2.sdk/System/Library/Frameworks/CoreMedia.framework/Headers/CoreMedia.h:15:
/ioscross/arm64/SDK/iPhoneOS14.2.sdk/System/Library/Frameworks/CoreMedia.framework/Headers/CMFormatDescription.h:29:10:{29:2-29:11}: fatal error: could not build module 'CoreVideo' [4]
 #include <CoreVideo/CoreVideo.h>
  ~~~~~~~~^
While building module 'AVFoundation' imported from platform/iphone/gl_view.h:31:
While building module 'UniformTypeIdentifiers' imported from /ioscross/arm64/SDK/iPhoneOS14.2.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVAssetWriter.h:19:
In file included from <module-includes>:1:
In file included from /ioscross/arm64/SDK/iPhoneOS14.2.sdk/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UniformTypeIdentifiers.h:12:
/ioscross/arm64/SDK/iPhoneOS14.2.sdk/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UTTagClass.h:10:9:{10:2-10:10}: fatal error: could not build module 'Foundation' [4]
 #import <Foundation/Foundation.h>
  ~~~~~~~^
While building module 'AVFoundation' imported from platform/iphone/gl_view.h:31:
While building module 'MediaToolbox' imported from /ioscross/arm64/SDK/iPhoneOS14.2.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVAudioMix.h:21:
In file included from <module-includes>:1:
In file included from /ioscross/arm64/SDK/iPhoneOS14.2.sdk/System/Library/Frameworks/MediaToolbox.framework/Headers/MediaToolbox.h:11:
/ioscross/arm64/SDK/iPhoneOS14.2.sdk/System/Library/Frameworks/MediaToolbox.framework/Headers/MTAudioProcessingTap.h:13:10:{13:2-13:11}: fatal error: could not build module 'CoreMedia' [4]
 #include <CoreMedia/CMBase.h>
  ~~~~~~~~^

I have verified that those files are there - all frameworks are there with all their header files. So it seems like there is some issue with the include dirs but then again in the scons configuration files I see nothing different for the includes with regard to native/cross-compiling. So I may be missing something else but I can’t figure out what that might be…

Could someone help with this?