I'm building a music app for Mac using AppKit and Swift. I'm targeting macOS 11.0+.
When the app's last window is closed and then resigns active, my app is removed from the Dock, and terminated (when not attached to the debugger).
I'd like to stop this behaviour. When my app resigns active with no windows, it should remain in the Dock and continue running.
The current behaviour means that when music is playing, if the last window is closed (but not the app itself) and a user starts using a different app (e.g. Safari) the app is terminated. The expected behaviour would be to continue running and playing audio until the user explicitly quits the app.
I can't find this behaviour documented and can't find a way to fix this.
Thanks in advance for any help/pointers!
Notes:
My NSApplicationDelegate returns false for applicationShouldTerminateAfterLastWindowClosed
1
0
1.2k