tauri-apps/tauri · error

creating icon

Error message

creating icon

What it means

Only on macOS dev builds (cfg(all(dev, target_os = "macos"))): when the app is created, Tauri converts the configured app icon bytes to an NSImage to set the application icon in the dock. NSImage::initWithData returns None when AppKit cannot decode the bytes, and this expect panics.

Source

Thrown at crates/tauri/src/app.rs:2622

    },
    RuntimeRunEvent::WebviewEvent { label, event } => RunEvent::WebviewEvent {
      label,
      event: event.into(),
    },
    RuntimeRunEvent::Ready => {
      // set the app icon in development
      #[cfg(all(dev, target_os = "macos"))]
      {
        use objc2::{AllocAnyThread, MainThreadMarker};
        use objc2_app_kit::{NSApplication, NSImage};
        use objc2_foundation::NSData;

        if let Some(icon) = app_handle.manager.app_icon.clone() {
          // TODO: Enable this check.
          let mtm = unsafe { MainThreadMarker::new_unchecked() };
          let app = NSApplication::sharedApplication(mtm);
          let data = NSData::with_bytes(&icon);
          let app_icon = NSImage::initWithData(NSImage::alloc(), &data).expect("creating icon");
          unsafe { app.setApplicationIconImage(Some(&app_icon)) };
        }
      }
      RunEvent::Ready
    }
    RuntimeRunEvent::Resumed => RunEvent::Resumed,
    RuntimeRunEvent::MainEventsCleared => RunEvent::MainEventsCleared,
    RuntimeRunEvent::UserEvent(t) => {
      match t {
        #[cfg(desktop)]
        EventLoopMessage::MenuEvent(ref e) => {
          for listener in &*app_handle
            .manager
            .menu
            .global_event_listeners
            .lock()
            .unwrap()
          {

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Regenerate the full icon set: tauri icon path/to/source.png.
  2. Ensure bundle.icons includes a valid .icns or PNG usable on macOS.
  3. Open each icon file in Preview to confirm it decodes; replace broken files.
Defensive patterns

Strategy: validation

Validate before calling

// fail fast with a clear message instead of the NSImage panic (dev, macOS)
if let Some(icon) = app_icon_bytes() {
    assert!(image::load_from_memory(icon).is_ok(), "app icon is not a decodable image - regenerate with `tauri icon`");
}

Prevention

When it happens

Trigger: Running tauri dev on macOS while the app icon data is corrupt or in a format NSImage cannot decode: truncated file, garbage bytes from a misconfigured icon path, or a Windows .ico used as the sole icon asset.

Common situations: Hand-edited or truncated icon files; bundle icon config pointing at a non-image; icon set without a macOS-usable entry.

Related errors


AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20). Data as JSON: /api/errors/07bb35b6b102c458. Report an issue: GitHub.