符号 `_EMBED_INFO_PLIST` 已定义 Tauri 应用程序开发 mac

问题描述 投票:0回答:1

我正在尝试了解如何使用 Tauri 开发桌面应用程序,但我在 mac book pro 上遇到以下错误。我已经到处寻找解决方案或其他有此问题的人,但还没有找到任何人。请帮忙。

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

这也是我的 main.rs 文件

// 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");
}
macos rust tauri
1个回答
1
投票

您调用 Builder 两次,但它应该只调用一次,这就是您想要做的:

// 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");
}
© www.soinside.com 2019 - 2024. All rights reserved.