Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode is adding a dash to my bundle identifier

I can't seem to figure out the discrepancy here. My app is named Monsters! So in the plist, the Bundle Identifier is

com.businessname.${PRODUCT_NAME:rfc1034identifier}

from what I understand :rfc1034identifier removes forbidden characters from the Bundle ID, in my case the ! at the end of Monsters!

But for some reason, when I go to my Project Settings, Xcode is giving me a Bundle Identifier of

com.businessname.Monsters-

I realize I can go into the plist and just hardcode my Bundle Identifier but does anyone know where or why that - is being added?

like image 687
Lucian Thorr Avatar asked May 28 '14 20:05

Lucian Thorr


People also ask

Can I change bundle identifier in XCode?

Change the Bundle IDChoose your project from the left side, then your app target under TARGETS, select the General tab and rename the Bundle Identifier.

What is the difference between app ID and bundle ID in iOS?

An App ID is a string used to identify one or more apps from a single development team. The string consists of two parts, the Team ID and the bundle ID separated by a period (.). The Team ID is supplied by Apple, while the bundle ID is supplied by the developer.

What is XCode bundle ID?

Bundle ID is a unique id you give to your app bundle. No two apps in whole Apple ecosystem can have same bundle id. People generally use reverse domain nomenclature for this. For example if your organization name is quora, you use com.


2 Answers

The allowed characters for bundle identifier are the same as those from DNS. So you can't put any spaces, quotes, etc. For your situation in particular, I think best idea is to manually edit the bundle id with a valid identifier instead of using the product name.

As per Apple doc:

This string must be a uniform type identifier (UTI) that contains only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.) characters.

Anything not conforming to this standard will be automatically replaced with dash because only dash and period characters are valid. Previously to this, application were getting rejected when not following this rule. So to answer your question, its a measure preventing your app to be rejected when submitting it in store.

like image 124
Vlad Avatar answered Oct 03 '22 05:10

Vlad


Xcode is replacing the bad character with a non-bad character. They arbitrarily chose -.

Instead of using ${PRODUCT_NAME:rfc1034identifier}, I would define a new setting with a value that is your product name without the ! and use it instead.

Go to your Project settings and under Build Settings there should be a User-Defined section. Add a new setting by clicking the + button at the top near where it says "Basic All | Combined Levels | + ". Call it PRODUCT_NAME_SAFE and give it the value Monsters. Then set your Bundle ID to be com.businessname.${PRODUCT_NAME_SAFE}.

There are probably other variations on this solution that will work too, depending on your needs.

like image 33
i_am_jorf Avatar answered Oct 03 '22 04:10

i_am_jorf