简体   繁体   English

为什么CocoasPod会增加IPA规模? 如何减小尺寸?

[英]why CocoasPod increase IPA size? how to reduce the size?

CocoasPod is good, But sometimes it's not. CocoasPod很好,但有时它不是。
Why? 为什么? Because there is a flag call "-ObjC" in your project. 因为项目中有一个标志调用“-ObjC”。
It will pull ALL OBJECT FILES into your resulting binary. 它会将所有对象文件拉入生成的二进制文件中。

For example, an empty project with "pod 'AFNetworking'" and the flag "-ObjC" is on, that will cause the binary will be 7MB. 例如,一个带有“pod'AFNetworking'”和标志“-ObjC”的空项目打开,这将导致二进制文件为7MB。 7MB for an empty project, that's suck. 一个空项目7MB,这很糟糕。

Some frameworks like Google Map SDK need the flag "-ObjC" is on. Google Map SDK等一些框架需要标记“-ObjC”。
So, if your project with "AFNetworking pod" and "Google Map SDK", it will cause the binary will be 17MB. 因此,如果您的项目使用“AFNetworking pod”和“Google Map SDK”,则会导致二进制文件为17MB。

So my question is: 所以我的问题是:
How can I turn off the "-ObjC" flag for special Library? 如何关闭特殊库的“-ObjC”标志?
For example, just keep the "-ObjC" for Google Map SDK, but turn it off on AFNetworking. 例如,只需保留Google Map SDK的“-ObjC”,但在AFNetworking上将其关闭。

You should try the answer to this question so as to reduce the .ipa size. 你应该尝试这个问题的答案,以减少.ipa的大小。

In general, adding a static library to your project in Objective-C will pull ALL OBJECT FILES into your resulting binary because cocoa pods installation adds -ObjC flag to your linker settings, and as stated in linker manual: 通常,在Objective-C中向项目添加静态库会将所有OBJECT FILES拉入生成的二进制文件,因为可可pod安装会将-ObjC标志添加到链接器设置中,并且如链接器手册中所述:

 -ObjC Loads all members of static archive libraries that implement an Objective-C class or category. 

This flag included to solve problem with linking categories, because by default linker will not include object files containing only categories into resulting binary. 此标志包含用于解决链接类别的问题,因为默认情况下链接器不会包含仅包含结果二进制类别的对象文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM