I'm experimenting with some low(ish) level macOS coding for fun and curiosity.
I've been able to create a commandline app that can conditionally also launch a GUI with a window or two. (I'm sure other GUI app functionality is missing too.)
But despite having the regular macOS windows I can't alt-tab to the app when it's in GUI mode. I'm unable to find any discussion on what is needed for this.
Must I call some Foundation/AppKit APIs? Pass some flags when opening my windows? Add something to my Info.plist? If it's the last option, is there also a way to programmatically do all/most of what the Info.plist does declaratively?
(Additional info: My app is extremely minimal, consisting of just one .swift file and one XCode project file. No resource files or Info.plist or anything else.)
I found the solution thanks to this question.
You can set the app's "activation policy" to "regular" before launching the GUI:
As well as working with Alt+Tab the app will now appear in the dock, will have a (default, empty) menu, respects Command+` to cycle through its windows, and it gets a default app icon that looks a bit like the Terminal or Console icon but with
execwritten in its top left corner.An undesirable side-effect is that debug info for the GUI is now output to the terminal. I'll have to look into how to prevent that: