• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

BrainiumLLC/cargo-mobile: Rust on mobile made easy!

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

BrainiumLLC/cargo-mobile

开源软件地址(OpenSource Url):

https://github.com/BrainiumLLC/cargo-mobile

开源编程语言(OpenSource Language):

Rust 90.4%

开源软件介绍(OpenSource 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 update to that if you haven't already:

rustup update stable
rustup default stable

Installation

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

cargo install --git https://github.com/BrainiumLLC/cargo-mobile

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

A PR adding Windows support would be hugely appreciated!

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 bevy template pack gives you a minimal Bevy project that runs out-of-the-box on desktop and mobile.

name info
bevy Minimal Bevy project derived from sprite example
bevy-demo Bevy breakout demo
wgpu Minimal wgpu project derived from hello-triangle example
winit Minimal winit project derived from window example

Template pack contribution is encouraged; we'd love to have very nice template packs for Bevy, Amethyst, and whatever else people find helpful! We'll write up a guide for template pack creation soon, but in the mean time, the existing ones are a great reference point. Any template pack placed into ~./cargo-mobile/templates/apps/ will appear as an option in cargo mobile init.

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

Building for Android is broken on NDK >= 23

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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
gomatcha/matcha: Build native mobile apps in Go.发布时间:2022-08-30
下一篇:
chat-sdk/chat-sdk-ios: Chat SDK iOS - Open Source Mobile Messenger发布时间:2022-08-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap