A menu-bar app from scratch
MenuBarExtra is one of those SwiftUI additions where the API surface looks
clean but the runtime is haunted. The shape of Promptory’s menu-bar entry
went through three rewrites before settling.
Three rewrites
- Pure
MenuBarExtrawindow — laggy on first paint because the window was created lazily and the contents had unbounded SwiftUI. NSStatusBar+ manualNSPanel— fast, but every keyboard interaction had to be glued together by hand.MenuBarExtrawith a small pre-warmed body — what shipped.
The body of this note will go through the pre-warming trick (a hidden view mounted at app launch), the global hotkey using Carbon (yes, still), and how to make a focusable, searchable panel that returns the user to whatever window they had focused before.