UIApplication.swift 601 B

123456789101112131415161718192021222324252627
  1. //
  2. // UIApplication.swift
  3. // Mastodon
  4. //
  5. // Created by Cirno MainasuK on 2021-2-26.
  6. //
  7. import UIKit
  8. extension UIApplication {
  9. class func appVersion() -> String {
  10. return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
  11. }
  12. class func appBuild() -> String {
  13. return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
  14. }
  15. class func versionBuild() -> String {
  16. let version = appVersion(), build = appBuild()
  17. return version == build ? "v\(version)" : "v\(version) (\(build))"
  18. }
  19. }