无效的可执行文件大小 - 来自 iTunes Connect [英] Invalid Executable Size - From iTunes Connect

查看:25
本文介绍了无效的可执行文件大小 - 来自 iTunes Connect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 iTunes 上上传我的 iOS 应用程序.我正在使用 MonoTouch 为 iOS 编译我的 LibGdx 游戏.在 Android 中,它几乎是 7-8mb.但是当我在 iTunes AppStore 上传时,它会变成 78 mb.我不知道为什么?请告诉我.

I am uploading my iOS application on iTunes. I am using MonoTouch for compiling my LibGdx Game for iOS. In Android it is hardly 7-8mb. But When I upload on iTunes AppStore then its goes to 78 mb. I dont know why ? Please Let me know.

我也收到了来自 Apple 的此错误消息.

I have also received this error from Apple.

亲爱的开发者:

我们发现您最近交付的Run Panda Run:Racing"有一个或多个问题.要处理您的交付,必须更正以下问题:

We have discovered one or more issues with your recent delivery for "Run Panda Run: Racing". To process your delivery, the following issues must be corrected:

无效的可执行文件大小 - 72037504 字节的可执行文件大小超过了 60 MB 的最大允许大小.

Invalid Executable Size - The executable size of 72037504 bytes exceeds the maximum allowed size of 60 MB.

推荐答案

如果没有更多细节,很难给出确定的答案.有很多因素会影响应用程序的大小.很多.让我们从基本开始.

It's hard to give a definite answer without more details. There's a lot of things that can affect the size of the applications. Let's start with the basic.

您应该检查的内容:

  • 首先,确保您的应用程序使用不链接构建.这将创建非常大的应用程序,因为您将几乎使用 Xamarin.iOS 提供的完整 .NET 框架;

  • First, ensure that your application is not being build with Don't link. That will create very big applications since you'll be AOT'ing nearly the full .NET framework that Xamarin.iOS ships;

其次,确保您为单一架构 (ARMv7) 构建.FAT 二进制文件(例如 ARMv7 和 ARMv7s)被构建两次,需要两倍的空间;

Second, make sure you're building for a single architecture (ARMv7). FAT binaries (e.g. ARMv7 and ARMv7s) are build two times and needs twice the space;

第三确保您没有启用调试构建(在发布构建中可以这样做,它是一个复选框).这将创建更大的二进制文件以支持调试;

Third make sure you have not enabled the Debug build (it's possible to do so in Release build, it's a checkbox). That will create larger binaries to support debugging;

第四,确保您使用的是 LLVM 编译器.编译需要更多时间,但它生成更好(和更小)的代码;

Fourth make sure you're using the LLVM compiler. It takes more time to compile but it generates better (and smaller) code;

这些初始检查非常容易进行,并且是获得非常大的二进制文件的最常见原因.

Those initial checks are pretty easy to do and are the most common reasons for getting very large binaries.

要了解大小的来源,您需要了解应用程序的构建方式.

To understand where the size come from you need to know how the application are built.

  • Android 和 iOS 版本之间的主要区别在于 iOS 上不允许 JIT'ing(即时编译)(Apple 的规则).

  • The main difference between the Android and iOS version is that JIT'ing (just-in-time compilation) is not allowed on iOS (Apple's rules).

这意味着代码必须经过 AOT 处理(提前编译),并且该过程会创建更大的可执行文件(因为 IL 比本机代码更紧凑);

That means the code must be AOT'ed (ahead-of-time compilation) and that process creates much larger executables (because IL is way more compact than native code);

如果您的代码是泛型的,那么最终的二进制文件可能会变得非常大,因为它需要本地编译所有泛型的可能性(许多情况可以共享,但值类型不能).

If your code is generic-heavy then the final binary can get quite large since it will need to natively compile every generic possibilities (many cases can be shared, but value-types cannot).

您可以采取哪些措施来减小尺寸:

  • 首先尝试减少您的托管代码大小.做到这一点的简单方法是在每个程序集上启用链接器,即在您的项目选项中链接所有程序集.
  • First try to reduce your managed code size. The easy way to do this is the enable the linker on every assemblies, i.e. Link all assemblies in your project options.

许多人认为链接他们自己的代码不值得 - 因为他们知道在运行时需要它(因此链接器无法删除它),否则他们不会编写该代码.

Many people think it's not worth linking their own code - because they know it will be needed at runtime (so the linker cannot remove it) or else they would not have written that code.

说对了一半.链接器可能无法删除您的大部分应用程序代码但是如果您使用的是 3rd 方程序集,它们不太可能 100% 使用.链接器可以删除额外的代码(并且还可以从 SDK 中删除所有为支持不需要的代码而保留的代码).您拥有的共享代码越多,链接器就越能帮助您.

That's half true. The linker might not be able to remove most of your application code but if you're using 3rd party assemblies they are not likely 100% used. The linker can remove that extra code (and also remove, from the SDK, all the code that is kept to support that unneeded code). The more shared code you have the more the linker can help you.

更少的 IL 代码意味着更快的 AOT 时间,这意味着更快的构建更小的最终二进制文件(包括可执行文件的大小).

Less IL code means faster AOT time, which translate to faster builds and smaller final binaires (including the executable size).

注意:关于如何控制链接器跳过处理/删除某些程序集、某些类型或方法的文档和博客条目很多.

Note: there's a lot of documents and blog entries on how you can control the linker to skip some assemblies, some types or method from being processed/removed.

  • 第二次尝试减小您的原生大小.如果您正在构建本机库,请再次查看它们,因为它们将静态(非动态)链接到您的最终二进制文件(iOS 应用程序的另一条规则).其中一些在您的最终二进制文件中可能不值得(在功能方面)它们的权重(并且可能有更轻的替代方案).
  • Second try to reduce your native size. If you're building native libraries then have a second look at them as they will be statically (not dynamically) linked to your final binary (another rule for iOS applications). Some of them might not be worth (feature wise) their weight in your final binary (and there might be lighter alternatives).

这篇关于无效的可执行文件大小 - 来自 iTunes Connect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆