From ce0203c4dce969e099aac8fcc043d303f3e3e4a3 Mon Sep 17 00:00:00 2001 From: Flux Date: Sat, 11 Jan 2025 12:30:08 +0200 Subject: [PATCH] Update README.md --- README.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6bbeb3c..a9d288f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,29 @@ -# rust-to-flutter -bash script to cross compile a Rust library to mobile targets and copy the binaries into the correct Flutter directories +### README for `compile_rust_for_flutter.sh` + +This script compiles a Rust library for both Android and iOS and copies the generated libraries to the appropriate Flutter project directories. + +#### Features: +- Compiles Rust for Android using `cargo-ndk` for `arm64-v8a`, `armeabi-v7a`, `x86_64`, and `x86` architectures. +- Conditionally compiles Rust for iOS if running on macOS. +- Automatically cleans the build directory before compiling. +- Copies `.so` (Android) and `.a` (iOS) files to the Flutter project. + +#### Usage: +1. Ensure the following are installed: + - `cargo-ndk`: `cargo install cargo-ndk` + - Android NDK (set `ANDROID_NDK_HOME` or `ANDROID_SDK_ROOT`) + - Rust toolchains for iOS targets if compiling on macOS + +2. Run the script: + ```bash + ./compile_rust_for_flutter.sh + ``` + +#### Example: +```bash +./compile_rust_for_flutter.sh ./rust_project ./flutter_project +``` + +#### Notes: +- Android libraries are copied to `android/app/src/main/jniLibs/`. +- iOS libraries are copied to the `ios` directory.