Skip to content

[bug] tauri add doesn't add the conditional inclusion for desktop vs mobile #11737

Open
@dionysuzx

Description

If you follow the docs to add updater like cargo tauri add updater, it adds everything but you'll get this error: error[E0433]: failed to resolve: use of undeclared crate or module tauri_plugin_updater.

The reason for this is because in the Cargo.toml it will add tauri-plugin-updater conditionally excluding mobile builds:

[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-updater = "2.0.2"

Thus, the program cannot find tauri-plugin-updater when referenced in the lib.rs builder.

I fixed this by doing:

    let mut builder = tauri::Builder::default()
        .plugin(tauri_plugin_dialog::init())
        .plugin(tauri_plugin_fs::init())
        .plugin(tauri_plugin_os::init())
        .invoke_handler(tauri::generate_handler![
            ...
        ]);

    #[cfg(not(any(target_os = "android", target_os = "ios")))]
    {
        builder = builder.plugin(tauri_plugin_updater::Builder::new().build());
    }

One option is we can update the install script to also do this by default.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions