Skip to content

[bug] open_devtools doesn't work in setup #4170

@12kv

Description

@12kv

Describe the bug

similar code like below, open_devtools does nothing

fn main() {
  tauri::Builder::default()
    .setup(|app| {
      WindowBuilder::new(app, "main", WindowUrl::default()).build().expect("error build main window");
      #[cfg(debug_assertions)]
      app.get_window("main").unwrap().open_devtools();
      Ok(())
    })
    .run(tauri::generate_context!())
    .expect("error while running tauri application");
}

Reproduction

No response

Expected behavior

open devtools programmably

Platform and versions

Environment
  › OS: Mac OS 12.3.1 X64
  › Node.js: 16.14.0
  › npm: 8.3.1
  › pnpm: Not installed!
  › yarn: 1.22.17
  › rustup: 1.24.3
  › rustc: 1.59.0
  › cargo: 1.59.0
  › Rust toolchain: stable-aarch64-apple-darwin

Packages
  › @tauri-apps/cli [NPM]: 1.0.0-rc.11
  › @tauri-apps/api [NPM]: 1.0.0-rc.5
  › tauri [RUST]: 1.0.0-rc.11,
  › tauri-build [RUST]: 1.0.0-rc.9,
  › tao [RUST]: 0.8.4,
  › wry [RUST]: 0.16.2,

App
  › build-type: bundle
  › CSP: script-src 'unsafe-eval' 'self'; default-src blob: data: filesystem: tauri: 'unsafe-eval' 'unsafe-inline' 'self'; img-src 'self' data: https:;
  › distDir: ../dist
  › devPath: http://127.0.0.1:8080/
  › framework: Vue.js (Vue CLI)
  › bundler: Webpack

App directory structure
  ├─ dist
  ├─ patches
  ├─ node_modules
  ├─ public
  ├─ scripts
  ├─ .github
  ├─ src-tauri
  ├─ .git
  └─ src
✨  Done in 10.37s.

Stack trace

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions