问题
I read this documentation article about library and framework linking and the section below drew my attention:
... an Optional framework will be loaded only if needed. The initial load of the application will be faster if a large library that is never needed is designated as Optional.
So I'm asking why wouldn't I set all frameworks as Optional
, if they will load when necessary? What would be the drawback?
回答1:
Using optional libraries requires additional code as it makes use of weak linking:
if (MyWeakLinkedFunction != NULL)
{
result = MyWeakLinkedFunction();
}
That makes using the library something of a pain; I would rather know that the symbols are available when the program loads, and if they are not the O/S can deal with telling the user.
回答2:
I'm guessing because of this line
The initial load of the application...
You might have a "large" load, later in the application if you do set as optionaly, where it might be unwanted. So loading the framework early, will decrease load time later.
That is what I imagine anyway
来源:https://stackoverflow.com/questions/36421099/linking-all-frameworks-as-optional