I have a small window that needs to be in the active space (macOS Swift)
One option would be to have that window in all the spaces. It seems that is not recommendable: https://developer.apple.com/documentation/appkit/nswindow/collectionbehavior/1419120-movetoactivespace
Another approach is to move the window when the user changes to another space. I could find that in the documentation: https://developer.apple.com/documentation/appkit/nswindow/1419707-isonactivespace
Also this question: How can I move application's window between virtual desktops in OS X?
I am not sure if that is the right option. In any case, I cannot apply apply the documentation to the current window. self.view.window This is what I tried but if I change space the window remains in the first space. Probably there is something I do not understand or I am missing?
override func viewDidLoad() {
super.viewDidLoad()
self.view.window?.collectionBehavior = NSWindow.CollectionBehavior.canJoinAllSpaces
self.view.window?.collectionBehavior = NSWindow.CollectionBehavior.moveToActiveSpace
}