doorxp

Blog

Xcode Build Setting Transformations

Xcode supports the ability to substitute the value of build settings using the $(BUILD_SETTING_NAME) or ${BUILD_SETTING_NAME} syntax in a number of places including Info.plists, other build setting values, and .xcconfig files. In these substitutions it’s also possible to add operators that transform the value in various ways. You may have seen one of these in the Info.plist included in project templates:

com.company.$(PRODUCT_NAME:rfc1034identifier)

This results in the value of the PRODUCT_NAME build setting being transformed into a representation suitable for use in the reverse DNS format used by CFBundleIdentifier. So if PRODUCT_NAME is “Whatever App” the resulting string is “com.company.Whatever-App”.

These transformations can be quite useful but don’t appear to be documented, so here’s the list of available operators and what they do:

OperatorReturns
identifierA C identifier representation suitable for use in source code.
c99extidentifierLike identifier, but with support for extended characters allowed by C99. Added in Xcode 6.
rfc1034identifierA representation suitable for use in a DNS name.
quoteA representation suitable for use as a shell argument.
lowerA lowercase representation.
upperAn uppercase representation.
standardizepathThe equivalent of calling stringByStandardizingPath on the string.
baseThe base name of a path - the last path component with any extension removed.
dirThe directory portion of a path.
fileThe file portion of a path.
suffixThe extension of a path including the '.' divider.

Note that these operators can be chained, so you can do things like $(PRODUCT_NAME:lower:rfc1034identifier) or $(CONFIGURATION:upper:identifier).


发表评论:

«   2024年11月   »
123
45678910
11121314151617
18192021222324
252627282930
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言

    Powered By Z-BlogPHP 1.5.1 Zero

    Copyright doorxp.com Rights Reserved.