Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion DualClip/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ struct SettingsView: View {
.frame(width: 420, height: 320)
}

/// Resolve app version: Bundle (release .app) → source Info.plist (dev swift run)
private static var appVersion: String {
// 1. Try Bundle.main (works in .app bundles)
if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String {
return version
}
// 2. Fallback: read from source Info.plist (works with swift run)
if let plistPath = Bundle.main.executableURL?
.deletingLastPathComponent() // .build/debug/
.deletingLastPathComponent() // .build/
.deletingLastPathComponent() // project root
.appendingPathComponent("DualClip/Info.plist"),
let dict = NSDictionary(contentsOf: plistPath),
let version = dict["CFBundleShortVersionString"] as? String {
return version
}
return "dev"
}

// MARK: - Shortcuts Tab

private var shortcutsTab: some View {
Expand Down Expand Up @@ -65,7 +84,7 @@ struct SettingsView: View {
.font(.callout)
.foregroundColor(.secondary)

Text("v\(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "?")")
Text("v\(Self.appVersion)")
.font(.caption)
.foregroundColor(.secondary)

Expand Down
Loading