5 Resources for Dialing in Your Xcode Configuration
Use these five resources to adhere to the best practice of separating your code from your project configurations by breaking them out into standalone xcconfig files.
It is considered a best practice in development to separate code from configuration details. But this can be a challenge in Xcode specifically, because of how thoroughly integrated the configuration controls are within a given project. Moreover, in order to configure a project within the Xcode GUI, you will need to navigate through a slew of tabs – each containing huge numbers of configuration controls and further expandable option sets. This means that in addition to learning and remembering all required configuration details, you will also have to remember how to navigate to each in the GUI.
But there is a solution. Enter the Xcode configuration file, a plain text file with the xcconfig file extension, that allows you to configure a specific build type. Because this file is plain text, you can edit it anywhere and you can easily check it into source control, so as to track changes over time. Xcode configuration files are human-readable lists of key, value pairs that can be associated with a given project, in which they will define and override the build settings for a particular build configuration of a project or target.
The following five resources will help you to better understand what configuration options exist, and how to best separate your Xcode project configurations from a given project in a text-based xcconfig file that you can check into source control.
Five Xcode Configuration Resources
Xcode Build Configuration Files provides a deep dive into configuration files as a way to get around configuring Xcode in the GUI. It covers topics such as creating build configuration files, defaulting to existing configuration values in an Xcode project, and setting conditional configuration values.
The Unofficial Guide to xcconfig files offers a practical guide for writing xcconfig files. The guide covers topics such as general syntax, include statements, variable assignment, build setting inheritance, and more with practical examples.
Xcode Build Settings is a thorough reference that defines each xcconfig value type and meaning. It does a great job of rooting out potential ambiguities with extended definitions of configuration values as needed.
xcconfigs is an open-source project that acts as an aggregator of common and universal Xcode configuration settings. Xcode configuration files are organized hierarchically in order to make them easy to modify and reuse in multiple projects.
ConfigGenerator is a Swift-based command-line interface tool that will extract values from your Xcode project and format them in a human and machine-readable xcconfig file. This can be helpful to see what configurations exist in an Xcode project without the risk of changing things inadvertently, as well as to create files that can be checked into source control directly.
Xcode configuration files allow you to define your build configurations in Xcode in plain text, which helps to satisfy the best practice of strictly separating code from project configuration details. Additionally, because they are plain text files, they can be edited outside of Xcode and checked into source control to track changes over time. The above resources expand on the benefits of this approach, explicitly define the syntax of xcconfig files, and even go so far as to automate the generation of them from the command line.