Can't change bundle ID in project, greyed out

2019-02-04 05:04发布

问题:

I'm having a problem with bundle identifiers. In the Summary section of my project in Xcode and under 'Identifiers', I can't seem to change the name of my bundle ID as it is greyed out. For example, my project name is 'My App'. In the identifier text box in Summary, it says this 'My-App' and is greyed out. However, my bundle id in my provisioning profile is this, 'com.mycompany.myapp'. I would like to change my bundle ID in my project to that but I can't seem to be able to. Any ideas why it is greyed out? Thanks!

回答1:

Not sure why this is happening to you, but try to change in the info.plist file.



回答2:

If anybody else runs into this, it is likely because you have a product name variable, something like .${PRODUCT_NAME:rfc1034identifier}, appended to the end of your bundle identifier under Target (your application) > Info (info.plist). Try removing that.



回答3:

  1. Go to info.plist file
  2. Go to Bundle Identifier key-value pair
  3. Remove .${PRODUCT_NAME:rfc1034identifier} from the value and save the file

Your bundle identifier has been modified as required.



回答4:

You may want to consider changing the value of PRODUCT_NAME instead of directly changing the bundle identifier. This can be done thru the XCODE interface (and should have the added benefit of not possibly causing problems with certificates and code signing later on...which can be a real bear to resolve):

Click here to see stackoverflow thread for detailed instructions on how to do this thru XCode interface



回答5:

If you want to edit the Product Name, rather than remove it; you can set it in your target, using the following steps:

  • Open the Target in XCode
  • Go to the Build Settings tab
  • Scroll down to Packaging->Product Name

The name set in Product Name is added to the Bundle Identifier (spaces are changed to dashes e.g "Test App" becomes "Test-App").



回答6:

It may be that it's set in a .xcconfig file instead. For example, one Parse sample project has a 'debug.xcconfig' with:

BUNDLE_IDENTIFIER = com.parse.Anypic

If so, this is the place to change it.



回答7:

I saw this also happen when the iOS Deployment Target is higher than your version of Xcode supports. Between World Wide Developers Christmas when they release the betas and when the new version is finalized.

So say you have a project with a min deployment for the current iOS beta version, but you are using the release version of Xcode. Just open the project in the current Xcode beta version.



回答8:

This can also be related to user defined variables under [Target] > Build Settings > User-Defined