IMEApp // Contantiate .appVersionLabel() with build date.

This commit is contained in:
ShikiSuen 2023-07-03 22:34:58 +08:00
parent 20bddbc0cb
commit 34a6f036b5
1 changed files with 20 additions and 5 deletions

View File

@ -76,17 +76,32 @@ _ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)
public enum IMEApp {
// MARK: -
public static var appVersionLabel: String {
guard
let intBuild = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String,
let strVer = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
public static let appVersionLabel: String = {
let maybeStrDate: String? = {
guard let executableURL = Bundle.main.executableURL,
let infoDate = (try? executableURL.resourceValues(forKeys: [.creationDateKey]))?.creationDate
else {
return "114.514.1919810"
return nil
}
return "\(strVer) Build \(intBuild)"
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyyMMdd.HHmm"
dateFormatter.timeZone = .init(secondsFromGMT: +28800) ?? .current
let strDate = dateFormatter.string(from: infoDate)
return strDate
}()
guard
let intBuild = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String,
let strVer = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String,
let strDate = maybeStrDate
else {
return "1.14.514 - 19190810"
}
return "\(strVer) Build \(intBuild) - \(strDate)"
}()
// MARK: -
public static var currentInputMode: Shared.InputMode {