From e6246286fb94049aabe00a2527ae90c1f76a6409 Mon Sep 17 00:00:00 2001 From: oho Date: Fri, 13 Feb 2026 18:23:55 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20Dock=20icon=20not=20loading=20=E2=80=94?= =?UTF-8?q?=20move=20to=20onAppear?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NSApp.applicationIconImage set in init() was too early; the app wasn't fully initialized yet. Moved to onAppear where NSApp is ready. --- apps/macos/KnowledgeRefinery/Sources/App.swift | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/macos/KnowledgeRefinery/Sources/App.swift b/apps/macos/KnowledgeRefinery/Sources/App.swift index 93c0164..41aefbf 100644 --- a/apps/macos/KnowledgeRefinery/Sources/App.swift +++ b/apps/macos/KnowledgeRefinery/Sources/App.swift @@ -13,12 +13,6 @@ struct KnowledgeRefineryApp: App { init() { // Ensure the app appears in the Dock and can become frontmost NSApplication.shared.setActivationPolicy(.regular) - - // Set custom Dock icon from bundled .icns - if let iconURL = Bundle.module.url(forResource: "AppIcon", withExtension: "icns"), - let icon = NSImage(contentsOf: iconURL) { - NSApplication.shared.applicationIconImage = icon - } } var body: some Scene { @@ -28,6 +22,7 @@ struct KnowledgeRefineryApp: App { .environmentObject(lmMonitor) .frame(minWidth: 900, minHeight: 600) .onAppear { + setAppIcon() autoStartDaemons() runSelfTestIfRequested() } @@ -56,6 +51,14 @@ struct KnowledgeRefineryApp: App { .defaultSize(width: 1300, height: 850) } + /// Set the Dock icon from the bundled .icns file. + private func setAppIcon() { + if let iconURL = Bundle.module.url(forResource: "AppIcon", withExtension: "icns") { + let icon = NSImage(contentsOf: iconURL) + NSApp.applicationIconImage = icon + } + } + /// Auto-start daemons for all workspaces on app launch. private func autoStartDaemons() { for ws in workspaceStore.workspaces {