Xcode: How to set debug environment with multiple xcconfig files?
Asked Answered
S

4

17

I'm using Xcode 3.2 with xcconfig files. The files are organized by target. For example, I have a debug.xcconfig file and a release.xcconfig one. Both uses common settings, so I added a shared.xcconfig file which is included by both.

The shared.xcconfig file looks like this:

GCC_C_LANGUAGE_STANDARD = c99
GCC_WARN_ABOUT_RETURN_TYPE = YES
GCC_WARN_UNUSED_VARIABLE = YES
GCC_PREPROCESSOR_DEFINITIONS = SOME_COMMON_DEFINITIONS

The debug.xcconfig file looks like this:

#include "Shared.xcconfig"
GCC_OPTIMIZATION_LEVEL = 0

Now, I would like to add a DEBUG preprocessor definition in the debug.xcconfig file. As shown in this question, the following method is supposed to work:

GCC_PREPROCESSOR_DEFINITIONS = "$(GCC_PREPROCESSOR_DEFINITIONS) DEBUG"

This doesn't work in Xcode 3.2. The Xcode documentation also explicitly mention that modifying variables is not possible, you can only overwrite them.

How would you guys solve this problem?

Substantialize answered 9/9, 2009 at 23:17 Comment(0)
A
19

The way we have tackled this in the past is to have each layer compose a subset of the definitions, then bring them all together at the leaf-level xcconfig.

In shared.xcconfig:

GCC_PREPROCESSOR_DEFINITIONS_SHARED = qFoo qBar qBaz

In debug.xcconfig:

GCC_PREPROCESSOR_DEFINITIONS_DEBUG = qDebug
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_SHARED) $(GCC_PREPROCESSOR_DEFINITIONS_DEBUG)

(The advantage to making the subset variables verbose is that they are lexicographically similar to the value they are used to compose, making them easier to find in the config file.)

Alexandrine answered 9/9, 2009 at 23:30 Comment(1)
Another solution, if you can't easily edit the variable name in the xcconfig you include, is to set the xcconfig you want to include for the project and you more specific one for the target. This will make inheritance work. See this Github issue comment for more info: github.com/CocoaPods/CocoaPods/issues/…Theorist
C
5

You could also use the following format in a .xcconfig file. (works in xcode 4, not tested in xcode 3 ). Its only an example, seems to works for all settings.

ARCHS=i386 x86_64
ARCHS[config=Debug]=i386
ARCHS[config=Release]=i386 x86_64
Cradlesong answered 7/1, 2013 at 14:52 Comment(0)
O
2

Following should work :

xcodebuild GCC_PREPROCESSOR_DEFINITIONS='$(value) BAR=1'
Obelia answered 27/9, 2012 at 19:21 Comment(0)
B
-3

How about using $(inherited)?

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) DEBUG

Beethoven answered 26/10, 2011 at 18:38 Comment(1)
Would be nice if it worked, but unfortunately it doesn't in .xcconfig files.Curitiba

© 2022 - 2024 — McMap. All rights reserved.