Obtain bundle identifier programmatically in Swift?

User picture User · Sep 17, 2014 · Viewed 48.8k times · Source

How can I get the bundle ID in Swift?

Objective-C version:

NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];

Answer

Sebastian picture Sebastian · Sep 17, 2014

Try this:

let bundleID = NSBundle.mainBundle().bundleIdentifier

Swift 3+:

let bundleID = Bundle.main.bundleIdentifier