How to get bundle ID?

做~自己de王妃 提交于 2019-12-03 10:30:14

问题


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.


回答1:


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




回答2:


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




回答3:


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.




回答4:


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

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




回答5:


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]




回答6:


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

Solution 2



来源:https://stackoverflow.com/questions/8873203/how-to-get-bundle-id

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!