macosrusttauri

symbol `_EMBED_INFO_PLIST` is already defined Tauri app development mac


I am trying to lear how to use Tauri to develop desktop app but I am running in to the following error on my mac book pro. I have looked everywhere for a fix or others having this issue but have not found anyone yet. please help.

error: symbol `_EMBED_INFO_PLIST` is already defined
  --> src/main.rs:17:14
   |
17 |         .run(tauri::generate_context!())
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `$crate::embed_info_plist_bytes` which comes from the expansion of the macro `tauri::generate_context` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `sandbox` (bin "sandbox") due to 1 previous error

here is my main.rs file too

// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

#[tauri::command]
fn reply(replies: &str) -> String {
    format!("Your reply is {}", replies)
}
fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![greet])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![reply])
        .run(tauri::generate_context!())
        .expect("Error while running application");
}

Solution

  • You're calling Builder two times, but it should be called only once, here's what you want to do:

    // Prevents additional console window on Windows in release, DO NOT REMOVE!!
    #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
    
    // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
    #[tauri::command]
    fn greet(name: &str) -> String {
        format!("Hello, {}! You've been greeted from Rust!", name)
    }
    
    #[tauri::command]
    fn reply(replies: &str) -> String {
        format!("Your reply is {}", replies)
    }
    fn main() {
        tauri::Builder::default()
            .invoke_handler(tauri::generate_handler![greet, reply])
            .run(tauri::generate_context!())
            .expect("error while running tauri application");
    }