All Projects β†’ kennytm β†’ Rust Ios Android

kennytm / Rust Ios Android

Licence: apache-2.0
Example project for building a library for iOS + Android in Rust.

Programming Languages

shell
77523 projects
rust
11053 projects

Projects that are alternatives of or similar to Rust Ios Android

Heim
Cross-platform async library for system information fetching πŸ¦€
Stars: ✭ 572 (-8.63%)
Mutual labels:  cross-platform
Caesium Image Compressor
Caesium is a cross-platform image compression software aimed at helping photographers, bloggers, webmasters, businesses or casual users at storing, sending and sharing digital pictures. Based on libcaesium.
Stars: ✭ 595 (-4.95%)
Mutual labels:  cross-platform
Cross Env
πŸ”€ Cross platform setting of environment scripts
Stars: ✭ 5,623 (+798.24%)
Mutual labels:  cross-platform
Python Mss
An ultra fast cross-platform multiple screenshots module in pure Python using ctypes.
Stars: ✭ 582 (-7.03%)
Mutual labels:  cross-platform
Colfer
binary serialization format
Stars: ✭ 597 (-4.63%)
Mutual labels:  cross-platform
Seqkit
A cross-platform and ultrafast toolkit for FASTA/Q file manipulation in Golang
Stars: ✭ 607 (-3.04%)
Mutual labels:  cross-platform
Csvtk
A cross-platform, efficient and practical CSV/TSV toolkit in Golang
Stars: ✭ 566 (-9.58%)
Mutual labels:  cross-platform
Swiftfoundation
Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. (Pure Swift, Supports Linux)
Stars: ✭ 623 (-0.48%)
Mutual labels:  cross-platform
Xamarin.forms
Xamarin.Forms Official Home
Stars: ✭ 5,485 (+776.2%)
Mutual labels:  cross-platform
Guilite
βœ”οΈThe smallest header-only GUI library(4 KLOC) for all platforms
Stars: ✭ 5,841 (+833.07%)
Mutual labels:  cross-platform
Poco
The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
Stars: ✭ 5,762 (+820.45%)
Mutual labels:  cross-platform
Goblin
An impish, cross-platform binary parsing crate, written in Rust
Stars: ✭ 591 (-5.59%)
Mutual labels:  cross-platform
Usockets
Miniscule cross-platform eventing, networking & crypto for async applications
Stars: ✭ 611 (-2.4%)
Mutual labels:  cross-platform
Server
Mangos ZERO is a server for World of Warcraft. The server serves full world content including authentication & scripts support. Compatible with World of Warcraft clients 1.12.1-1.12.3 - Report all issues at https://www.getmangos.eu/bug-tracker/mangos-zero/
Stars: ✭ 578 (-7.67%)
Mutual labels:  cross-platform
Capacitor
Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚑️
Stars: ✭ 6,598 (+953.99%)
Mutual labels:  cross-platform
React Native Dialogs
React Native wrappers for https://github.com/afollestad/material-dialogs
Stars: ✭ 568 (-9.27%)
Mutual labels:  cross-platform
Arxlibertatis
Cross-platform port of Arx Fatalis, a first-person role-playing game
Stars: ✭ 602 (-3.83%)
Mutual labels:  cross-platform
Liteapp
LiteApp is a high performance mobile cross-platform implementation, The realization of cross-platform functionality is base on webview and provides different ideas and solutions for improve webview performance.
Stars: ✭ 626 (+0%)
Mutual labels:  cross-platform
Tvision
A modern port of Turbo Vision 2.0, the classical framework for text-based user interfaces. Now cross-platform and with Unicode support.
Stars: ✭ 612 (-2.24%)
Mutual labels:  cross-platform
Notes
Note-taking application, write down your thoughts.
Stars: ✭ 612 (-2.24%)
Mutual labels:  cross-platform

rust-ios-android

Build status

Example project for building a library for iOS + Android in Rust. macOS is required for iOS development.

  • βœ“ Rust 1.20 – 1.25
  • βœ“ Android 4.1 – 8.1 (Jelly Bean – Oreo) (API 16–27)
  • βœ“ iOS 7 – 11

(probably works on earlier versions but I don't bother to check πŸ˜›)

Note: The purpose of this project is not to create a pure Rust app, but rather use Rust as a shared native component between the mobile platforms.

You may also want to check https://github.com/Geal/rust_on_mobile.

Setup

  1. Install the common build tools like C compiler and linker. On macOS, get Xcode, and install the command line tools.

    xcode-select --install
    
  2. Get Android NDK. We recommend installing it via Android Studio or sdkmanager:

    sdkmanager --verbose ndk-bundle
    

    Otherwise, please define the environment variable $ANDROID_NDK_HOME to the path of the current version of Android NDK.

    export ANDROID_NDK_HOME='/usr/local/opt/android-ndk/android-ndk-r14b/'
    
  3. Create the standalone NDKs.

    ./create-ndk-standalone.sh
    
  4. Download rustup. We will use this to setup Rust for cross-compiling.

    curl https://sh.rustup.rs -sSf | sh
    
  5. Download targets for iOS and Android.

    # iOS. Note: you need *all* five targets
    rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios
    
    # Android.
    rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android
    
  6. Copy the content of cargo-config.toml (consists of linker information of the Android targets) to ~/.cargo/config

    cat cargo-config.toml >> ~/.cargo/config
    
  7. Install cargo-lipo to generate the iOS universal library.

    cargo install cargo-lipo
    

Creating the libraries

You use use the sample/ project as an example. (Note that the sample itself does not contain proper error checking.)

  1. Write the library and expose a C interface. See the FFI chapter in the Rust Book for an introduction.

  2. Expose the Java interface with JNI when target_os="android".

  3. Build the libraries.

    cd sample/cargo
    
    # iOS
    cargo lipo --release
    
    # Android
    cargo build --target aarch64-linux-android --release
    cargo build --target armv7-linux-androideabi --release
    cargo build --target i686-linux-android --release
    
    cd ../..
    
  4. Build the Xcode project.

    cd sample/ios
    xcodebuild -configuration Release -scheme RustSample | xcpretty
    cd ../..
    

    When you create an Xcode project yourself, note the following points:

    • Add the C header rust_regex.h to allow using the Rust functions from C.
    • Copy target/universal/release/lib???.a to the project. You may need to modify LIBRARY_SEARCH_PATHS to include the folder of the *.a file.
    • Note that cargo-lipo does not generate bitcode yet. You must set ENABLE_BITCODE to NO. (See also http://stackoverflow.com/a/38488617)
    • You need to link to libresolv.tbd.
  5. Build the Android project.

    cd sample/android
    ./gradlew assembleRelease
    cd ../..
    

    When you create an Android Studio project yourself, note the following points:

    • Copy or link the *.so into the corresponding src/main/jniLibs folders:

      Copy from Rust Copy to Android
      target/armv7-linux-androideabi/release/lib???.so src/main/jniLibs/armeabi-v7a/lib???.so
      target/aarch64-linux-android/release/lib???.so src/main/jniLibs/arm64-v8a/lib???.so
      target/i686-linux-android/release/lib???.so src/main/jniLibs/x86/lib???.so
    • Don't forget to ensure the JNI glue between Rust and Java are compatible.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].