xcode 在开发时确定 iOS .app 包大小的最简单方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4446367/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the easiest way to determine an iOS .app bundles size while developing?
提问by radven
It is important to make sure every iOS application submitted to the AppStore is under 20MB in size so that it can be downloaded over-the-air.
确保提交到 AppStore 的每个 iOS 应用程序的大小都小于 20MB,以便可以通过无线方式下载,这一点很重要。
I am working on an app that may be getting close to that limit, and I've discovered that there does not appear to be an easy way to tell the current output .app bundle size from within XCode.
我正在开发一个可能接近该限制的应用程序,我发现似乎没有一种简单的方法可以从 XCode 中判断当前输出 .app 包的大小。
In XCode4 in particular - by default every build is tucked away in a hard to get at and cryptically named temp directory. I don't want to override this default behavior unless I have to.
特别是在 XCode4 中 - 默认情况下,每个构建都隐藏在一个难以访问且名称隐秘的临时目录中。除非必须,否则我不想覆盖此默认行为。
I know I can track down the .app bundle by looking at the build logs, opening a shell window, changing to that directory, and using 'du' - but I am hoping to find a quicker and easier way to keep track of the .app file size after each new build.
我知道我可以通过查看构建日志、打开 shell 窗口、更改到该目录并使用“du”来跟踪 .app 包 - 但我希望找到一种更快、更简单的方法来跟踪 .app 包。每次新构建后的应用程序文件大小。
There isn't even an easy way directly on an iPhone or iPad to determine the size of an application. Mostly I appreciate this - but not when I am in the midst of optimization.
甚至没有直接在 iPhone 或 iPad 上确定应用程序大小的简单方法。大多数情况下,我很欣赏这一点 - 但在我进行优化时则不然。
Any thoughts on best practices?
关于最佳实践的任何想法?
UPDATE: I am using XCode 4 now for most of my day-to-day development, and it seems that every solution so far doesn't work on XCode 4 either because functionality has changed or features (such as Archiving) are still coming soon. I think the ultimate answer may be "use XCode 3" for the particular phase of development. I know I will still need to use XCode 3 for the final build and submission anyway...
更新:我现在在大部分日常开发中都使用 XCode 4,而且似乎迄今为止的每个解决方案都不适用于 XCode 4,因为功能已更改或功能(例如存档)即将推出. 我认为最终的答案可能是在特定的开发阶段“使用 XCode 3”。我知道无论如何我仍然需要使用 XCode 3 进行最终构建和提交......
采纳答案by hotpaw2
Create a script (perl, bash, AppleScript, whatever...) and add it to your Build Scripts. The script can then cd to magic location, zip the .app to /tmp, du -s -h the resulting zip, and pipe the output to some log file... maybe even flash bright red warning lights hooked to a USB parallel port relay to warn you of exceeding some file size limit.
创建一个脚本(perl、bash、AppleScript 等等)并将其添加到您的构建脚本中。然后脚本可以 cd 到魔法位置,将 .app 压缩到 /tmp,du -s -h 生成的 zip,并将输出通过管道传输到某个日志文件......甚至可能闪烁亮红色警告灯连接到 USB 并行端口中继警告您超出某些文件大小限制。
回答by Martin Cote
Where I work, we make an archive form Xcode (Build and Archive) and then we export that archive on the disk from the Organizer Window (using the Share button).
在我工作的地方,我们制作了一个存档形式 Xcode(构建和存档),然后我们从管理器窗口(使用共享按钮)导出磁盘上的存档。
This will generate an .ipa file. The size of that file is what you're looking for.
这将生成一个 .ipa 文件。该文件的大小就是您要查找的大小。
回答by aepryus
There should be a 'Products' folder in your Xcode project. Inside that folder will be your .app files. Right click on your file and select 'Reveal in Finder'.
您的 Xcode 项目中应该有一个“产品”文件夹。该文件夹内将是您的 .app 文件。右键单击您的文件并选择“在 Finder 中显示”。
回答by ughoavgfhw
Actually, it is the size of the .ipa, not the .app, that has to be under 20MB. Since .ipa is a zip archive, you get a little more space to work with. The only way of finding the size that I know of would be to do a Build and Archive in XCode and look at the file size in Finder.
实际上,是 .ipa 的大小,而不是 .app 的大小,必须小于 20MB。由于 .ipa 是一个 zip 存档文件,因此您可以获得更多的工作空间。找到我所知道的大小的唯一方法是在 XCode 中进行构建和存档,然后在 Finder 中查看文件大小。
回答by SK9
The file you send to Apple is a .zip file, it's your compressed binary file. For example I'm working on an app that's over 120mb uncompressed but compresses to about 19mb as it's mostly data. I'd guess you have plenty of slack is most of your files aren't a compressed format.
您发送给 Apple 的文件是 .zip 文件,它是您的压缩二进制文件。例如,我正在开发一个未压缩超过 120mb 但压缩到大约 19mb 的应用程序,因为它主要是数据。我猜你有很多松懈,因为你的大部分文件都不是压缩格式。