Быстро получить информацию о приложении

info
extension
build

#1

К примеру, я часто использую для того, чтобы пользователь в письме из приложения, автоматом вставлял номер версии и билда.

Можно использовать в онбординге, чтобы после обновления сравнивать версии и тогда показывать вью с информацией о новых фичах

extension Bundle {
  
  // returns the canonical application name - this is the name default name of the app if CFBundleDisplayName is not set
  var appName:  String? {
    return Bundle.main.infoDictionary!["CFBundleName"] as! String?
  }
  
  // returns the canonical application name - this is the name default name of the app if CFDisplayName is not specified
  var displayName: String? {
    return Bundle.main.infoDictionary!["CFBundleDisplayName"] as! String?
  }
  
  // returns the application bundle name - e.g., com.myorg.thisAppBundleName
  var bundleName: String? {
    return Bundle.main.infoDictionary!["CFBundleIdentifier"] as! String?
  }
  
  // returns the build number - this is not your applications version number but the internal build number
  // that should be incremented with every iTunesConnect submission
  var buildNumber: String? {
    return Bundle.main.infoDictionary!["CFBundleVersion"] as? String  // was: CFBuildNumber
  }
  
  // returns the version number - known as the marketing version number
  var versionNumber: String? {
    return Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String?
  }
  
  // returns the version number - known as the marketing version number
  var buildDate: Date? {
    return Bundle.main.infoDictionary!["CFBuildDate"] as! Date?
  }
  
}