diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d5dfc8..d663d53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,17 +33,12 @@ jobs: - uses: actions/checkout@v2 with: lfs: true - - uses: actions/setup-java@v2 + - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 11 + java-version: '17' cache: 'gradle' # Reference: https://github.com/mozilla/rust-android-gradle/blob/master/.github/workflows/check.yml - - name: Setup Android SDK - uses: android-actions/setup-android@v2 - - uses: nttld/setup-ndk@v1 - with: - ndk-version: r21e - uses: actions-rs/toolchain@v1 # Reference: https://github.com/rust-windowing/android-ndk-rs/blob/master/.github/workflows/rust.yml with: @@ -54,8 +49,5 @@ jobs: run: | make prepare-android - name: "Build Android library" - env: - ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} - run: | - cd hello - make android + run: make android + working-directory: hello diff --git a/Makefile b/Makefile index 9238113..aa6f524 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ prepare-apple: rustup toolchain install nightly rustup target add aarch64-apple-ios-sim --toolchain nightly && rustup target add aarch64-apple-ios x86_64-apple-ios rustup component add rust-src --toolchain nightly - make install-uniffi-bindgen prepare-android: rustup toolchain install stable @@ -12,7 +11,3 @@ prepare-android: rustup target add aarch64-linux-android rustup target add armv7-linux-androideabi rustup target add i686-linux-android - make install-uniffi-bindgen - -install-uniffi-bindgen: - cargo install uniffi_bindgen --version 0.17.0 \ No newline at end of file diff --git a/README.md b/README.md index bef09b2..cd5cf6d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Please read . ### iOS -1. Latest Xcode (13.x) +1. Latest Xcode (14.3) 1. Rust toolchains for iOS: `make prepare-apple` or `rustup target add aarch64-apple-ios-sim --toolchain nightly && rustup target add aarch64-apple-ios x86_64-apple-ios`. Check installaion: ```shell $ rustup target list --installed | grep ios diff --git a/hello/Cargo.toml b/hello/Cargo.toml index 6c5ae92..ab5d61c 100644 --- a/hello/Cargo.toml +++ b/hello/Cargo.toml @@ -8,14 +8,18 @@ version = "0.1.0" crate-type = ["staticlib", "cdylib"] name = "hello" +[[bin]] +name = "uniffi-bindgen" +path = "bin/uniffi-bindgen.rs" + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -uniffi = "0.22.0" -uniffi_macros = "0.22.0" +uniffi = "0.23.0" +uniffi_macros = "0.23.0" [build-dependencies] -uniffi_build = "0.22.0" +uniffi = { version = "0.23.0", features = [ "build" ] } [profile.release] codegen-units = 1 # Reduce number of codegen units to increase optimizations. diff --git a/hello/Makefile b/hello/Makefile index e158c89..c0059b6 100644 --- a/hello/Makefile +++ b/hello/Makefile @@ -8,18 +8,18 @@ apple: @make cp-xcframeowrk-source build-targets: - cargo build --release --target x86_64-apple-ios - cargo +nightly build --release --target aarch64-apple-ios-sim - cargo +nightly build -Z build-std --release --target aarch64-apple-ios-macabi - cargo +nightly build -Z build-std --release --target x86_64-apple-ios-macabi - cargo build --release --target aarch64-apple-ios + cargo build --lib --release --target x86_64-apple-ios + cargo +nightly build --lib --release --target aarch64-apple-ios-sim + cargo +nightly build -Z build-std --lib --release --target aarch64-apple-ios-macabi + cargo +nightly build -Z build-std --lib --release --target x86_64-apple-ios-macabi + cargo build --lib --release --target aarch64-apple-ios bindgen-swift: - uniffi-bindgen generate src/hello.udl --language swift + cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/hello.udl --language swift sed -i '' 's/module\ HelloFFI/framework\ module\ HelloFFI/' src/HelloFFI.modulemap bindgen-kotlin: - uniffi-bindgen generate src/hello.udl --language kotlin -o platforms/android/UniffiRustExample/app/src/main/java + cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/hello.udl --language kotlin -o platforms/android/UniffiRustExample/app/src/main/java sed -i '' 's/return "uniffi_Hello"/return "hello"/' platforms/android/UniffiRustExample/app/src/main/java/uniffi/Hello/Hello.kt assemble-frameworks: diff --git a/hello/bin/uniffi-bindgen.rs b/hello/bin/uniffi-bindgen.rs new file mode 100644 index 0000000..f6cff6c --- /dev/null +++ b/hello/bin/uniffi-bindgen.rs @@ -0,0 +1,3 @@ +fn main() { + uniffi::uniffi_bindgen_main() +} diff --git a/hello/build.rs b/hello/build.rs index de213cd..d6610a1 100644 --- a/hello/build.rs +++ b/hello/build.rs @@ -1,3 +1,3 @@ fn main() { - uniffi_build::generate_scaffolding("./src/hello.udl").unwrap(); + uniffi::generate_scaffolding("./src/hello.udl").unwrap(); } diff --git a/hello/platforms/android/UniffiRustExample/app/build.gradle b/hello/platforms/android/UniffiRustExample/app/build.gradle index 041fa8b..613b3d5 100644 --- a/hello/platforms/android/UniffiRustExample/app/build.gradle +++ b/hello/platforms/android/UniffiRustExample/app/build.gradle @@ -10,11 +10,12 @@ cargo { module = "../../../.." // Or whatever directory contains your Cargo.toml libname = "hello" // Or whatever matches Cargo.toml's [package] name. targets = ["arm", "x86", "x86_64", "arm64"] + extraCargoBuildArguments = ["--lib"] } android { compileSdk 31 -// ndkVersion rootProject.ext.ndkVersion + ndkVersion "25.2.9519653" defaultConfig { applicationId "com.demo.mobile.uniffirustexample" @@ -42,6 +43,7 @@ android { buildFeatures { viewBinding true } + namespace 'com.example.mobile.demo.uniffirustexample' } dependencies { diff --git a/hello/platforms/android/UniffiRustExample/app/src/main/AndroidManifest.xml b/hello/platforms/android/UniffiRustExample/app/src/main/AndroidManifest.xml index 79ee800..d367a75 100644 --- a/hello/platforms/android/UniffiRustExample/app/src/main/AndroidManifest.xml +++ b/hello/platforms/android/UniffiRustExample/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - +