Template for creating cross-platform Rust libraries as iOS/macOS/tvOS/watchOS Swift frameworks.
Install Rust via Rustup
$ curl https://sh.rustup.rs -sSf | sh
If you want Bitcode support (required for tvOS and watchOS) you'll need to use a Rust nightly 1.2.7+ build (as of 4-27-2018).
$ rustup toolchain install nightly
$ rustup default nightly
Install the iOS targets for your selected toolchain:
$ rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios
Install cargo-lipo
$ cargo install cargo-lipo
VS Code offers an IDE-like experiene for developing your Rust code, including some rough LLDB debugging support.
- VS Code
- rls-vscode (code completion)
- vscode-lldb (debugging)
The src folder contains all of our Rust library source code (.rs
) and a manually created C header file (example.h
) exporting a few symbols of interest from our Rust code. The build output is a static library called libexample.a
.
This framework is a lightweight wrapper that simply includes the libexample.a
library and example.h
header.
This framework builds a higher level Swift API on top of ExampleCore.framework
.
- cargo-lipo - Cargo subcommand to automatically create universal libraries for iOS.
- rust-to-ios - Example project for building a library for iOS in Rust.
- rust-ios-android - Example project for building Rust library for iOS and Android
MIT