Mobile example main.rs does not compile
Steps To Reproduce
Steps to reproduce the behavior:
- follow the instructions on https://dioxuslabs.com/learn/0.4/getting_started/mobile
- after running
cargo build --target aarch64-apple-ios-simobserve the following compile errors:
error[E0433]: failed to resolve: use of undeclared type `Config`
--> src/main.rs:12:9
|
12 | Config::default().with_custom_index(r#"<!DOCTYPE html>
| ^^^^^^ use of undeclared type `Config`
|
help: consider importing this struct
|
1 + use dioxus_desktop::Config;
|
error[E0107]: enum takes 2 generic arguments but 1 generic argument was supplied
--> src/main.rs:3:18
|
3 | pub fn main() -> Result<()> {
| ^^^^^^ -- supplied 1 generic argument
| |
| expected 2 generic arguments
|
note: enum defined here, with 2 generic parameters: `T`, `E`
--> /Users/evgeniia/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/result.rs:502:10
|
502 | pub enum Result<T, E> {
| ^^^^^^ - -
help: add missing generic argument
|
3 | pub fn main() -> Result<(), E> {
| +++
error[E0425]: cannot find function `init_logging` in this scope
--> src/main.rs:4:5
|
4 | init_logging();
| ^^^^^^^^^^^^ not found in this scope
Some errors have detailed explanations: E0107, E0425, E0433.
For more information about an error, try `rustc --explain E0107`.
error: could not compile `dioxus-mobile-test` (bin "dioxus-mobile-test") due to 3 previous errors
Expected behavior
The example from the documentation should compile without errors.
Environment:
[dependencies]
anyhow = "1.0.56"
dioxus = "0.4.0"
dioxus-desktop = { version = "0.4.0", default-features = false, features = ["tokio_runtime"] }
log = "0.4.11"
wry = "0.28.0"
- Rust version:
rustc 1.72.1 (d5c2e9c34 2023-09-13) - OS info: macOS
- App platform:
mobile
Questionnaire
- [x] I'm interested in fixing this myself but don't know where to start
- [ ] I would like to fix and I have a solution
- [ ] I don't have time to fix this right now, but maybe later
I tried to update the code and this version compiles (I also needed to install cargo add oslog):
use dioxus::prelude::*;
use dioxus_desktop::Config;
use log::LevelFilter;
use oslog::OsLogger;
use wry::Error;
pub fn main() -> Result<(), Error> {
// Init logger
OsLogger::new("com.example.test")
.level_filter(LevelFilter::Debug)
.init()
.expect("failed to init logger");
// Right now we're going through dioxus-desktop but we'd like to go through dioxus-mobile
// That will seed the index.html with some fixes that prevent the page from scrolling/zooming etc
dioxus_desktop::launch_cfg(
app,
// Note that we have to disable the viewport goofiness of the browser.
// Dioxus_mobile should do this for us
Config::default().with_custom_index(r#"<!DOCTYPE html>
<html>
<head>
<title>Dioxus app</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- CUSTOM HEAD -->
</head>
<body>
<div id="main"></div>
<!-- MODULE LOADER -->
</body>
</html>
"#.into()),
);
Ok(())
}
fn app(cx: Scope) -> Element {
let items = cx.use_hook(|| vec![1, 2, 3]);
log::debug!("Hello from the app");
render! {
div {
h1 { "Hello, Mobile"}
div { margin_left: "auto", margin_right: "auto", width: "200px", padding: "10px", border: "1px solid black",
button {
onclick: move|_| {
println!("Clicked!");
items.push(items.len());
cx.needs_update_any(ScopeId(0));
println!("Requested update");
},
"Add item"
}
for item in items.iter() {
div { "- {item}" }
}
}
}
}
}
but after opening in xcode (cargo apple open) and hitting the play button, there is an error:
Command PhaseScriptExecution failed with a nonzero exit code
https://github.com/DioxusLabs/docsite/pull/191 updates the mobile code in the example to include imports and a more recent version of wry. It may fix this issue
this error seems to be back with the latest 0.5 release & docs
@dignifiedquire have you found a solution?, using mobile iOS guide [https://dioxuslabs.com/learn/0.5/reference/mobile] resulted this error Dioxus version 0.5.1
Command PhaseScriptExecution failed with a nonzero exit code
no solution yet