{"record":{"id":"07bb35b6b102c458","repo":"tauri-apps/tauri","slug":"creating-icon","errorCode":null,"errorMessage":"creating icon","messagePattern":"creating icon","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri/src/app.rs","lineNumber":2622,"sourceCode":"    },\n    RuntimeRunEvent::WebviewEvent { label, event } => RunEvent::WebviewEvent {\n      label,\n      event: event.into(),\n    },\n    RuntimeRunEvent::Ready => {\n      // set the app icon in development\n      #[cfg(all(dev, target_os = \"macos\"))]\n      {\n        use objc2::{AllocAnyThread, MainThreadMarker};\n        use objc2_app_kit::{NSApplication, NSImage};\n        use objc2_foundation::NSData;\n\n        if let Some(icon) = app_handle.manager.app_icon.clone() {\n          // TODO: Enable this check.\n          let mtm = unsafe { MainThreadMarker::new_unchecked() };\n          let app = NSApplication::sharedApplication(mtm);\n          let data = NSData::with_bytes(&icon);\n          let app_icon = NSImage::initWithData(NSImage::alloc(), &data).expect(\"creating icon\");\n          unsafe { app.setApplicationIconImage(Some(&app_icon)) };\n        }\n      }\n      RunEvent::Ready\n    }\n    RuntimeRunEvent::Resumed => RunEvent::Resumed,\n    RuntimeRunEvent::MainEventsCleared => RunEvent::MainEventsCleared,\n    RuntimeRunEvent::UserEvent(t) => {\n      match t {\n        #[cfg(desktop)]\n        EventLoopMessage::MenuEvent(ref e) => {\n          for listener in &*app_handle\n            .manager\n            .menu\n            .global_event_listeners\n            .lock()\n            .unwrap()\n          {","sourceCodeStart":2604,"sourceCodeEnd":2640,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri/src/app.rs#L2604-L2640","documentation":"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.","triggerScenarios":"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.","commonSituations":"Hand-edited or truncated icon files; bundle icon config pointing at a non-image; icon set without a macOS-usable entry.","solutions":["Regenerate the full icon set: tauri icon path/to/source.png.","Ensure bundle.icons includes a valid .icns or PNG usable on macOS.","Open each icon file in Preview to confirm it decodes; replace broken files."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// fail fast with a clear message instead of the NSImage panic (dev, macOS)\nif let Some(icon) = app_icon_bytes() {\n    assert!(image::load_from_memory(icon).is_ok(), \"app icon is not a decodable image - regenerate with `tauri icon`\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate icons with tauri icon instead of hand-copying files.","Include a macOS-usable format (icns/PNG) in bundle.icons.","Preview-test icon files after editing them."],"tags":["tauri","macos","icon","dev","nsimage"],"backgroundTag":"invalid-image-data","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}