Let's say my app is doing some work and it takes some good seconds to finish it. Meanwhile, the user of my app starts working with another app. But the work is happening in my app and it is finished now. How can I bring my app to the front in order to inform the user the job is finished?
In these cases we usually show a User Notification to inform user that their task is complete.
But if you want to bring your window to the front, you could just use:
NSApp.mainWindow?.orderFrontRegardless()
Or if your app is in Menubar (hidden from Dock) and you want to display the main window:
NSApp.activate(ignoringOtherApps: true)
openWindow(id: YOUR_WINDOW_ID)
NSApp.mainWindow?.orderFrontRegardless()