cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.66k stars 372 forks source link

iOS support #72

Closed carllerche closed 2 years ago

carllerche commented 7 years ago

I didn't see any listed iOS support. I thought that I would open an issue for it.

I recently got Mio running iOS CI on Travis. It isn't super generalized, but some of the insights that I discovered could be useful in figuring out how to generalize it.

The iOS CI script is here: https://github.com/carllerche/mio/blob/master/ci/run-ios.sh

The difficulty lies in the fact that a process on iOS must start up a coca application within 20 seconds or the OS will kill the process. Even more fun is that the iOS application must* run on the main thread. This wouldn't be a huge deal except that the rust test runner is pretty limited and also starts on the main thread.

The insight that I had is that you can specify an alternate entry point symbol during the link phase. So, I build a little iOS harness that starts the app then runs the Rust tests.

This could probably be generalized and included in cross.

Alexhuszagh commented 2 years ago

There's support for building iOS targets on MacOS (see [1] in the Supported Targets), but it's likely not legal to provide images to build iOS on other targets.

https://github.com/cross-rs/cross/pull/516#issuecomment-896047293

Additionally, the iPhoneOS SDK should be fetched directly from Apple, as I am not sure of the legality of the GitHub repository this depends upon.

I think it would be possible to extract it from an Xcode copy fetched from Apple using an user-provided Apple developer account. Obviously, as users of the feature must comply with Apple’s terms of service, this whole feature is only to be used on Linux installed on Apple-branded hardware.

Cargo itself can compile for iOS as long as xcrun is installed (IE, on macOS or using a macOS emulator):

cargo build --target aarch64-apple-ios
dvc94ch commented 2 years ago

If you want to cross compile for iOS you should try https://GitHub.com/cloudpeers/xbuild