Xcode is adding a dash to my bundle identifier
Asked Answered
N

2

13

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?

Noblesse answered 28/5, 2014 at 20:44 Comment(1)
Far as I know when it replaces disallowed characters it replaces them with hyphens.Messalina
C
14

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.

Chau answered 28/5, 2014 at 20:51 Comment(2)
Can you provide link to the Apple doc that has it please? I tried finding it myself but couldn't locate.Laomedon
Also, apparently, it cannot start with numbers.Syncytium
E
6

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.

Ensure answered 28/5, 2014 at 20:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.