如何减少iPhone应用程序的代码大小? [英] How to reduce code size of iPhone app?

查看:116
本文介绍了如何减少iPhone应用程序的代码大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPhone应用程序已准备好投入生产,我们希望尽可能多地填充数据。当我为我的应用程序生成.app文件时,我看到一个名为< executable name>的文件。我假设是编译的代码。它大概是2.5兆,对于我在我的应用程序中包含的内容来说似乎很大。我应该检查什么类型的东西以确保我的可执行文件中没有包含任何不需要的项目?

My iPhone app is getting ready to go to production and we like to cram in as much data as possible. When I poke around the generated .app file for my application I see a file named <executable name> which I assume is the compiled code. It is about 2.5 megs which seem large for what I am including in my app. What type of things should I check to make sure there aren't any unneeded items being included into my executable?

推荐答案

你可以做的很多事情 - 2.5 MB是一个小应用程序。

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.

链接时间优化(LTO)可以为您节省大量空间,这适用于程序的C和C ++方面。它将我的一个程序降低到大小的1/5。

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.

使用优化设置进行游戏。 O3 O2 通常会产生比 Os 更小的二进制文件。

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.

在大型项目中使用C或C ++来共享库。如果未使用,它们可能会被剥离或优化。

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

最小化静态数据和 static 函数,将其范围限制为c,cpp,m,mm文件。

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

这篇关于如何减少iPhone应用程序的代码大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆