Xamarin iOS ipa file size issue

元气小坏坏 提交于 2019-12-11 12:54:32

问题


Project structure with PCL based approach:

Project X (solution)

  • Core (Base project with autofac for Ioc based setup)
  • Project (90% of code common for droid and ios)
  • Project.Droid (Droid settings, renderers and graphics. )
  • Project.iOS (iOS settings, renderers and graphics. )

I have gone through all possible options to reduce ipa file size. esp with linking. I have used 'Link all' and stripping debug code, optimizing image etc.

Final ipa size is 77 MB.

Here are the details of file sizes after exploring package contents. I am using arch 7 and 64.

Project.iOS is 42 MB This is bothering. Since I can see dll's and images separately along with this file. Not sure why its taking so much space. Can I reduce the size of it ? This is my priority

dll's are about 15 MB (Xamarin forms, maps, other third party libraries. Since I am targeting for 7 and 64. I see libraryX.dll, libraryX.aotdata.arm64, libraryX.aotdata.arm7) This is right I believe.

Images are about 20 MB

I am planning to reduce even further by using 'https://tinypng.com/' to flaten and putting all images assets for 'thinning'. Also probably wants to use on demand resources option but its low priority

Please let me know. Any help / suggestion would be very much appreciated.

Xamarin Forum link : https://forums.xamarin.com/discussion/103470/xamarin-ios-file-size-is-too-big-tried-all-the-possible-options/p1?new=1

Thank you.


回答1:


Using an icon font would help to reduce the size of your IPA as you would be replacing multiple versions of icons with a vector graphic from the font. I have had a lot of success with this approach. Details here and also here




回答2:


There isn't very much that can be done to minimize the size a part from what you've already done. (linking/link away/strip debug code)
Here you can find a list of best practice to apply to reduce your app's size and there is also a Xamarin section dedicated to Linking on iOS. (limit generics/download resources at runtime/limit structs)

You can dig finding out which assemblies are the most hunger for space.
Check out the mtouch-cache folder of the objfolder of your build:

ls -laS *.o

In my case:

-rw-r--r--  1 hichame.yessou  staff  9276292 Sep 13 10:03 mscorlib.dll.o
-rw-r--r--  1 hichame.yessou  staff  5741840 Sep 13 10:03 Newtonsoft.Json.dll.o
-rw-r--r--  1 hichame.yessou  staff  5359900 Sep 13 10:13 ****.Core.dll.o
-rw-r--r--  1 hichame.yessou  staff  4823812 Sep 13 10:03 System.Core.dll.o
-rw-r--r--  1 hichame.yessou  staff  3929056 Sep 13 10:13 ****.iOS.exe.o
-rw-r--r--  1 hichame.yessou  staff  3729004 Sep 13 10:03 NodaTime.dll.o
-rw-r--r--  1 hichame.yessou  staff  3218980 Sep 13 10:03 System.Xml.dll.o
-rw-r--r--  1 hichame.yessou  staff  3014548 Sep 13 10:03 System.dll.o
-rw-r--r--  1 hichame.yessou  staff  2985844 Sep 13 10:03 Xamarin.iOS.dll.o
-rw-r--r--  1 hichame.yessou  staff  2165576 Sep 13 10:03 Ninject.dll.o
-rw-r--r--  1 hichame.yessou  staff  1686992 Sep 13 10:13 registrar.o
-rw-r--r--  1 hichame.yessou  staff  1569908 Sep 13 10:03 System.Net.Http.dll.o
-rw-r--r--  1 hichame.yessou  staff   903048 Sep 13 10:03 SQLite.Net.dll.o
-rw-r--r--  1 hichame.yessou  staff   620200 Sep 13 10:03 ****-iOS.dll.o
-rw-r--r--  1 hichame.yessou  staff   566972 Sep 13 10:03 ********.dll.o
-rw-r--r--  1 hichame.yessou  staff   430432 Sep 13 10:03 ********.dll.o
-rw-r--r--  1 hichame.yessou  staff   396776 Sep 13 10:03 SDWebImage.dll.o
-rw-r--r--  1 hichame.yessou  staff   318632 Sep 13 10:03 ********.dll.o
-rw-r--r--  1 hichame.yessou  staff   268884 Sep 13 10:03 SwipeTableCellBinding.dll.o
-rw-r--r--  1 hichame.yessou  staff   235960 Sep 13 10:03 Flurl.dll.o
-rw-r--r--  1 hichame.yessou  staff   232304 Sep 13 10:03 MonoTouch.******.dll.o



Secondly, if you try to build an empty Xamarin.iOS project it will result in an 37 MB .ipa, so I do think that it's a resonable size 77 MB for a full project.
Plus, the App Store restriction for WiFi-only apps are set to 100 MB.



来源:https://stackoverflow.com/questions/46286265/xamarin-ios-ipa-file-size-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!