Bundle
public extension Bundle
The Bundle extensions provide convenient properties to access information from the main bundle.
-
The display name of the main bundle.
This property retrieves the value of the
CFBundleDisplayName
key from the main bundle’s info dictionary.Example:
let name = Bundle.main.displayName print("App Name: \(name)")
Declaration
Swift
var displayName: String { get }
Return Value
A string representing the display name of the main bundle. If the key is not present or the value is not a string, an empty string is returned.
-
The bundle identifier of the main bundle.
This property retrieves the value of the
CFBundleIdentifier
key from the main bundle’s info dictionary.Example:
let identifier = Bundle.main.bundleIdentifier print("Bundle Identifier: \(identifier)")
Declaration
Swift
var bundleIdentifier: String { get }
Return Value
A string representing the bundle identifier of the main bundle. If the key is not present or the value is not a string, an empty string is returned.
-
The build version number of the main bundle.
This property retrieves the value of the
CFBundleVersion
key from the main bundle’s info dictionary.Example:
let buildVersion = Bundle.main.buildVersionNumber print("Build Version: \(buildVersion)")
Declaration
Swift
var buildVersionNumber: String { get }
Return Value
A string representing the build version number of the main bundle. If the key is not present or the value is not a string, an empty string is returned.
-
The build release number of the main bundle.
This property retrieves the value of the
CFBundleShortVersionString
key from the main bundle’s info dictionary.Example:
let releaseVersion = Bundle.main.buildReleaseNumber print("Release Version: \(releaseVersion)")
Declaration
Swift
var buildReleaseNumber: String { get }
Return Value
A string representing the build release number of the main bundle. If the key is not present or the value is not a string, an empty string is returned.