I'm trying to condtionally link in. .a static libraries开发者_如何学Go 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.
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
.
精彩评论