How to reduce code size of iPhone app?

心已入冬 提交于 2019-12-03 03:43:06

There are a number of things you could do -- 2.5 MB is a small app.

  • One obvious way is to verify that your binary is in fact stripped. This removes unused references (e.g. functions which are not actually called) and debugging info.

  • Link Time Optimization (LTO) can save you a ton of space, although that applies to the C and C++ aspects of your program. It brought one of my programs down to about 1/5 the size.

  • Play with optimization settings. O3 and O2 often produce a smaller binary than Os.

  • Keep track of your dependent libraries. Their exported symbols may be relatively large.

  • Favor C or C++ for shared libraries in larger projects. If unused, they may be stripped or optimized away.

  • Minimize static data and static functions, restricting their scope to the c, cpp, m, mm file.

I probably wouldn't be overly concerned about the app being 2.5MB, but if you want to do due diligence in making sure you're only including what is really needed, I'd take a look at all of the resource files (images, views, movies, etc) that your project references and make sure that all of them are being used by the application.

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