Skip to content

Instantly share code, notes, and snippets.

@thewh1teagle
Last active November 28, 2024 16:12
Show Gist options
  • Save thewh1teagle/794add8801e7c0923042ff877b179ee5 to your computer and use it in GitHub Desktop.
Save thewh1teagle/794add8801e7c0923042ff877b179ee5 to your computer and use it in GitHub Desktop.
Build for Android and IOS in Rust

Prepare project

mkdir project
cd project
cargo init --lib

Edit Cargo.toml and add

[lib]
crate-type = ["dylib"]

Android

rustup target add aarch64-linux-android
cargo install cargo-ndk
export ANDROID_NDK_HOME="$HOME/Library/Android/sdk/ndk/27.0.12077973"
export NDK_HOME=$ANDROID_NDK_HOME
cargo ndk -t arm64-v8a -o ./jniLibs build --release

IOS

xcode-select --install
rustup target add aarch64-apple-ios
cargo build --target aarch64-apple-ios --release
# Intel emulator
rustup target add x86_64-apple-ios
cargo build --target x86_64-apple-ios --release

# Silicon chip emulator
rustup target add aarch64-apple-ios-sim
cargo build --target aarch64-apple-ios-sim --release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment