Tony Edgecombe

Xcode Linking

24 Dec 2010

I've just started a cross platform project in Xcode and one of the problems I came across is it doesn't seem possible to link to different libraries depending on whether you are building the Debug or Release configuration.

I did find an old message on the Apple developer forums that indicates you can do this with dependent projects, the trouble with this is when you clean your target all the dependent projects will clean as well.

In the end I did find a method that works for my project. The trick is to add a "Library Search Path" with the BUILD_STYLE environment variable:

/path/to/mylibrary/build/$(BUILDSTYLE)/x8664

The $(BUILD_STYLE) macro gets expanded to Debug or Release depending on which configuration I am using, I just need to make sure the libraries are created in the appropriate folders.

I can then add the libraries using the setting "Other linker flags" with the -l option:

-l mylibraryname

Not as nice as the Visual Studio solution but it does seem to work.