Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditionally including a library for different iOS SDK versions?

I'm sure this has got a simple answer, but it's stumping me :(

I'm trying to build an app that will run on iOS versions 4.3 and 5.0. I'm fine with the idea of checking for capabilities at runtime with -respondsToSelector, but in order to use the Twitter functionality I need to include the Twitter library.

That causes the compiler to fail when building for 4.3, which I'd expect. According to the Apple docs (at the very bottom of this page), it's possible to link frameworks conditionally - but I cannot for the life of me figure out how to set the Other Linker flags to do this. Can anyone tell me how this is done?

like image 892
TimD Avatar asked Oct 11 '11 09:10

TimD


2 Answers

You should also link the framework with the flag "Optional". You can set this at the "Build Phases" panel at the point "Link Binary With Libraries".

see the image , you can switch "Required" to "Optional"

you can switch "Required" to "Optional"

like image 139
Jonas Schnelli Avatar answered Oct 06 '22 14:10

Jonas Schnelli


In your Target -> Build Settings, search for Other Linker Flags and click on the type of release (Debug or Release) and then on the bottom right, click Add Build Setting -> Add Conditional Setting and that will give you the SDK popup and the ability to specify any additional flags.

like image 24
Suhail Patel Avatar answered Oct 06 '22 15:10

Suhail Patel