美文网首页iOS底层原理
ipa包分析 和 瘦身

ipa包分析 和 瘦身

作者: IreneWang1988 | 来源:发表于2018-08-16 10:07 被阅读0次

ipa包太大,首先分析ipa 包各个部分的占比。查到的资料有如下

https://forums.xamarin.com/discussion/36858/how-to-understand-what-causes-large-ios-executable-size-and-reduce-it

https://stackoverflow.com/questions/23938500/decrease-ios-application-size-to-app-store

https://help.apple.com/xcode/mac/current/#/devbbdc5ce4f

苹果官网中说:

Inspecting an .ipa File

If the universal .ipa or any of the thinned .ipa files are larger than expected, the next step is to look at the thinned app bundle and see what files inside it are taking up the most space. The .ipa files are just a .zip archive that has a particular structure when unzipped.

Simply change the extension of an .ipa file to .zip, then open it with Finder to decompress it. Right-click on the unzipped .app bundle and choose "Show Package Contents" to see the resources inside. This can give you an idea of what is using the most space.

You can examine the compressed size of each item in the .ipa by opening Terminal and executing the following command:

使用这个函数在terminal中分析ipa包,会得到每个文件的压缩比,大小等等。

unzip -lv /path/to/your/thinned_app.ipa

分析我们的ipa包,得到的一个数据是:

Length Method Size Cmpr Date Time CRC-32 Name

--------  ------  ------- ---- ---------- ----- --------  ----

      0  Stored        0  0% 07-03-2018 09:52 00000000  Payload/

      0  Stored        0  0% 07-03-2018 09:53 00000000  Payload/xxx.app/

    3001  Defl:N    2989  0% 07-03-2018 09:23 c9f95b77  Payload/xxx.app/5scales@2x.png

     448  Defl:N      359  20% 07-03-2018 09:23 58d4a00a  Payload/xxx.app/5scales@3x.png

通过整理所有的记录,归结了4类占比:

ImageAssets 84M

Frameworks 36M

外部png 3.6M

代码 28M

其他 10M

首先想到的是压缩图片,使用tinyPng 压缩工具可对图片进行无损压缩,发现一个icon可以从12K 降到3k。 

要求UI同事尽量使用8bit编码的图片,根据苹果官方文档

Use 8-bit Images Where Possible

Using an 8-bit PNG instead of a 32-bit PNG can decrease your image size by 4x,

采用开源项目LSUnusedResources对工程项目文件进行相关条件的筛查,排查出无用的资源和类文件(此排查方式基于项目代码及视图文件对类文件或者资源文件的调用次数进行排查),然后进行人为比对,确认无用或废弃的文件使用该工具进行物理删除。

LSUnusedResources

相关文章

  • ipa包分析 和 瘦身

    ipa包太大,首先分析ipa 包各个部分的占比。查到的资料有如下 https://forums.xamarin.c...

  • ipa和apk简易瘦身

    Material Design风格apk 瘦身ipa 瘦身 一、起因 新版本发布后发现安装包apk和ipa各增加了...

  • IPA包瘦身

    一些老项目战线比较长的,往往经历很多人的手,如果没有统一规范会存在各种风格的代码,并且ipa包日益增大,本文就来简...

  • ipa包瘦身过程

    参考文章1、https://blog.csdn.net/u013236878/article/details/53...

  • 性能优化:iOS APP安装包瘦身

    APP安装包瘦身 安装包(IPA)主要由可执行文件、资源组成 资源优化瘦身 资源(图片、音频、视频等)采取无损压缩...

  • IOS项目(一)安装包瘦身

    安装包组成: 谈到 App 瘦身,最直接的想法莫过于分析一个安装包内部结构,了解其每一部分的来源。解压一个 ipa...

  • iOS代码瘦身实践

    原文iOS代码瘦身实践 1 分析当前ipa的组成 一般一个ipa会包含: 1) 资源文件 本地文件:数据、配置、数...

  • iOS包-(ipa文件)瘦身

    1、下载安装瘦身软件 下载: LSUnusedResources.app.zip或者使用 XCode 编译运行项目...

  • iPa包瘦身处理

    目的: App包大小优化目的,为节省用户下载app流量消耗。 成效: 优化之前App大小50M,优化后App大小3...

  • 安装包(IPA)瘦身

    安装包(IPA)主要由可执行文件、资源组成 资源(图片、音频、视频等) 采取无损压缩 去除没有用到的资源: htt...

网友评论

    本文标题:ipa包分析 和 瘦身

    本文链接:https://www.haomeiwen.com/subject/fxdnbftx.html