I know that it is possible to add a "style sheet" like item in Xcode Workspaces. I would like to see a "how to do this" and an example. I currently have a workspace with a few projects and would like to roll up some Build Settings.
XCode Workspace How To Add Same as Visual Studio Style Sheet
160 views Asked by ort11 At
1
I gather that by "style sheet" you mean a group of settings that can be applied to each project within an Xcode worksheet (for example, ensuring that different projects use the same set of compiler flags). This is done by using .xcconfig files ("Configuration settings files") as the basis for configurations within each project.
First, start by creating a new .xcconfig file. In Xcode, choose File > New > File... and select "Configuration settings file" from the Other file group. Give your .xcconfig file a name and save it to the root of your source directory. It should appear in the top level of your workspace in the Groups and Files panel.
The syntax of an .xcconfig file is simply a series of lines of the form
SETTING = <value>
, whereSETTING
is the name of an Xcode build setting and<value>
is the desired value. The setting name can be found in the Quick Help inspector when the setting is selected in the Build Settings panel for a target. (Settings cannot cross line boundaries, and//
is used for comments.)As a shortcut, you can select a setting, choose Edit > Copy, switch back to the .xcconfig file, and paste the text (the setting name) into the file. If you have specified a value for the setting, the value will be copied as well, so you can use this to set up a base .xcconfig file pretty quickly.
Once you have entered your settings, you use the .xcconfig file as a basis for a project configuration, but to do so, the .xcconfig file must be referenced by the project. So in the Groups and Files panel, drag the .xcconfig from the top level of the workspace to under each project in which you want to use it. Then, go to the project's Info panel and locate the Configurations section. For each configuration in which you wish to use the .xcconfig file, locate the corresponding project or target(s), and choose your .xcconfig file using the popup under "Based on Configuration File".
Obviously you can use different configuration files for different configurations (e.g. "Config.Debug" and "Config.Release"). You can even have a common group of settings in a common .xcconfig file, which you then #include from each configuration-specific .xcconfig file (using the syntax
#include "Config.Common.xcconfig"
).