1 public struct Application {
2 /// Creates an returns a new application object representing the current application
3 public static func makeCurrentApplication() -> Application {
4 let displayName = bundleDisplayNameForCurrentApplication()
5 let name = bundleNameForCurrentApplication()
6 let identifier = bundleIdentifierForCurrentApplication()
7 let version = bundleVersionForCurrentApplication()
8 let shortVersion = bundleShortVersionForCurrentApplication()
9 return Application(bundleDisplayName: displayName, bundleName: name, bundleIdentifier: identifier, bundleVersion: version, bundleShortVersion: shortVersion)
12 /// The name of your app as displayed on the homescreen i.e. "My App"
13 public let bundleDisplayName: String?
15 /// The bundle name of your app i.e. "my-app"
16 public let bundleName: String?
18 /// The bundle identifier of your app i.e. "com.my-company.my-app"
19 public let bundleIdentifier: String?
21 /// The bundle version a.k.a. build number as String i.e. "149"
22 public let bundleVersion: String?
24 /// The app version as String i.e. "1.0.1"
25 public let bundleShortVersion: String?
28 extension Application {
29 /// Returns the name of the app as displayed on the homescreen
30 private static func bundleDisplayNameForCurrentApplication() -> String? {
31 return Bundle.main.infoDictionary?["CFBundleDisplayName"] as? String
34 /// Returns the bundle name of the app
35 private static func bundleNameForCurrentApplication() -> String? {
36 return Bundle.main.infoDictionary?["CFBundleName"] as? String
39 /// Returns the bundle identifier
40 private static func bundleIdentifierForCurrentApplication() -> String? {
41 return Bundle.main.infoDictionary?["CFBundleIdentifier"] as? String
44 /// Returns the bundle version
45 private static func bundleVersionForCurrentApplication() -> String? {
46 return Bundle.main.infoDictionary?["CFBundleVersion"] as? String
49 /// Returns the app version
50 private static func bundleShortVersionForCurrentApplication() -> String? {
51 return Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String