cargo-mobile2

Rust on mobile made easy!

Latest version: 0.20.1 registry icon
Maintenance score
100
Safety score
100
Popularity score
88
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
0.20.1 0 0 0 0 0
0.20.0 0 0 0 0 0
0.19.0 0 0 0 0 0
0.18.1 0 0 0 0 0
0.18.0 0 0 0 0 0
0.17.6 0 0 0 0 0
0.17.5 0 0 0 0 0
0.17.4 0 0 0 0 0
0.17.3 0 0 0 0 0
0.17.2 0 0 0 0 0
0.17.1 0 0 0 0 0
0.17.0 0 0 0 0 0
0.16.0 0 0 0 0 0
0.15.1 0 0 0 0 0
0.15.0 0 0 0 0 0
0.14.0 0 0 0 0 0
0.13.5 0 0 0 0 0
0.13.4 0 0 0 0 0
0.13.3 0 0 0 0 0
0.13.2 0 0 0 0 0
0.13.1 0 0 0 0 0
0.13.0 0 0 0 0 0
0.12.2 0 0 0 0 0
0.12.1 0 0 0 0 0
0.12.0 0 0 0 0 0
0.11.1 0 0 0 0 0
0.11.0 0 0 0 0 0
0.10.4 0 0 0 0 0
0.10.3 0 0 0 0 0
0.10.2 0 0 0 0 0
0.10.1 0 0 0 0 0
0.10.0 0 0 0 0 0
0.9.1 0 0 0 0 0
0.9.0 0 0 0 0 0
0.8.0 0 0 0 0 0
0.7.0 0 0 0 0 0
0.6.0 0 0 0 0 0
0.5.4 0 0 0 0 0
0.1.0 0 0 0 0 0

Stability
Latest release:

0.20.1 - This version is safe to use because it has no known security vulnerabilities at this time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

Apache-2.0   -   Apache License 2.0

Not a wildcard

Not proprietary

OSI Compliant


MIT   -   MIT License

Not a wildcard

Not proprietary

OSI Compliant



cargo-mobile2

Maintenance Status

This fork was created for use as a base for mobile support in Tauri. Due to very limited resources we can only provide maintenance for that single use-case.

We currently cannot offer support or fix issues for uses outside of Tauri.

If you face issues with Tauri, please open an issue in Tauri's issue tracker even if you tracked down the issue to cargo-mobile2.

That said, contributions are still very welcome and if you're interested in helping us maintain this crate, please reach out to us in the #contributing channel on the Tauri Discord.

Introduction

The answer to "how do I use Rust on iOS and Android?"

cargo-mobile takes care of generating Xcode and Android Studio project files, building and running on device, generating project boilerplate, and a few other things!

This project is a fork of cargo-mobile. Tauri uses it as a library dependency instead of using its CLI directly. For more information, please visit Tauri's prerequisites and development guides.

In the meantime, cargo-mobile2 contains the template of wry, please follow wry's instruction if you want to use with it.

Installation

The build will probably take a bit, so feel free to go get a snack or something.

cargo install --git https://github.com/tauri-apps/cargo-mobile2

cargo-mobile2 is currently supported on macOS, Linux and Windows. Note that it's not possible to target iOS on platforms other than macOS! You'll still get to target Android either way.

You'll need to have Xcode and the Android SDK/NDK installed. Some of this will ideally be automated in the future, or at least we'll provide a helpful guide and diagnostics.

Whenever you want to update:

cargo mobile update

Usage

To start a new project, all you need to do is make a directory with a cute name, cd into it, and then run this command:

cargo mobile init

After some straightforward prompts, you'll be asked to select a template pack. Template packs are used to generate project boilerplate, i.e. using the wry template pack gives you a wry project that runs out-of-the-box on desktop and mobile.

name info
bevy Minimal Bevy application rendering a static sprite
bevy-demo Minimal 2d Bevy application with a controlable sprite and some audio
dioxus Hello world Dioxus example
egui Full egui + winit + wgpu example based on agdk-egui example
wgpu wgpu-rs triangle example
winit winit window example
wry Minimal wry project

Template pack contribution is welcomed

Once you've generated your project, you can run cargo run as usual to run your app on desktop. However, now you can also do cargo apple run and cargo android run to run on connected iOS and Android devices respectively!

If you prefer to work in the usual IDEs, you can use cargo apple open and cargo android open to open your project in Xcode and Android Studio respectively.

For more commands, run cargo mobile, cargo apple, or cargo android to see help information.

Android

cargo android run will build, install and run the app and follows device logs emitted by the app.

By default, warn and error logs are displayed. Additional logging of increasing verbosity can be shown by use of the -v or -vv options. These also provide more verbose logging for the build and install steps.

For fine-grained control of logging, use the --filter (or -f) option, which takes an Android log level, such as debug. This option overrides the default device logging level set by -v or -vv.

If using the android_logger crate to handle Rust log messages, trace logs from Rust are mapped to verbose logs in Android.