Mulberry/App/Services/AppVersion.swift

17 lines
819 B
Swift

import Foundation
/// Version info from Info.plist (set by build.sh from the VERSION file and the git commit count).
enum AppVersion {
static var version: String { Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "?" }
static var build: String { Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "?" }
/// "Updated to x.y.z" once after an update (nil on first install or same version).
static func updateNote() -> String? {
let key = "last_version"
let now = "\(version) (\(build))"
let last = UserDefaults.standard.string(forKey: key)
UserDefaults.standard.set(now, forKey: key)
guard let last, last != now else { return nil }
return "Updated to Mulberry \(version) (build \(build))"
}
}