Reputation: 1503
I am working on getting the facebook API working for iOS, and the FB registration page requires the Bundle ID of the project. How can I get this information? I read something about getting it at run time, but is there a way to get Xcode to tell me this information, or is it held in a plist somewhere. I am not using the default bundle id, I remember setting it while I created the project.
Upvotes: 71
Views: 116406
Reputation: 34401
iOS Bundle ID(PRODUCT_BUNDLE_IDENTIFIER)
A bundle ID
or bundle identifier identifies an application in Apple's ecosystem. Apple advice to use reverse domain name(reverse DNS notation) to create it.
For example:
com.companyname
Bundle identifier is a string in Info.plist
[About] which is required for any Bundle
To set it using Xcode
//Info.plist
Bundle identifier
//by default it points on `$(PRODUCT_BUNDLE_IDENTIFIER)` which is you can setup in Build Settings
//Build Settings the mirror of Target Settings
Build Settings -> Product Bundle Identifier(PRODUCT_BUNDLE_IDENTIFIER)
//Target Settings the mirror of Build Settings
General -> Bundle Identifier
When you setup a new target you find
Bundle Identifier = Organization Identifier + ProductName
Organization Identifier
is not take into account by Build Settings
To get it programmatically
//Objective-C
[[NSBundle mainBundle] bundleIdentifier];
//Swift
Bundle.main.bundleIdentifier
Upvotes: 5
Reputation: 25294
let bundleId = Bundle.main.bundleIdentifier
let bundleId = Bundle.main.infoDictionary?["CFBundleIdentifier"] as? String
Upvotes: 17
Reputation: 5712
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
It will work for both iOS and Mac apps Good luck..
Upvotes: 68
Reputation: 1737
For those using Xcode >=7: select your target and click the General tab. Bundle Identifier is found under Identity.
Upvotes: 37
Reputation: 2485
If you're build a library, this may be problematic - it's applications that have a bundle ID. However, your can probably query this programatically using [NSBundle mainBundle]
and then [NSBundle bundleIdentifier]
Upvotes: 2
Reputation: 8802
You can find out and change from supporting file=> info.plist => Bundle identifier
It is generally DNS form ex. com.companyname.appname
Upvotes: 2
Reputation: 1124
In Xcode 4, select your project, then your target (you should have only one) and then the 'Info' tab. You should be able to see the bundle identifier there.
Upvotes: 15