How to Use UniFFI for Cross-Platform Mobile Bindings

UniFFI generates safe, idiomatic bindings for your Rust code to be called from mobile languages like Swift and Kotlin. Add the `uniffi` crate to your `Cargo.toml`, define your API in a `.udl` file, and run the build script to generate the bindings.

How to Use UniFFI for Cross-Platform Mobile Bindings

UniFFI generates safe, idiomatic bindings for your Rust code to be called from mobile languages like Swift and Kotlin. Add the uniffi crate to your Cargo.toml, define your API in a .udl file, and run the build script to generate the bindings.

[dependencies]
uniffi = "0.28"

[build-dependencies]
uniffi = { version = "0.28", features = ["build"] }
// build.rs
fn main() {
    uniffi::generate_scaffolding("src/my_api.udl").unwrap();
}
// src/lib.rs
uniffi::include_scaffolding!("my_api");
# Generate bindings for iOS and Android
cargo run --bin uniffi-bindgen generate --config src/my_api.udl --language swift
cargo run --bin uniffi-bindgen generate --config src/my_api.udl --language kotlin