Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the build setting modifiers in Xcode called?

I've seen some build settings being used like

$(PRODUCT_NAME:identifier)

Using :upper also makes the setting value uppercase, but I don't know what those are called and can't find any documentation. Does anyone know their name or where the documentation is to use them properly?

like image 786
Javier C Avatar asked Oct 19 '11 15:10

Javier C


2 Answers

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).

like image 138
chown Avatar answered Nov 22 '22 23:11

chown


Since they are not documented I don't think they have a name. When building Xcode 4 templates I found 3 variable modifiers in the Apple templates that seem to do the following:

  • identifier: ensures that it is a legal C variable name. It replaces illegal characters with underscores.
  • bundleIdentifier: ensures that it is a legal bundle identifier.
  • RFC1034Identifier: ensures that it is a legal domain name.

And thanks to you I know another one:

  • upper: change the value to uppercase.

The Xcode project templates are not documented. They are defined in plists with an inheritance system. Their elements have a defined structure and use several expansion macros with double underscore like __PACKAGENAME__ (also seen in Xcode 3) that are modified with one of the modifiers mentioned above.

If you want to dig further on this I recommend Documentation: Xcode 4 templates. Learning Apple's template system was painful and slow until I stumbled onto this PDF. It's $10/€7,50 but it's worthy. Writing templates remains very cumbersome, I guess Apple engineers use an internal tool or a great deal of patience.

The build settings are called "build settings" and they are documented in the Xcode Build Setting Reference. The Product Name defaults to your target name, but you can make up your own value if you like. These settings are referenced when writing scripts. Usually you don't need to touch anything while using XCode.

like image 45
Jano Avatar answered Nov 23 '22 01:11

Jano