iOS slow startup time

天涯浪子 提交于 2019-12-05 02:23:58

问题


I have project in Swift and when I measure with DYLD_PRINT_STATISTICS I can see 1.0 second pre-init time, where 70% is dynamic libraries linking.

Are there any clean and safe ways of dealing with this problem?


回答1:


According to Apple's WWDC 2016 Session on Optimizing App Startup Time, regardless of their size, having a large number of dynamically linked libraries slows down app launch time dramatically.

To fix this, several dynamic libraries can be merged into a single library. If they are already static libraries, then libtool can be used to combine them, using the command from this SO answer. However, if they are not static, then to combine them, one must have access to their source code. If the source code is accessible, then literally copying the code from one library into another, and using the resulting library, will suffice.

Of course, merging disparate libraries into a single one is definitely inconvenient from the developer's perspective. To combat this, Xcode allows for different libraries to be linked when different flags (i.e. RELEASE and DEBUG) are set, as described in this forum.

When possible, it's better to merge static libraries, as the merging process is far less error prone. CocoaPods allows users to use static libraries in their projects.



来源:https://stackoverflow.com/questions/45388419/ios-slow-startup-time

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