Under Linked frameworks and libraries there is a Required or Optional option.
Could somebody explain a situation in which and how to work with an optional framework? I could see hypothetically a situation where I have some test data and IF the framework is included I would want to enable some sort of functionality and if it is not included than perhaps I wouldn't do something....
But otherwise I'm at a loss as to when you would want to use an optional framework
(a code example would be awesome if one exists)
Optional linking is useful if you're targeting older OS versions where a certain framework might not be available yet. In this case you can set the linkage of the given framework to optional, and this causes the program not to crash on launch if dlopen
cannot find the given framework.
Then in your code you can put guard statements around the usage of this framework in order to avoid crashing b/c of using unresolved symbols:
if (MyWeakLinkedFunction != NULL)
{
result = MyWeakLinkedFunction(); // this function comes from a weakly/optionally linked framework
}
See: Frameworks and Weak Linking
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With