AppBootstrap.swift
1import AppKit23enum HavenApplication {4 /// Boots the app. Returns a tiny tuple-style struct so callers (and5 /// tests) can introspect the activation policy the bootstrap installed6 /// without poking at NSApp.shared directly.7 @discardableResult8 static func start(9 delegate: AppDelegate, shouldRun: Bool,10 setDelegate: (AppDelegate) -> Void, run: () -> Void,11 /// Defaults to setting `NSApp.setActivationPolicy(.accessory)` so an12 /// unbundled `swift run` launch still behaves like a menu-bar app and13 /// doesn't grow a Dock icon. The bundled `Info.plist` keeps the same14 /// behaviour via `LSUIElement`, so both paths land on `.accessory`.15 setActivationPolicy: (NSApplication.ActivationPolicy) -> Void =16 { NSApp.setActivationPolicy($0) }17 ) -> ActivationChoice {18 // `.accessory` keeps Haven out of the Dock and out of the Cmd+Tab19 // switcher, matching the bundled `LSUIElement` Info.plist key. The20 // menu-bar status item still shows in both launch modes.21 setActivationPolicy(.accessory)22 setDelegate(delegate)23 if shouldRun { run() }24 return ActivationChoice(policy: .accessory)25 }2627 /// Recorded activation policy chosen by `start`. Exposed so tests can28 /// assert that the bootstrap honours the menu-bar contract regardless29 /// of whether the executable was launched from a bundle.30 struct ActivationChoice: Equatable {31 let policy: NSApplication.ActivationPolicy32 }33}