Skip to main content
deleted 14 characters in body
Source Link
Sebastian Boldt
  • 5.3k
  • 10
  • 54
  • 66

I created an extension for UIApplication.

extension UIApplication { static var appVersion: String { let versionNumber = Bundle.main.infoDictionary?[IdentifierConstants.InfoPlist.versionNumber] as? String let buildNumber = Bundle.main.infoDictionary?[IdentifierConstants.InfoPlist.buildNumber] as? String let formattedBuildNumber = buildNumber.map { return "(\($0))" } return [versionNumber,formattedBuildNumber].compactMap { $0 }.joined(separator: " ") } } structenum IdentifierConstantsConstants { structenum InfoPlist { static let versionNumber = "CFBundleShortVersionString" static let buildNumber = "CFBundleVersion" } } 

I created an extension for UIApplication.

extension UIApplication { static var appVersion: String { let versionNumber = Bundle.main.infoDictionary?[IdentifierConstants.InfoPlist.versionNumber] as? String let buildNumber = Bundle.main.infoDictionary?[IdentifierConstants.InfoPlist.buildNumber] as? String let formattedBuildNumber = buildNumber.map { return "(\($0))" } return [versionNumber,formattedBuildNumber].compactMap { $0 }.joined(separator: " ") } } struct IdentifierConstants { struct InfoPlist { static let versionNumber = "CFBundleShortVersionString" static let buildNumber = "CFBundleVersion" } } 

I created an extension for UIApplication.

extension UIApplication { static var appVersion: String { let versionNumber = Bundle.main.infoDictionary?[IdentifierConstants.InfoPlist.versionNumber] as? String let buildNumber = Bundle.main.infoDictionary?[IdentifierConstants.InfoPlist.buildNumber] as? String let formattedBuildNumber = buildNumber.map { return "(\($0))" } return [versionNumber,formattedBuildNumber].compactMap { $0 }.joined(separator: " ") } } enum Constants { enum InfoPlist { static let versionNumber = "CFBundleShortVersionString" static let buildNumber = "CFBundleVersion" } } 
Source Link
Sebastian Boldt
  • 5.3k
  • 10
  • 54
  • 66

I created an extension for UIApplication.

extension UIApplication { static var appVersion: String { let versionNumber = Bundle.main.infoDictionary?[IdentifierConstants.InfoPlist.versionNumber] as? String let buildNumber = Bundle.main.infoDictionary?[IdentifierConstants.InfoPlist.buildNumber] as? String let formattedBuildNumber = buildNumber.map { return "(\($0))" } return [versionNumber,formattedBuildNumber].compactMap { $0 }.joined(separator: " ") } } struct IdentifierConstants { struct InfoPlist { static let versionNumber = "CFBundleShortVersionString" static let buildNumber = "CFBundleVersion" } }