July 22, 2021
Get application bundle information
You can use this simple struct to easily get app bundle information.
struct App {
/// Bundle identifier
static var bundleID: String? {
Bundle.main.bundleIdentifier
}
/// Application version
static var version: String? {
Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
}
/// Build number
static var buildNumber: String? {
Bundle.main.infoDictionary?["CFBundleVersion"] as? String
}
}
print("Bundle identifier: \(App.bundleID ?? "empty")")
print("Version: \(App.version ?? "empty")")
print("Build number: \(App.buildNumber ?? "empty")")