安利一个小工具 用于分析 iOS 包大小

2016-12-30 13:50:11 +08:00
 guomiaoyou7784

LinkMapAnalyzer

基于项目工程编译链接产生的 Linkmap 文件,分析项目中各个模块的大小。

使用时要确保项目的 Build Settings -> Write Link Map File 已置为YES。然后在Path to Link Map File表明的路径里找到自己工程生成的 LinkMap 文件

如 LinkMap 文件内容大致为

# Path: /Users/guomiaoyou/Library/Developer/Xcode/DerivedData/GAG-focyaelrlonzsogsgfnrfxjywimo/Build/Products/Debug-iphonesimulator/GAG.app/GAG
# Arch: x86_64
# Object files:
[  0] linker synthesized
[  1] /Users/guomiaoyou/Library/Developer/Xcode/DerivedData/GAG-focyaelrlonzsogsgfnrfxjywimo/Build/Intermediates/GAG.build/Debug-iphonesimulator/GAG.build/GAG.app.xcent
[  2] /Users/guomiaoyou/Library/Developer/Xcode/DerivedData/GAG-focyaelrlonzsogsgfnrfxjywimo/Build/Intermediates/GAG.build/Debug-iphonesimulator/GAG.build/Objects-normal/x86_64/GMYListItem.o
[  3] /Users/guomiaoyou/Library/Developer/Xcode/DerivedData/GAG-focyaelrlonzsogsgfnrfxjywimo/Build/Intermediates/GAG.build/Debug-iphonesimulator/GAG.
...
<<dead>> 	0x00000007	[ 44] literal string: length
<<dead>> 	0x00000006	[ 44] literal string: alloc
<<dead>> 	0x00000008	[ 44] literal string: CGImage
<<dead>> 	0x00000011	[ 44] literal string: imageOrientation
<<dead>> 	0x00000023	[ 44] literal string: initWithCGImage:scale:orientation:
<<dead>> 	0x00000018	[ 44] CIE

LinkMapAnalyzer 分析结果各个模块大小为:

# Path: /Users/guomiaoyou/Library/Developer/Xcode/DerivedData/GAG-focyaelrlonzsogsgfnrfxjywimo/Build/Products/Debug-iphonesimulator/GAG.app/GAG
# Arch: x86_64
[debug]: 0-unknownFile-unknownModule
[debug]: read file line count = 11811
libAFNetworking.a                                                       314.20KB
libSDWebImage.a                                                         194.45KB
libMasonry.a                                                             94.99KB
GAG                                                                      55.24KB
libSVPullToRefresh.a                                                     43.88KB
libarclite_iphonesimulator.a                                              7.43KB
unknownModule                                                             2.04KB
libPods-GAG.a                                                             0.25KB



[-] totalSize : 0.695766MB
[-] Cast Time : 8

4768 次点击
所在节点    iDev
4 条回复
lynulzy
2016-12-30 15:01:03 +08:00
很方便
guomiaoyou7784
2016-12-30 16:14:37 +08:00
@lynulzy 谢谢支持。
XuYanci
2017-03-02 08:22:38 +08:00
能够分析不止是静态 目标文件等大小就更棒了
guomiaoyou7784
2017-03-02 10:57:58 +08:00
@XuYanci 可以讲讲你的具体需求吗?或者在 github 上给我提 issue ,我会抽空解决的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/331219

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX