Нема описа

README.md 1.2KB

rust-on-ios

This is a quick proof-of-concept for a bitcode-enabled library built from Rust intended for consumption in an iOS app built in Unity (2018.4.11f1)

Unity defaults to embedding bitcode meaning all static dependencies must do likewise. Rust, by default, does not embed bitcode for static library targets. We can use -C lto -Z embed-bitcode to ask Rust to embed bitcode (afaict -C lto is required because the shipped iOS rust-std libs also need to embed bitcode.)

Naturally both Rust and Apple have forked LLVM and they are not always in-sync which is the current major problem outlined here. For Xcode 11.1 the latest Rust version we can use is nightly-2019-07-17.

Building

  • cd librusty
  • cargo install cargo-lipo
  • rustup target add aarch64-apple-ios
  • cargo lipo --targets aarch64-apple-ios --release
  • cp target/universal/release/librusty.a ../unity/Assets/Plugins/iOS/librusty.a

So, what?

Until Rust officially decides to support bitcode we have to jump through hoops in order to do so:

  • We must use a specific (nightly) compiler version
  • Xcode betas/updates may break linkability of our static library
  • Downstream developers may not all be on the same (latest) version of Xcode