Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Platform-Specific Configuration seems broken #9607

Open
oddpxl opened this issue Apr 29, 2024 · 9 comments · May be fixed by #9646
Open

[bug] Platform-Specific Configuration seems broken #9607

oddpxl opened this issue Apr 29, 2024 · 9 comments · May be fixed by #9646
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@oddpxl
Copy link

oddpxl commented Apr 29, 2024

Describe the bug

Platform-Specific Configuration seems broken.

"pnpm tauri android dev" do not load "tauri.android.conf.json" ( broken )
"pnpm tauri android build" do not load "tauri.android.conf.json" ( broken )
"pnpm tauri android build -c tauri.android.conf.json" do not load "tauri.android.conf.json" ( broken )
"pnpm tauri android dev -c tauri.android.conf.json" do load "tauri.android.conf.json" ( works )

also

"pnpm tauri build" on macos do not load "tauri.macos.conf.json" ( broken )
"pnpm tauri build -c tauri.macos.conf.json" on macos do not load "tauri.macos.conf.json" ( broken )
"pnpm tauri dev" on macos do load "tauri.macos.conf.json" ( works )

Reproduction

Try "pnpm tauri android dev" to see it not load "tauri.android.conf.json"
Try "pnpm tauri android build" to see it not load "tauri.android.conf.json"
Try "pnpm tauri android build -c tauri.android.conf.json" to see it not load "tauri.android.conf.json"
Try "pnpm tauri build" on a mac to see it not load "tauri.macos.conf.json"
Try "pnpm tauri build -c tauri.macos.conf.json" to see it not load "tauri.macos.conf.json"

Expected behavior

If "tauri.macos.conf.json" or "tauri.android.conf.json" exist during build or dev - they should be used.

If I use -c or -config to specify use of "tauri.whatever.conf.json" - it should be used.

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.4.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.77.2 (25ef9e3d8 2024-04-09)
    ✔ cargo: 1.77.2 (e52e36006 2024-03-26)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 21.7.1
    - pnpm: 8.15.5
    - npm: 10.5.1

[-] Packages
    - tauri [RUST]: 2.0.0-beta.16
    - tauri-build [RUST]: 2.0.0-beta.13
    - wry [RUST]: 0.39.0
    - tao [RUST]: 0.27.0
    - tauri-cli [RUST]: 1.5.11
    - @tauri-apps/api [NPM]: 2.0.0-beta.7
    - @tauri-apps/cli [NPM]: 2.0.0-beta.12

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: SolidJS
    - bundler: Vite

Stack trace

No response

Additional context

No response

@oddpxl oddpxl added status: needs triage This issue needs to triage, applied to new issues type: bug labels Apr 29, 2024
@amrbashir
Copy link
Member

Works fine on my Windows machine, can you please update your tauri dependencies and also the cli? if still doesn't work please provide a minimal reproduction repo.

@oddpxl
Copy link
Author

oddpxl commented Apr 29, 2024

Updated and re-tested... ..unfortunately issues persist.

For some reason Rust only allowed me to do Beta 13 when building ( see new tauri info above )

Added reproduction of the 5 issues I found - let me know if I need to add anything else ( pls bear with me - new at this )

@oddpxl
Copy link
Author

oddpxl commented Apr 30, 2024

@amrbashir My apologies - seems I was mistaken ! - conf files loads... ..it's the "URL" that only works in dev...not in build:

See windows section below - "url": "/indexDesktop.html"

When I do "pnpm tauri dev" it loads indexDesktop.html
When I do "pnpm tauri build" it loads index.html

See below my "tauri.macos.conf.json" file:

{
"productName": "tauri-mobile-neo",
"version": "0.0.0",
"identifier": "com.oddmade.dev",
"build": {
"beforeDevCommand": "pnpm dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "pnpm build",
"frontendDist": "../dist"
},
"app": {"windows": [
{
"title": "tauri-desktop",
"width": 1200,
"height": 800,
"url": "/indexDesktop.html"
}
],
"security": {
"csp": null }
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/[email protected]",
"icons/icon.icns",
"icons/icon.ico"
]
}
}

@oddpxl
Copy link
Author

oddpxl commented Apr 30, 2024

@amrbashir Also - it seems when I do "pnpm tauri android dev" it loads "tauri.macos.conf.json" instead of "tauri.android.conf.json"

If I force it with "pnpm tauri android dev -c tauri.android.conf.json" it loads "tauri.android.conf.json"

..but again - when I do "pnpm tauri android build" or "pnpm tauri build" it always loads index.html and ignores the "url" i set in the "tauri.android.conf.json" or "tauri.macos.conf.json"... ..even when I force it with -c

Am I doing something wrong here - or is it a bug ?

@FabianLars
Copy link
Member

If I force it with "pnpm tauri android dev -c tauri.android.conf.json" it loads "tauri.android.conf.json"

Hmm, we had that problem once before already but it was fixed in #7802. Maybe we broke it again 🤔

..but again - when I do "pnpm tauri android build" or "pnpm tauri build" it always loads index.html and ignores the "url" i set in the "tauri.android.conf.json" or "tauri.macos.conf.json"... ..even when I force it with -c

As far as i know the whole window config is ignored on mobile (since it doesn't have the concept of a window) so it will always use devUrl and frontendDist respectively.

@oddpxl
Copy link
Author

oddpxl commented Apr 30, 2024

@FabianLars Perhaps this is me doing it the wrong way...

I'm trying to get "tauri.android.conf.json" to load indexMobile.html - and "tauri.macos.conf.json" to load indexDesktop.html

..so each platform can have different index.html files.

..but it seems macos only allow me to change the window URL in dev mode... ( not build )

..and android ( that ignores the window section ) don't seem to allow a customised index.html at all ?

( after further checks, conf files seems to load fine - it's the url that I don't get to work - so sorry for the confusion )

@amrbashir
Copy link
Member

I guess we could add a new config option app > defaultUrl that controls which urls is loaded onto the webview when it is not specified on url of the window config or when creating the webview on mobile.

@oddpxl
Copy link
Author

oddpxl commented Apr 30, 2024

@amrbashir That would be very useful... I'm writing an app that is very similar in core function on desktop vs mobile - but the UX / UI needs to be different due to screen size and use cases - hence the need for a custom index.html per platform.

@amrbashir
Copy link
Member

This looks like a bug after all, so no need for app > defaultUrl once this bug is fixed

amrbashir added a commit that referenced this issue May 3, 2024
closes #9607

proc-macros are compiled for the current host target
and so it read the config for current host target even
when building for mobile.
In another part of our codegen macros we used `TAURI_ENV_TARGET_TRIPLE` as a fallback but it is only set by the CLI and users using `cargo build` won't be able to generate the correct `Context`.

This PR will parse config for each platform and generates an appropriate `Context` and genertes code that uses this context conditionaly using compilation flags `#[cfg]`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
3 participants