When you create a Mac app using SwiftUI, you get the standard Mac menubar by default. The commands
modifier lets you customize the menu bar, either by adding, replacing or removing items and menus. You can even add some presets which give a consistent way to add groups of common items.
The problem comes when you want to communicate back to the SwiftUI views from the menubar. How can you direct your menubar commands to the correct destination? AppKit uses the responder chain, so it effectively broadcasts any menubar message until something handles it. This might be an edit field, a view, a window or even the app itself. SwiftUI doesn’t work like this, but I’ve explored multiple possibilities for passing messages from the menubar to the active window.