GithubHelp home page GithubHelp logo

ramyareye / cargo-mobile Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tauri-apps/cargo-mobile2

1.0 1.0 0.0 1.32 MB

Rust on mobile made easy!

License: Apache License 2.0

Shell 0.13% C++ 0.02% Rust 92.93% PowerShell 0.11% Objective-C++ 0.02% HTML 0.06% Handlebars 6.73%

cargo-mobile's Introduction

cargo-mobile

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!

Check out the announcement post!

Status

Everything here works and is already used internally! However, this hasn't seen a lot of external use yet, so there could still be some rough edges.

Building for iOS is broken on Rust 1.46.0, 1.47.0, and 1.48.0!

Sorry for the inconvenience! This is resolved in Rust 1.49.0, so please use 1.49 or higher.

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-mobile

cargo-mobile 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
wry Minimal wry project
tauri Minimal tauri 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.

cargo-mobile's People

Contributors

amrbashir avatar arthurkvalladares avatar cactice avatar davidkern avatar expectocode avatar francesca64 avatar inokawa avatar jhutchins avatar kazatsuyu avatar keiya01 avatar lucasfernog avatar msiglreith avatar mtak- avatar mworleybr avatar ramyareye avatar spensbot avatar trindadegm avatar wusyong avatar zeerooth avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.