import AppKit enum HavenApplication { /// Boots the app. Returns a tiny tuple-style struct so callers (and /// tests) can introspect the activation policy the bootstrap installed /// without poking at NSApp.shared directly. @discardableResult static func start( delegate: AppDelegate, shouldRun: Bool, setDelegate: (AppDelegate) -> Void, run: () -> Void, /// Defaults to setting `NSApp.setActivationPolicy(.accessory)` so an /// unbundled `swift run` launch still behaves like a menu-bar app and /// doesn't grow a Dock icon. The bundled `Info.plist` keeps the same /// behaviour via `LSUIElement`, so both paths land on `.accessory`. setActivationPolicy: (NSApplication.ActivationPolicy) -> Void = { NSApp.setActivationPolicy($0) } ) -> ActivationChoice { // `.accessory` keeps Haven out of the Dock and out of the Cmd+Tab // switcher, matching the bundled `LSUIElement` Info.plist key. The // menu-bar status item still shows in both launch modes. setActivationPolicy(.accessory) setDelegate(delegate) if shouldRun { run() } return ActivationChoice(policy: .accessory) } /// Recorded activation policy chosen by `start`. Exposed so tests can /// assert that the bootstrap honours the menu-bar contract regardless /// of whether the executable was launched from a bundle. struct ActivationChoice: Equatable { let policy: NSApplication.ActivationPolicy } }