49

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.

Leo Natan
  • 55,734
  • 8
  • 140
  • 186
jln646v
  • 1,264
  • 2
  • 14
  • 29
  • 3
    The bundle ID should appear when you click on your project in Xcode and go to the 'info' tab. It should look something like "com.mycompany.appname" – CodaFi Jan 15 '12 at 20:45

7 Answers7

52

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..

Andrea Mugnaini
  • 8,880
  • 3
  • 34
  • 49
Aks
  • 4,339
  • 1
  • 33
  • 32
35

For those using Xcode >=7: select your target and click the General tab. Bundle Identifier is found under Identity.

plátano plomo
  • 1,544
  • 15
  • 24
  • what is the general tab ? – Romain Jouin Nov 10 '16 at 17:47
  • 4
    @romainjouin "...choose View > Navigators > Show Project Navigator. Choose the target from the Project/Targets pop-up menu or in the Targets section of the second sidebar if it appears. Click General..." from [this document](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/ConfiguringYourApp/ConfiguringYourApp.html) – plátano plomo Nov 11 '16 at 23:19
14

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.

bdash
  • 17,105
  • 1
  • 52
  • 86
Nikso
  • 1,084
  • 8
  • 7
  • 1
    Thanks, but the issue is I am building a library, and when I click on the target, I only have "Build Settings" "Build Phases" and "Build Rules". Is there another way to get this? – jln646v Jan 16 '12 at 08:52
  • 4
    when it says PRODUCT_NAME do you have to replace that ? – shim Jun 03 '13 at 21:42
7

Details

  • Xcode 11.2.1 (11B500), Swift 5.1

Programmatically

Solution 1

let bundleId = Bundle.main.bundleIdentifier

Solution 2

let bundleId = Bundle.main.infoDictionary?["CFBundleIdentifier"] as? String

From Xcode

Solution 1

enter image description here

Solution 2

enter image description here

Vasily Bodnarchuk
  • 19,860
  • 8
  • 111
  • 113
2

You can find out and change from supporting file=> info.plist => Bundle identifier

It is generally DNS form ex. com.companyname.appname

enter image description here

Avijit Nagare
  • 7,801
  • 7
  • 34
  • 62
2

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]

James Turner
  • 2,285
  • 2
  • 18
  • 23
2

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

[ProductName]

To get it programmatically

//Objective-C
[[NSBundle mainBundle] bundleIdentifier];

//Swift
Bundle.main.bundleIdentifier

[Vocabulary]

yoAlex5
  • 13,571
  • 5
  • 105
  • 98