Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Link Binary with library for debug only

I have a bit of a problem with setting different configuration for my project. I have two versions of the same static library. One has logging enabled, the other doesn't.

I am using two different xcconfig files for Debug vs. Release. In these files I specify the library and header search paths for the two variants of the static lib. So far so good.

However, in my build settings I can't see a way to conditionally link the actual library. I.e use the debug variant for Debug and the release for Release.

Any ideas?

like image 393
John Lane Avatar asked Nov 27 '12 12:11

John Lane


1 Answers

You need to link the library using the "Other Linker Flags" build setting, rather than the standard "Link Binary With Libraries" UI. The build setting can be changed depending on the configuration:

enter image description here

Click the triangle and you can give different values for Debug/Release. You will need to use the -l flag. For example, for a filename of libMyLib.a use the flag -lMyLib. You may need to edit the "Library Search Paths" to search the appropriate location.

If the filenames for the debug and release version are the same and you don't want to change them, put them into their own lib/Debug and lib/Release directories respectively. Then edit the "Library Search Paths" build setting adding either "$SRCROOT/lib/Debug" or "$SRCROOT/lib/Release" for the appropriate configuration.

like image 154
Mike Weller Avatar answered Nov 08 '22 04:11

Mike Weller