8

我用 Xcode 6.1 和 swift 制作了一个非常简单的 iPhone 应用程序。我对 ios 开发真的很陌生,并遇到了一个最终为 134 mb 的应用程序!当然这是不可接受的。

我有所有屏幕尺寸的背景图像,加起来最多 20 mb。就是这样!我将这些图像存储在 xcassets 中,因为这是我猜的首选方式。

我认为该应用程序不应超过 25 mbs。

我发现我的项目中有一些参考资料翻了一番。我删除了这些,但我的 .app 文件仍然是 89 mbs!

我究竟做错了什么?我阅读了几个关于此的主题,但没有任何帮助!

到目前为止我所做的:

- reduce the size of all pngs
- disable the compress PNG option, as it seems to make the PNGs bigger (lol)
- configured the build settings to run the fastest and smallest build
- Strip Debug Symbols During Copy build setting to Yes (COPY_PHASE_STRIP = YES)

编辑1:显然Xcode对我的png做了一些奇怪的事情。其中一些最初为 2 mb 的图片在 .app 文件中超过了 10 mb。xcode 在那里做什么?

4

1 回答 1

13

苹果重新压缩的文件更大实际上并不奇怪。它们针对快速加载而不是小尺寸进行了优化。如果您不关心大小而不是速度,请务必关闭压缩。即使您确实关心速度,您也可以比 Apple 做得更好。

https://imageoptim.com/xcode.html

所以是的,关闭PNG压缩。我要做的第一件事是构建 ipa。ipa 实际上是一个 zip 文件,因此构建 ipa,将其复制到 Mac 上的文件夹中,使用 .zip 扩展名重命名文件并双击它。这将扩大它。在 Payload 文件夹中找到该应用程序,然后右键单击它并选择显示包内容。您将看到所有资产。按大小排序。我猜你有过大的图像。在那个尺寸下,我的猜测是额外的尺寸可能几乎完全是由 PNG 文件引起的。

Consider using non retina images for some. Honestly most people wont notice. iOS will gracefully use the non retina on retina. This can save a ton of space,

Also consider using jpeg files instead of PNG for some of the files if you do not need transparency. Jpeg files are less efficient but can be much smaller. Compare both. Depends on the extent to which the images are continuous tone.

By default PNG file are 32 bit. 24 bit color and 8 buit alpha/transparency. You can save a bit of size by going to 24 bit. You can also save a lot of size going to 16 bit color or below. At 8 bit PNG files use a color lookup table. Play with Photoshop and the save for we options at PNG with bit depth 8 and below.

I have all sorts of expensive compressing software but often use the $8

https://itunes.apple.com/us/app/lossless-photo-squeezer/id704083918?mt=12

Try the 8 bit PNG option and the JPEG options.

EDIT I did some research. I had always know Fireworks did better PNG compression. I did not realize that there was an 8bit PNG with an 8 Bit alpha channel. Photoshop supports 8 bit with a 1 bit Alpha Channel. I have always told people to use 32 bit PNG if their transparency needed more than 1 bit. In the future I will let them know the 8 bit with 8 bit alpha may be the better route, They just can use Photoshop for the final save of the file. They just need to save a 32 bit and compress elsewhere.

http://calendar.perfplanet.com/2010/png-that-works/

David

于 2014-12-07T01:56:21.847 回答