OC,Swift混编,Bitcode,cocoapod对ipa大小的影响
2017-09-29 16:00
1966 查看
(结论针对本项目的工程而言,项目不同数据会有所不同):
OC 和swift 混编会让iPA 的包增大20M,即使你只有几个swift 文件,每一个swift文件代码都不多都可能增加20M
bitcode 会让ipa 包增加1.5M左右
cocoapod 的设置Objc打开会增加ipa的大小,几M左右,而且这个Objc 是最好要打开的
文中还使用了RAC ,RAC对ipa的大小影响还没测试,有知道的欢迎给我留言
Snip20160809_11.png
Snip20160809_8.png
Snip20160809_9.png
Snip20160809_10.png
问题:CocoasPod很好,但是-ObjC 在项目中会让所有的对象文件编译到二进制文件中,一个空的工程使用pod AFNetworking和”ObjC”打开,ipa的大小是7M.google map 需要ObjC 打开,这样导致ipa 17M ,所以这个老外想知道, Google Map SDK 的ObjC 打开,AFNetworking 的ObjC 关闭去减少ipa 的大小?\
答案:别人的答案没说怎么办,只是说cocoapod 这么做是为了程序更好的编译.
文中的打包出的ipa大小都包含了RAC 和cocoapad.RAC对ipa的大小影响还没测试,估计在7M以内,
最后的结论见文章开头,有不同的意见欢迎留言
OC 和swift 混编会让iPA 的包增大20M,即使你只有几个swift 文件,每一个swift文件代码都不多都可能增加20M
bitcode 会让ipa 包增加1.5M左右
cocoapod 的设置Objc打开会增加ipa的大小,几M左右,而且这个Objc 是最好要打开的
文中还使用了RAC ,RAC对ipa的大小影响还没测试,有知道的欢迎给我留言
1) oc和swift 混编,bitcode 勾选上,ipa 文件大小49.8M
49.8M有点大 ,30M的时候老板就想更小点,50M老板估计不好接受Snip20160809_11.png
Snip20160809_8.png
2) oc和swift 混编,bitcode 未选上,ipa 文件大小48.4M,比上面减少了1.4M
Snip20160809_9.png
3) 删除项目中的swift 文件,改为纯OC,ipa为29.7M,减少20M啊
Snip20160809_10.png
4) cocoapod中设置Objc 会让ipa 增大
cocoapod这么好用的工具,增大ipa 还是得用的.cocoapod 会让ipa 增大的,我没测试,详情见这位老外的问答.\问题:CocoasPod很好,但是-ObjC 在项目中会让所有的对象文件编译到二进制文件中,一个空的工程使用pod AFNetworking和”ObjC”打开,ipa的大小是7M.google map 需要ObjC 打开,这样导致ipa 17M ,所以这个老外想知道, Google Map SDK 的ObjC 打开,AFNetworking 的ObjC 关闭去减少ipa 的大小?\
答案:别人的答案没说怎么办,只是说cocoapod 这么做是为了程序更好的编译.
CocoasPod is good, But sometimes it's not.Why? Because there is a flag call "-ObjC" in your project.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. 7MB for an empty project, that's suck. Some frameworks like Google Map SDK need the flag "-ObjC" is on.So, if your project with "AFNetworking pod" and "Google Map SDK", it will cause the binary will be 17MB. So my question is:How can I turn off the "-ObjC" flag for special Library?For example, just keep the "-ObjC" for Google Map SDK, but turn it off on AFNetworking.
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: -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.
文中的打包出的ipa大小都包含了RAC 和cocoapad.RAC对ipa的大小影响还没测试,估计在7M以内,
最后的结论见文章开头,有不同的意见欢迎留言
相关文章推荐
- Swift 和 Objective-C 混编后对ipa包大小的影响
- cocoapod Podfile use frameworks swift/oc混编 could not build module xxx
- OC和Swift混编使用Pod管理第三方库的问题
- oc 和swift混编的时候打包ipa安装不了
- iOS开发--Swift 如何完成工程中Swift和OC的混编桥接(Cocoapods同样适用)
- oc 和swift混编的时候打包ipa安装不了
- iOS Swift和OC混编
- iOS开发 项目中Swift与OC混编
- OC和Swift混编
- swift_037(Swift之Swift和OC混编)
- IOS-Swift混编 调用OC的Block
- 如果实现Swift --- OC混编(swift)
- OC与Swift混编
- Swift - 与OC混编时如何创建桥接头文件
- swift和 oc 混编2-备
- OC与swift混编
- iOS开发之swift与OC混编出现的坑,oc中不能对swift的代理进行调用,不能访问swift中的代理,swift中的回调方法
- swift项目桥接通过cocoapods pod下来的第三方oc文件引入不成功
- Swift UI Demo- 表格,标签,文本框,按钮,网络请求Oc混编
- OC和Swift混编