Xcode Info.Plist Build Variable ${Product_Name:Rfc1034Identifier} Seems Completely Undocumented

xcode info.plist build variable ${PRODUCT_NAME:rfc1034identifier} seems completely undocumented?

At long last, Apple produced some documentation on this. This is in the "Text Macros" section of the Xcode manual, as of this date.

Text macro format reference

A text macro can contain any valid unicode text. It can also contain other text macros.

Including other text macros
To include another text macro, add three underscore (_) characters before and after the macro name:

___<MacroName>___

Modifying text macro expansion
You can modify the final expansion of the text macro by adding one or more modifiers. Add a modifier to a text macro by placing a colon (:) at the end of the macro followed by the modifier. Add multiple modifiers by separating each one with a comma (,).

<MACRO>:<modifier>[,<modifier>]…

For example, the following macro will remove the path extension from the FILENAME macro:

FILENAME:deletingPathExtension

To turn the modified macro above into a valid C identifier, add the identifier macro:

FILENAME:deletingPathExtension,identifier

Modifiers

bundleIdentifier: Replaces any non-bundle identifier characters with a hyphen (-).

deletingLastPathComponent: Removes the last path component from the expansion string.

deletingPathExtension: Removes any path extension from the expansion string.

deletingTrailingDot: Removes any trailing dots (.).

identifier: Replaces any non-C identifier characters with an underscore (_).

lastPathComponent: Returns just the last path component of the expansion string.

pathExtension: Returns the path extension of the expansion string.

rfc1034Identifier: Replaces any non-rfc1034 identifier characters with a hyphen (-).

xml: Replaces special xml characters with the corresponding escape string. For example, less-than (<) is replaced with <

TEXT MACROS

Text macros reference

COPYRIGHT
A copyright string that uses the company name of the team for the project. If there is no company name, the string is blank.

The example shows a copyright string when the company is set to “Apple”.

Copyright © 2018 Apple. All rights reserved.

DATE
The current date.

DEFAULTTOOLCHAINSWIFTVERSION
The version of Swift used for the default toolchain.

FILEBASENAME
The name of the current file without any extension.

FILEBASENAMEASIDENTIFIER
The name of the current file encoded as a C identifier.

FILEHEADER
The text placed at the top of every new text file.

FILENAME
The full name of the current file.

FULLUSERNAME
The full name of the current macOS user.

NSHUMANREADABLECOPYRIGHTPLIST
The entry for the human readable copyright string in the Info.plist file of a macOS app target. The value of the macro must include the XML delimiters for the plist. For example, a valid value is:

'''
<key>NSHumanReadableCopyright</key>

<string>Copyright © 2018 Apple, Inc. All rights reserved.</string>

'''

Notice that the value includes a newline.

ORGANIZATIONNAME
The name for your organization that appears in boilerplate text throughout your project folder. The organization name in your project isn’t the same as the organization name that you enter in App Store Connect.

PACKAGENAME
The name of the package built by the current scheme.

PACKAGENAMEASIDENTIFIER
A C-identifier encoded version of the package name built by the current scheme.

PRODUCTNAME
The app name of the product built by the current scheme.

PROJECTNAME
The name of the current project.

RUNNINGMACOSVERSION
The version of macOS that is running Xcode.

TARGETNAME
The name of the current target.

TIME
The current time.

USERNAME
The login name for the current macOS user.

UUID
Returns a unique ID. The first time this macro is used, it generates the ID before returning it. You can use this macro to create multiple unique IDs by using a modifier. Each modifier returns an ID that is unique for that modifier. For example, the first time the UUID:firstPurpose modifier is used, the macro generates and returns a unique ID for that macro and modifier combination. Subsequent uses of the UUID:firstPurpose modifier return the same ID. Adding the UUID:secondPurpose modifier generates and returns a different ID that will be unique to UUID:secondPurpose, and different from the ID for UUID:firstPurpose.

WORKSPACENAME
The name of the current workspace. If there is only one project open, then the name of the current project.

YEAR
The current year as a four-digit number.

Should the rfc1034identifier be removed from the CFBundleIdentifier in plist file?

The :rfc1034identifier just formats it (if needed) so there are no illegal characters* in the bundle name. You're unlikely to have a product that is called by an illegal character but it's not impossible.

I'd leave it in there but it's really up to you.

(Actually, most of the time I just hardcode the bundle - that way if the product name changes for any reason, it's still got the same bundle identifier when I come to update it in the app store)

*such as a space or a dot - they will be replaced with a dash so 'My Game' would become 'My-Game'

How to automatically set a lowercase bundle identifier

Yes. You can use this trick instead of setting the bundle identifier statically:

com.yourcompany.${PRODUCT_NAME:rfc1034identifier:lower}

What are the build setting modifiers in Xcode called?

The file /Developer/Library/PrivateFrameworks/DevToolsCore.framework/Versions/A/DevToolsCore has a bunch of these:

[ 09:22 root@MacBookPro / ]# strings /Developer/Library/PrivateFrameworks/DevToolsCore.framework/Versions/A/DevToolsCore | egrep "(^:|^[a-z0-9]+$)"
:children.count=%lu
:name='%@'
:File='%@':Line=%lu:RefType=%@
:fileRef=%@:timestamp=%lu
:char-range=%@
:line-range=%@
:<range-type-%lu>=%@
:name='%@'
:name=%@:path='%@'
:name='%@'
:name='%@':buildSettings(%lu)=%@
:path='%@'
:quote
:identifier
:rfc1034identifier
:dir
:abs
:remoteRef='%@'
:File='%@':Head Revision=%@:Active Branch=%@
:scmProprties='%@':sandboxEntry='%@'
.... SNIP ....
upper
environment
diagnostics
type
category
description
path
kind
message
ranges
alternate
start
edges
location
file

Found this as well: DevToolsCore Framework Reference. Looks like an API for the Framework (- (id)initWithName:(id)arg1 productTypeIdentifier:(id)arg2).

Couldn't find any other documentation for it though, just this SO question (xcode-info-plist-build-variable-product-namerfc1034identifier-seems-complete).

Product Bundle Identifier name to apply in firebase

You should not modify anything about that PRODUCT_BUNDLE_IDENTIFIER. Well... OK, maybe you can, but there's no need for it. What you have there are the instructions of how Xcode builds the the final bundle ID, so you can replay them to get the same value.

Look up what your PRODUCT_NAME is (see here and here) and then funnel that through a rfc1034identifier "filter" (pretty much replacing spaces and dots with _, as explained here and here. That will give you the final bundle ID that you need to specify in Firebase.



Related Topics



Leave a reply



Submit