You'll find some official informations about build setting variables here :
.pbbsetspec
)The GUI settings are defined either in a dedicated .pbbsetspec
file or in the
specification file of a compiler (.pbcompspec
) or a linker (.pblinkspec
).
The explainations are illustrated with a compiler specification file.
Some sample compiler/linker definitions with GUI build settings (the syntax may be slightly different from the one defined below because there're several equivalent syntaxes to define options):
/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/GCC.xcspec
/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/Built-in linkers.pblinkspec
The build settings are defined by a property list like the following one :
( { Identifier = com.domain.me.compilers; Name = "My compiler"; … Options = ( { // Bool options can have only two values : NO or YES. Name = OPTION_1; Type = bool; DefaultValue = NO; // You may define how an option must be translated to an argument(s) for the // compiler compand line: CommandLineArgs = { NO = (); // expand to nothing YES = ("-with-opt1") // expand to one argument : -with-opt1 }; Category = "My Category"; }, { // A stringlist is a string containing many string value, separated by space, // like command line arguments in shells. Name = OPTION_2; Type = stringlist; // replace with "pathlist" if the strings in the list are paths UIType = ??; // not documented DefaultValue = ""; // if the option value is «aa bb», Xcode will issue «-I aa -I bb» on the // command line: CommandLineArgs = ("-I", "$(value)"); // will appear after OPTION_1 in the build setting window: AppearsAfter = OPTION_1; // will appear after OPTION_3 on the command line: AppearsOnCommandLineAfter = OPTION_3; // will appear on the command if this value expands to YES: CommandLineCondition = "$(OPTION_1)"; Category = "My Category"; // put option into this group }, { // A string. Name = OPTION_3; Type = string; // replace with "path" if the string represent a path DefaultValue = "I'm the default string"; AvoidEmptyValue = YES; // Show the default value if the user put an empty value CommandLineArgs = ("$(value)"); // option will appear on the command line args only for these architectures: // (only works with compilers, no with linkers) Architectures = (ppc, ppc64); // option will appear on the command line args only for these source file types: FileTypes = (sourcecode.me, sourcode.mebis); Category = "My Other Category"; }, { // Option with predefined choices. Name = OPTION_4; Type = enum; AllowedValues = (VAL1, VAL2, VAL3, VAL4, VAL5); DefaultValue = VAL3; // in this case, $(value) will be VAL3 or VAL4 or VAL5: CommandLineArgs = { VAL1 = (-a); VAL2 = (-b); "<<otherwise>>" = (-custom, "$(value)") }; Category = "My Other Category"; CommonOption = YES; // ?? AdditionalArgsForFixBundlizing = (…); // ?? AdditionalLinkerArgs = (…); // ?? }, ); OptionCategories = ( { Name = "My Category"; IconName = "PBX-option-build"; // or PBX-option-warning PBX-option-language-c PBX-option-language-r }, { Name = "My Other Category"; IconName = "PBX-option-build"; }, ); };
The CommandLineArgs
, Architectures
, FileTypes
keys are
only useful in compiler or linker specification.
If you don't set the Category
key, the option won't appear in the GUI.
If you don't set the CommandLineArgs
key, the option won't be automatically
translated into command line arguments. However, you may treat it in your plugin code (for instance
to do custom stuff) : all options are added to the build environment. You may get the value of the
option OPTION_1
with the following code :
[context expandedValueForString:@"$(OPTION_1)"]
In Xcode 2.0 to 2.2, the build settings defined in the specification of all used compiler/linker will be added to the GUI target inspector. In Xcode 2.3 and later, only settings of used compilers will be shown, and not those of used linkers :-( (it's really annoying !!!).
If you put the option definitions in a .pbbsetspec
, you must define the
specificationToShowInUserInterface
method of your compiler class to inform which
specification should be shown when your compiler is used:
- (XCPropertyDomainSpecification*) specificationToShowInUserInterface { XCPropertyDomainSpecification* spec = [[XCPropertyDomainSpecification specificationRegistry] objectForKey:@"com.domain.buildsettings.mycomp"]; return (XCPropertyDomainSpecification*)[spec loadedSpecification]; }
Be carefull : if you do this (using pbbsetspec files), command line arguments won't be automatically issued.
The human readable names are defined in a .strings
file (in order to be localizable)
named «identifier».strings
(com.domain.me.compilers.strings
for the above
sample):
"[OPTION_1]-name" = "Option 1"; "[OPTION_1]-description" = "Description… [OPTION_1, -with-opt1]"; "[OPTION_2]-name" = "Option 2"; "[OPTION_2]-description" = "Description… [OPTION_2, -I]"; "[OPTION_3]-name" = "Option 3"; "[OPTION_3]-description" = "Description… [OPTION_3]"; "[OPTION_4]-name" = "Option 4"; "[OPTION_4]-value-[VAL1]" = "Value 1"; "[OPTION_4]-value-[VAL2]" = "Value 2"; "[OPTION_4]-value-[VAL3]" = "Value 3"; "[OPTION_4]-value-[VAL4]" = "Value 4"; "[OPTION_4]-value-[VAL5]" = "Value 5"; "[OPTION_4]-description" = "Description… [OPTION_4, -a, -b, -custom]";
Expand variables :
[PBXBuildSetting expandedValueForString:]
[PBXBuildSetting absoluteExpandedPathForString:]
[PBXBuildSetting expandedBooleanValueForString:]
(Xcode >= 2.2)[PBXBuildSetting expandedValueIsNonEmptyForString:]
(Xcode >= 2.2)[PBXBuildSetting expandedValueExistsForString:]
[PBXBuildSetting expandedValueForString:getRecursiveSettingName:options:]
nil
and 1
)Modify string variables :
[PBXBuildSetting setStringValue:forDynamicSetting:]
[PBXBuildSetting removeDynamicSetting:]
Modify string list variables :
[PBXBuildSetting prependStringOrStringListValue:toDynamicSetting:]
[PBXBuildSetting appendStringOrStringListValue:toDynamicSetting:]
[PBXBuildSetting removeStringOrStringListValue:]
Some useful tasks :
[NSString boolValue]
[NSString arrayByParsingAsStringList]
Compute command line arguments from build settings :
Options
key :[XCCommandLineToolSpecification commandLineForAutogeneratedOptionsInTargetBuildContext:]
[XCCommandLineToolSpecification commandLineForAutogeneratedOptionsForKey:inTargetBuildContext:]
For more informations, see the XCPBuildSystem.h
n XCPSpecifications.h
and XCPSupport.h
header files available here.
In many case, it's possible to provide different values when compiling to different architectures
or different variant : MYSETTING_ppc
, MYSETTING_x86
,
MYSETTING_normal
, MYSETTING_debug
, MYSETTING_normal_ppc
.
Variables containing useful paths :
LOCAL_APPS_DIR
(defaults to /Applications
)LOCAL_ADMIN_APPS_DIR
(defaults to /Applications/Utilities
)LOCAL_LIBRARY_DIR
(defaults to /Library
)HOME
(defaults to ~
)USER_APPS_DIR
(defaults to ~/Applications
)USER_LIBRARY_DIR
(defaults to ~/Library
)DEVELOPER_DIR
(defaults to /Developer
)PROJECT_DIR
TARGET_BUILD_DIR
(or BUILT_PRODUCTS_DIR
)BUILD_ROOT
(or BUILD_DIR
)OBJECTS_DIR
(OBJECT_FILE_DIR
, OBJECT_FILE_DIR_$(variant)
, $(OBJFILES_DIR_$(variant))/$(arch)
)DERIVED_FILES_DIR
(or DERIVED_FILE_DIR
or DERIVED_SOURCES_DIR
)TEMP_DIR
PROJECT_TEMP_DIR
CONFIGURATION_TEMP_DIR
Variables used to defined the product :
INSTALL_PATH
. A good value is : $(HOME)/bin
for
command line tools, $(HOME)/Applications
for applications, $(HOME)/Library/Frameworks
for frameworks…PUBLIC_HEADERS_FOLDER_PATH
PRODUCT_NAME
PROJECT_NAME
EXECUTABLE_NAME
. A good value is :$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)
.ARCHS
(see arch
)BUILD_VARIANTS
(see variant
)Variables containing compilation/linking directives :
HEADER_SEARCH_PATHS
LIBRARY_SEARCH_PATHS
FRAMEWORK_SEARCH_PATHS
GENERATE_PROFILING_CODE
LIBRARY_STYLE
(= STATIC
, DYNAMIC
or BUNDLE
)Variables used in compiler specification files (Xcode >= 2.3) :
InputFile
OutputFile
SourceBaseNameUniquefier
ObjectsDir
Variables used during dependency graph creation (lowercase) :
variant
(or CURRENT_VARIANT
)arch
(or CURRENT_ARCH
)object_files_$(variant)_$(arch)
object_files
(Xcode >= 2.3)non_master_object_files
dylib_files
sab_binaries
strippable_linked_product_$(variant)
build_file_compiler_flags
build_file_attributes
compiler_mandated_linker
and compiler_mandated_linker_priority
(use a custom product specification or RequiredLinker
instead)compiler_mandated_librarian
and compiler_mandated_librarian_priority
Other available variables :
CONFIGURATION
(or BUILD_STYLE
)UID
USER
GROUP
BUILD_ACTION
inherited