Bring macOS app to front when dock icon gets clicked

Implement applicationShouldHandleReopen in your AppDelegate

func applicationShouldHandleReopen(_ sender: NSApplication,
                                       hasVisibleWindows flag: Bool) -> Bool {
        // Bring app window when dock icon gets clicked
        if !flag {
            for window: AnyObject in sender.windows {
                window.makeKeyAndOrderFront(self)
            }
        }
        
        return true
}
Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Leave a comment