From c5d1afcbe7148343cce22f5156832e2ec5f7ed24 Mon Sep 17 00:00:00 2001 From: MarioHewardt Date: Wed, 22 Jul 2026 10:34:58 -0700 Subject: [PATCH] Display bundled app version in settings --- Sources/ZoomItMacCore/App/AppInfo.swift | 15 +++++++++++++-- .../ZoomItMacCore/SelfTest/SelfTestRunner.swift | 16 ++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Sources/ZoomItMacCore/App/AppInfo.swift b/Sources/ZoomItMacCore/App/AppInfo.swift index fef6110..fc0131e 100644 --- a/Sources/ZoomItMacCore/App/AppInfo.swift +++ b/Sources/ZoomItMacCore/App/AppInfo.swift @@ -1,8 +1,19 @@ import Foundation -/// Static product identity used across the UI (settings footer, about text). +/// Product identity used across the UI (settings footer, about text). public enum AppInfo { public static let productName = "Sysinternals ZoomIt" - public static let version = "1.0" + public static var version: String { + resolveVersion(from: Bundle.main.infoDictionary) + } public static let copyright = "Copyright © 2026 Mark Russinovich" + + static func resolveVersion(from infoDictionary: [String: Any]?) -> String { + for key in ["CFBundleShortVersionString", "CFBundleVersion"] { + if let value = infoDictionary?[key] as? String, !value.isEmpty { + return value + } + } + return "Development" + } } diff --git a/Sources/ZoomItMacCore/SelfTest/SelfTestRunner.swift b/Sources/ZoomItMacCore/SelfTest/SelfTestRunner.swift index 17efc81..ffc2f29 100644 --- a/Sources/ZoomItMacCore/SelfTest/SelfTestRunner.swift +++ b/Sources/ZoomItMacCore/SelfTest/SelfTestRunner.swift @@ -28,6 +28,7 @@ private final class FlippedBackgroundHostView: NSView { @MainActor public enum SelfTestRunner { public static func run() throws { + try testAppInfoVersionResolution() try testViewportClampsZoom() try testViewportZoomAnimation() try testViewportSourceRect() @@ -77,6 +78,21 @@ public enum SelfTestRunner { try testPanoramaLockedAxisRejectsShortFallback() } + private static func testAppInfoVersionResolution() throws { + try expect( + AppInfo.resolveVersion(from: ["CFBundleShortVersionString": "12.2.0"]) == "12.2.0", + "Expected the settings version to use CFBundleShortVersionString" + ) + try expect( + AppInfo.resolveVersion(from: ["CFBundleVersion": "42"]) == "42", + "Expected the settings version to fall back to CFBundleVersion" + ) + try expect( + AppInfo.resolveVersion(from: nil) == "Development", + "Expected an unbundled development build to identify itself as Development" + ) + } + private static func testViewportClampsZoom() throws { let controller = ZoomViewportController()