DioxusLabs / sdk

A library to provide abstractions to access common utilities when developing Dioxus applications.
Apache License 2.0
84 stars 13 forks source link

Geolocation not supported on web? #51

Open alper opened 4 months ago

alper commented 4 months ago

I'm getting: compile_error!("The geolocation module is not supported on this platform....

Not sure but my combination of:

dioxus = { version = "0.5", features = ["web", "router"] }

and

[application]

# App (Project) Name
name = "cuppings-web"

# Dioxus App Default Platform
# desktop, web
default_platform = "web"

# `build` & `serve` dist path
out_dir = "dist"

# resource (assets) file folder
asset_dir = "assets"

[web.app]

# HTML title tag content
title = "cuppings-web"

[web.watcher]

# when watcher trigger, regenerate the `index.html`
reload_html = true

# which files or dirs will be watcher monitoring
watch_path = ["src", "assets"]

# include `assets` in web platform
[web.resource]

# CSS style file

style = ["/tailwind.css"]

# Javascript code file
script = []

[web.resource.dev]

# Javascript code file
# serve: [dev-server] only
script = []

Is pretty web isn't it?

alper commented 4 months ago

I also don't really get what this bit in mod.rs is going on about:

if #[cfg(any(windows, target_family = "wasm"))] {

Windows??

marc2332 commented 4 months ago

@DogeDark probably knows more about this

alper commented 4 months ago

It seemingly is not supported on desktop either.

I just checked out master here and tried to build/run the geolocation example and it's broken.

alper commented 4 months ago

I get some more information now:

compile_error!("the `geolocation` feature is only available on wasm and windows targets...

But I thought I was cross-compiling to wasm here.

alper commented 4 months ago

OK. Let me close this. I think to see if things compile I was doing cargo build which would then of course not have the right target architecture set. A bit confusing.

alper commented 2 hours ago

Oddly enough, I'm trying to bundle everything not using cargo this time round:

dx bundle --platform web --release

But it gives me the same error about geolocation:

10 | ...   compile_error!("The geolocation module is not supported on this platform....
alper commented 2 hours ago

OK. This works now with: dx bundle --platform web --release --target wasm32-unknown-unknown

Which is odd because dx serve did not have me specify an explicit target.

It does give an error at the end but seems to have built most everything:

thread 'main' panicked at /Users/alpercugun/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-cli-0.5.7/src/cli/bundle.rs:216:13:
Failed to bundle project: GenericError(
    "Native unknown bundles not yet supported.",
)

stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: dioxus_cli::cli::bundle::Bundle::bundle
   3: dx::main::{{closure}}
   4: tokio::runtime::park::CachedParkThread::block_on
   5: tokio::runtime::runtime::Runtime::block_on
   6: dx::main