Linking all frameworks as optional

戏子无情 提交于 2021-01-29 04:35:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!