How do I weak link frameworks on Xcode 4?
Go to your project -> Targets -> Build Phases -> Link Binary with Libraries. Then change the library you want to weak-link from “Required” to “Optional”.
Go to your project -> Targets -> Build Phases -> Link Binary with Libraries. Then change the library you want to weak-link from “Required” to “Optional”.
I am puzzled by the answer given by max.haredoom (and that it was accepted). The answer deals with shared libraries and dynamic linking, whereas the question was clearly about the behavior of static linking using static libraries. I believe this is misleading. When linking static libraries, ld does not care about weak/strong symbols by default: … Read more
You can do it, here is an example in C: /* * pWeakValue MUST be an extern const variable, which will be aliased to * pDefaultWeakValue if no real user definition is present, thanks to the * alternatename directive. */ extern const char * pWeakValue; extern const char * pDefaultWeakValue = NULL; #pragma comment(linker, “/alternatename:_pWeakValue=_pDefaultWeakValue”)
TLDR Current: Swift: if #available(iOS 9, *) Obj-C, iOS: if (@available(iOS 11.0, *)) Obj-C, OS X: if (NSClassFromString(@”UIAlertController”)) Legacy: Swift (versions prior to 2.0): if objc_getClass(“UIAlertController”) Obj-C, iOS (versions prior to 4.2): if (NSClassFromString(@”UIAlertController”)) Obj-C, iOS (versions prior to 11.0): if ([UIAlertController class]) Swift 2+ Although historically it’s been recommended to check for capabilities (or … Read more