How can I get the bundle ID in Swift?
Objective-C version:
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
How can I get the bundle ID in Swift?
Objective-C version:
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
Try this:
let bundleID = NSBundle.mainBundle().bundleIdentifier
Swift 3+:
let bundleID = Bundle.main.bundleIdentifier
CFBundleIdentifier
is missing –
Floridafloridia It's pretty much the same thing in Swift except the class and method names have been shortened:
let bundleIdentifier = Bundle.main.bundleIdentifier // return type is String?
If you are trying to get it programmatically , you can use below line of code :
Objective-C:
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
Swift 3.0:
let bundleIdentifier = Bundle.main.bundleIdentifier
Updated for latest swift It will work for both iOS and Mac apps.
For More Info, Check here :
Apple Docs: https://developer.apple.com/documentation/foundation/bundle#//apple_ref/occ/instm/NSBundle/bundleIdentifier
© 2022 - 2024 — McMap. All rights reserved.
bundleIdentifier
is an optional? In what cases can it benil
? – Nobody