| Crates.io | kuniffi-generator |
| lib.rs | kuniffi-generator |
| version | 0.2.0 |
| created_at | 2026-01-10 21:49:30.728892+00 |
| updated_at | 2026-01-10 23:47:09.240917+00 |
| description | Generate iOS (.a, .dylib) and Android (.so) libraries from Rust projects with UniFFI |
| homepage | https://github.com/KevalPatel94/KUniffi-Generator |
| repository | https://github.com/KevalPatel94/KUniffi-Generator |
| max_upload_size | |
| id | 2034747 |
| size | 33,537 |
A tool to generate iOS (.a, .dylib) and Android (.so) libraries from Rust projects with UniFFI
Generate native libraries for iOS and Android from your Rust project with a simple command.
cargo install kuniffi-generator
git clone https://github.com/KevalPatel94/KUniffi-Generator.git
cd KUniffi-Generator
cargo install --path .
Make sure ~/.cargo/bin is in your PATH:
export PATH="$HOME/.cargo/bin:$PATH"
cargo install kuniffi-generator
cd /path/to/your/rust/project
Your Cargo.toml should have:
[lib]
name = "mylib"
crate-type = ["cdylib", "staticlib"]
[dependencies]
uniffi = "0.30.0"
[[bin]]
name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"
required-features = ["bindgen-cli"]
[features]
bindgen-cli = ["uniffi/cli"]
Create uniffi-bindgen.rs:
fn main() {
uniffi::uniffi_bindgen_main();
}
In your src/lib.rs, use UniFFI procedural macros:
uniffi::setup_scaffolding!();
#[uniffi::export]
pub fn my_function(x: i32) -> i32 {
x * 2
}
# Build for iOS (generates .a and .dylib files)
kuniffi-build ios
# Build for Android (generates .so files)
kuniffi-build android
# Build for both platforms
kuniffi-build both
# Specify package name explicitly (if auto-detection fails)
kuniffi-build ios mylib
The tool will automatically detect your package name from Cargo.toml if not specified.
kuniffi-build <ios|android|both> [package-name]
ios - Build iOS libraries (.a and .dylib files)android - Build Android libraries (.so files)both - Build for both iOS and Androidpackage-name - Optional Rust package name (auto-detected from Cargo.toml if not provided)After building, libraries are generated in:
iOS:
bindings/ios/
├── aarch64-apple-ios/
│ ├── libmylib.a
│ └── libmylib.dylib
├── aarch64-apple-ios-sim/
│ ├── libmylib.a
│ └── libmylib.dylib
└── x86_64-apple-ios/
├── libmylib.a
└── libmylib.dylib
Android:
bindings/android/jniLibs/
├── arm64-v8a/
│ └── libmylib.so
├── armeabi-v7a/
│ └── libmylib.so
├── x86/
│ └── libmylib.so
└── x86_64/
└── libmylib.so
cargo-ndk and Android NDKrustup target add aarch64-apple-ios
rustup target add aarch64-apple-ios-sim
rustup target add x86_64-apple-ios
cargo install cargo-ndk
rustup target add aarch64-linux-android
rustup target add armv7-linux-androideabi
rustup target add i686-linux-android
rustup target add x86_64-linux-android
The tool will automatically install missing Rust targets during the build process.
See the examples/calculator directory for a complete working example:
cd examples/calculator
kuniffi-build ios
kuniffi-build android
Cargo.tomlbindings/ directoryAll builds use release mode for optimized, production-ready libraries.
Make sure ~/.cargo/bin is in your PATH:
export PATH="$HOME/.cargo/bin:$PATH"
# Add to ~/.bashrc or ~/.zshrc for persistence
cargo install cargo-ndk
Either specify the package name explicitly:
kuniffi-build ios mylib
Or ensure Cargo.toml exists in the current directory with a valid [package] section.
Make sure the Rust target is installed:
rustup target list --installed
rustup target add <target-name>
The tool will attempt to auto-install missing targets, but manual installation may be needed in some cases.
MIT