

Xi editorĪ text editor with a lot of frontends: MacOS, GTK, Electron and Windows, among others. "Real world" examples CoEpiĪ mobile contact tracing app for epidemics, with Android and iOS frontends. This simplifies the FFI/JNI interfaces (see the CoEpi example, where the apps add concurrency via RxSwift/RxJava). While it's possible to use asynchronous code in core, it's recommended to use blocking apis and add concurrency in the apps. The iOS build is distributed directly as a binary (no wrapper), using Carthage. The Android build contains a wrapper library, which is imported in the Android app with Gradle. This makes working with this dependency like with regular third parties.Īn example for this and the binary approaches can be found here. Here the external dependency contains the Rust binary and wrapper libraries for Android and iOS respectively (written in Kotlin and Swift), which hide the FFI/JNI, providing a simple and safe interface to the apps. Note: it is possible to overwrite the external dependency with a local copy for local development. Rust binaries have to be versioned and released.

Everyone works mainly with their familiar tech stack.īetter separation of concerns / modularity.Ĭonsiderably more complicated to setup than monorepo (has to be done only once though). The Rust binary is distributed as an external dependency.īetter for teams with different skillsets. Not ideal if there are team members unfamiliar with Rust. Rust is built as part of the app's build process.

There are different ways to integrate Rust: As source (like in this repo) TODO move it to a folder android_app, like the iOS app. You even can reuse your core for a web-app, using WebAssembly, or desktop app (where again, you can use native or a cross-platform framework like Electron). For example, you can develop your MVP with Rust+React Native or Rust+Flutter, and migrate later to native iOS/Android, without having to rewrite everything. It's also very flexible, allowing to migrate easily between different platforms, including conventional cross-platform frameworks like Flutter or React Native. We keep a fully native UI experience and uncomplicated access to the latest APIs of the platforms. Rust, as a highly performant and safe language is a great fit for mobile. This approach gives us the best of all worlds: we prevent code duplication by using a shared library. If you want to help, just open an issue, or email me Why?

This is an example that shows how to use a shared Rust core in native Android and iOS apps. Rust core for native Android and iOS apps
