Xcode is adding a dash to my bundle identifier

bundle-identifier, ios, xcode

Solution

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.

Problem

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?

Original source