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
}