import AppKit import Foundation // Where the running app came from, for the About panel. The short git SHA is // stamped into the built Info.plist by the "Stamp git SHA" phase in // ios/project.yml — NOT baked in at compile time: a Swift compilation // condition (`#if GIT_SHA`) is a flag, not a value, so it can't carry the // string, and CFBundleVersion is off-limits because Sparkle orders updates by // it. The stamp is absent in a checkout without .git (a source tarball), and // then the panel is simply the stock one. enum BuildInfo { /// Short SHA of the commit the app was built from, `-dirty` when the tree /// had uncommitted changes. Nil when the build had no git to ask. static let gitSHA: String? = { let sha = Bundle.main.infoDictionary?["GitSHA"] as? String return (sha?.isEmpty ?? true) ? nil : sha }() /// The bundle's display name — "Eleven", or "Eleven Dev" for a dev alt, so /// the menu item names the app you're actually looking at. static var appName: String { let info = Bundle.main.infoDictionary return info?["CFBundleDisplayName"] as? String ?? info?["CFBundleName"] as? String ?? "Eleven" } /// Options for the standard About panel. The SHA rides in `.version` — the /// parenthetical next to the marketing version — so it reads "Version 1.0 /// (2 · a1b2c3d)" with no custom window to maintain. static var aboutPanelOptions: [NSApplication.AboutPanelOptionKey: Any] { guard let sha = gitSHA else { return [:] } let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "" return [.version: build.isEmpty ? sha : "\(build) · \(sha)"] } static func showAboutPanel() { NSApp.activate(ignoringOtherApps: true) NSApp.orderFrontStandardAboutPanel(options: aboutPanelOptions) } }