Firstly: don't query the OS version for guessing what is supported, check if a particular feature is actually available instead of using it based on assumptions.
That said, recent versions of iOS and the toolchain support weak linking. Just check for the class you're intending to use is not Nil
(method #1). You can also use the Objective-C runtime for this (method #2):
// method #1 - weak linking
if ([SLRequest class] != Nil) {
// Social.framework is available
}
// method #2 - querying the runtime
if (NSClassFromString(@"SLRequest") != Nil) {
// Social.framework is available
}
For weak linkage to take effect, the frameworks you intend to use like this shall be added as "optional" instead of as "required". If you don't use Xcode or an IDE but only a command line toolchain, weak linkage can be enforced by passing
-flat_namespace -undefined dynamic_lookup
to the linker.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…