Leonard 2d1234c3d1 Include README and Dioxus logo in package docs (#1536) 1 year ago
..
.cargo 8f0bb5dc5b chore: cleanup workspace 4 years ago
.vscode 8f0bb5dc5b chore: cleanup workspace 4 years ago
src 2d1234c3d1 Include README and Dioxus logo in package docs (#1536) 1 year ago
CHANGELOG.md 56f3002aed feat: add changelogs 3 years ago
Cargo.toml 7f8c963cd9 fix: Update doc links from v3 to v4 1 year ago
Makefile.toml f1865faef7 setup done, local tests work, check workflow 3 years ago
README.md 7f8c963cd9 fix: Update doc links from v3 to v4 1 year ago

README.md

Dioxus Mobile

Crates.io MIT licensed Build Status Discord chat

Website | Guides | API Docs | Chat

Overview

dioxus-mobile is a re-export of dioxus-desktop with some minor tweaks and documentation changes. As this crate evolves, it will provide some more unique features to mobile, but for now, it's very similar to the desktop crate.

Dioxus Mobile supports both iOS and Android. However, Android support is still quite experimental and requires a lot of configuration. A good area to contribute here would be to improve the CLI tool to include bundling and mobile configuration.

Getting Set up

Getting set up with mobile can but quite challenging. The tooling here isn't great (yet) and might take some hacking around to get things working. macOS M1 is broadly unexplored and might not work for you.

We're going to be using cargo-mobile to build for mobile. First, install it:

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

And then initialize your app for the right platform. Use the winit template for now. Right now, there's no "Dioxus" template in cargo-mobile.

$ cargo mobile init

We're going to completely clear out the dependencies it generates for us, swapping out winit with dioxus-mobile.


[package]
name = "dioxus-ios-demo"
version = "0.1.0"
authors = ["Jonathan Kelley <jkelleyrtp@gmail.com>"]
edition = "2018"


# leave the `lib` declaration
[lib]
crate-type = ["staticlib", "cdylib", "rlib"]


# leave the binary it generates for us
[[bin]]
name = "dioxus-ios-demo-desktop"
path = "gen/bin/desktop.rs"

# clear all the dependencies
[dependencies]
mobile-entry-point = "0.1.0"
dioxus = { version = "*", features = ["mobile"] }
simple_logger = "*"

Edit your lib.rs:

// main.rs
use dioxus::prelude::*;

fn main() {
    dioxus_mobile::launch(app);
}

fn app(cx: Scope) -> Element {
    cx.render(rsx!{
        div {
            "hello world!"
        }
    })
}

To configure the web view, menubar, and other important desktop-specific features, checkout out some of the launch configurations in the API reference.

Future Steps

Make sure to read the Dioxus Guide if you already haven't!

Contributing

  • Report issues on our issue tracker.
  • Join the discord and ask questions!

License

This project is licensed under the MIT license.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Dioxus by you shall be licensed as MIT without any additional terms or conditions.