#Unable to use setup hook

3 messages · Page 1 of 1 (latest)

ornate tendon
#

Pretty much just have a boilerplate example but isn't working, could someone help me out on Tauri V2?

the following complains: "no method named get_window found for mutable reference &mut tauri::App in the current scope"

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

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
  tauri::Builder::default()
      .setup(|app| {
      let main_window = app.get_window("main").unwrap();
      main_window.set_title("Howdy!")?;
      Ok(())
    })
    .plugin(tauri_plugin_opener::init())
    .invoke_handler(tauri::generate_handler![greet])
    .run(tauri::generate_context!())
    .expect("error while running tauri application");
}

but the example has it this way - https://docs.rs/tauri/2.6.2/tauri/struct.Builder.html#method.setup

i'm a rust beginner lol

#

oh, nvm - you have to add the unstable feature in the Cargo.toml 🤣

#
  • use tauri::Manager; at the top