我正在尝试减小ipa大小,但无法成功。我尝试仅链接SDK程序集,但在存档应用程序时,它显示了189 MB的应用程序商店和75mb的ipa。我尝试了其他选择,但没有成功。
然后,我查看了我的bin文件夹,发现Xamarin.swift4占用了大约80 MB的大小,当我删除该软件包时,我的ipda减小到了34mb,而playstore的大小减小到了89 MB,但是由于打开后,我的应用立即崩溃。因此,这意味着我无法删除Xamarin.swift 4库。
我已经附加了bin文件夹pic和packages.congifg文件,请告知是否有解决办法
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Answers" version="1.4" targetFramework="xamarinios10" />
<package id="Crashlytics" version="1.4" targetFramework="xamarinios10" />
<package id="dannycabrera.GetiOSModel" version="1.4.0" targetFramework="xamarinios10" />
<package id="Fabric" version="1.4" targetFramework="xamarinios10" />
<package id="iOSCharts" version="3.1.1.2" targetFramework="xamarinios10" />
<package id="Microsoft.CSharp" version="4.4.1" targetFramework="xamarinios10" />
<package id="Microsoft.NETCore.Platforms" version="2.0.2" targetFramework="xamarinios10" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="xamarinios10" />
<package id="NETStandard.Library" version="2.0.3" targetFramework="xamarinios10" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="xamarinios10" />
<package id="System.AppContext" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Collections" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.ComponentModel.TypeConverter" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Console" version="4.3.1" targetFramework="xamarinios10" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Globalization" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.IO" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Linq" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Net.Http" version="4.3.3" targetFramework="xamarinios10" />
<package id="System.Net.Primitives" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Reflection" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Runtime" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Runtime.Serialization.Formatters" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="xamarinios10" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="xamarinios10" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Threading" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Xml.ReaderWriter" version="4.3.1" targetFramework="xamarinios10" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="xamarinios10" />
<package id="UITextFieldShaker" version="2017.10.19" targetFramework="xamarinios10" />
<package id="Xam.Plugin.Connectivity" version="3.1.1" targetFramework="xamarinios10" />
<package id="Xamarin.Forms" version="3.0.0.446417" targetFramework="xamarinios10" />
<package id="ZXing.Net.Mobile" version="2.3.2" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4" version="4.0.0.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.Core" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.CoreAudio" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.CoreData" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.CoreFoundation" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.CoreGraphics" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.CoreImage" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.CoreMedia" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.Darwin" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.Dispatch" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.Foundation" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.Metal" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.ObjectiveC" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.OS" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.QuartzCore" version="4.1.0" targetFramework="xamarinios10" />
<package id="Xamarin.Swift4.UIKit" version="4.1.0" targetFramework="xamarinios10" />
</packages>
答案 0 :(得分:0)
您应仅删除仅项目中未使用的库。 两周前,我的ipa文件将近200 MB,然后我删除了该项目不需要的所有Swift库,现在我创建的ipa文件比上一个要小(80 MB)。 因此,您需要检查您的应用程序,看看是否有不必要的库并将其删除,这样可以减小ipa大小。
答案 1 :(得分:0)
我建议您查看“链接器”,您可以在Visual Studio的iOS构建选项中找到该链接器
简要概述:
请注意,“链接所有程序集”可能会引起问题,因为链接器无法始终确定要使用的内容,因此可以从实际所需的程序集中删除代码(请考虑Web服务,反射,序列化)。在这种情况下,您可以设置一个手动的mtouch参数,以防止链接程序触及一个或多个特定程序集,如下所示:
--linkskip=NameOfAssemblyToSkipWithoutFileExtension
或
--linkskip=NameOfFirstAssembly --linkskip=NameOfSecondAssembly
我遇到的一个实际用例是,在Xamarin.iOS上使用Entity Framework时,需要执行上述操作,因为链接器会删除代码,然后使用反射将其调用,从而导致应用程序崩溃。
链接器的完整文档可在此处找到:https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/linker?tabs=vsmac