drunknbass
drunknbass

Reputation: 1672

target conditional library search paths xcode

I'm trying to condtionally link in. .a static libraries by defines. Is this possible in xcode? Basically trying to wrap library specific code in ifdefs so it can be excluded at compile time by setting flags.

Upvotes: 0

Views: 781

Answers (1)

Chris Hanson
Chris Hanson

Reputation: 55116

No, a C #define is not at the same level as library linkage.

However, you can set a C #define (via the Preprocessor Macros build setting) from the value of a custom build setting, like BUILT_WITH_FOO, and also set your OTHER_LDFLAGS build setting based on that custom build setting as well.

For example:

BUILT_WITH_FOO = foo

GCC_PREPROCESSOR_DEFINITIONS_ = USING_FOO=0
GCC_PREPROCESSOR_DEFINITIONS_foo = USING_FOO=1
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_$(BUILT_WITH_FOO))

OTHER_LDFLAGS_ = -lsomething
OTHER_LDFLAGS_foo = -lsomething -lfoo
OTHER_LDFLAGS = $(OTHER_LDFLAGS_$(BUILT_WITH_FOO))

The above would let you adjust only the value of the BUILT_WITH_FOO build setting to choose whether to use the Preprocessor Macros and Other Linker Flags variants whose names end with a trailing _, or the ones whose names end with a trailing _foo.

Upvotes: 1

Related Questions