The Xcode project configuration is saved in the project file (`*.xcodeproj`). It is enough for normal-scale application development, but if you develop a middle or large-scale application, you may need more. Moreover, you would like to have more flexible control.
- You would like to define the common macro across multiple projects.
- You would like to change the search path of headers and libraries on each build machine.
- You would like not to save the code signing configuration into the project file.
- You would like to change the build configuration without Xcode.
You can overwrite the project’s configurations by writing them into the configuration setting file. This article explains how to create the Xcode configuration settings file.
Creating the configuration settings file
The configuration settings file is a text file. You can create this using a text editor, but you must set it to the project file. Hence, I suggest making it with Xcode.
The build configuration files are not targeted to a specific build target, even if the configuration is for a particular target.
The syntax of the configuration settings file
The syntax of the configuration settings file is simple. Write the configuration in each line.
Configuration = Value
For example, write the following line if you want to set the
ONLY_ACTIVE_ARCH to be
ONLY_ACTIVE_ARCH = YES
As with Swift code, everything after // until the end of the line is treated as a comment.
Types of the value
The value type differs for each configuration. For example, if you look at the build settings on Xcode, it could be a string or a number. It corresponds to that. The following types are defined.
- Boolean (
- Enumeration (The predefined text)
- Space-separated string list. If a string contains space, surround it with
- Path. The file path and the directory path are in the POSIX form.
- Space-separated path list. If a path contains space, surround it with
Reference to other configuration
If you want to use the value of the other configuration setting, write in the following form.
If you don’t specify the target level configuration value, the project level configuration value will be used. The default value will also be used if the project-level configuration value is not defined. Like this, the inherited value may be used.
To use the inherited value, write the following as a value.
Use it for the configuration supporting multiple values, such as the string list or the path list. You can add the element to the inherited value.
FLAGS = $(inherited) --no-timestamp
If you want to define the platform-specific configurations, write the configuration in
[platform=value]. The two platforms are defined.
sdk: The cross-platform SDK, such as
iphoneos10.2, and so on. You can specify
*as a version for hitting any version.
arch: The CPU architecture.
Both values can be specified simultaneously in the form
configuration[sdk=macos10.12][arch=x86_64] = value.
Import other configuration files
If you want to import other configuration files, use the
In this case, the
Common.xcconfig file is imported. If the file is missing, Xcode will say the warning. However, if you write
#include? statement, Xcode will not display the warning even if the file is missing.
Assign the configuration settings file to the build target
To use the configuration settings file, assign it to the build target with the Xcode.
For example, if you want to assign the
Debug.xcconfig file to the
Debug configuration, click the
None at the line “Example” project in the
The configurations list is available on the Apple Developer Site.