How to Target iOS from Rust

Install the iOS target with rustup and build your Rust project using the aarch64-apple-ios target flag to create binaries for iOS devices.

To target iOS from Rust, you must install the iOS target toolchain and configure your build to use the correct architecture and deployment target.

  1. Install the iOS target for your Rust toolchain by running rustup target add aarch64-apple-ios.
  2. Create a Cargo.toml profile for iOS that sets the target and linker flags, adding [profile.release] with lto = true and opt-level = 's' if needed.
  3. Build your library for iOS by running cargo build --release --target aarch64-apple-ios.
  4. Link the resulting .a or .dylib file into your Xcode project using the Other Linker Flags build setting.