跳过 Xcode iPhone 应用程序的“CompressResources”构建步骤

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/177160/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:24:37  来源:igfitidea点击:

Skipping the 'CompressResources' build step for Xcode iPhone apps

iphonexcodeimageresources

提问by James

Is it possible to set an iPhone Xcode project to skip the 'CompressResources' build step?

是否可以将 iPhone Xcode 项目设置为跳过“压缩资源”构建步骤?

Specifically, I want to skip the stage where it runs pngcrush on all of my .png files, many of which don't survive the experience in a form which my app can read.

具体来说,我想跳过它在我的所有 .png 文件上运行 pngcrush 的阶段,其中许多文件无法以我的应用程序可以读取的形式存在。

Edit:the version of pngcrush used creates png files which contain a non-standard 'mandatory, private' chunk which explicitly prevents decoding. I've modified my png reader to handle these files, but I'd still like a per-project method of skipping this step. One of the other side effects of pngcrush is that it doesn't save the colour value of transparent pixels, so alpha-ed textures show fringing at smaller mip levels.

编辑:使用的 pngcrush 版本创建了 png 文件,其中包含一个非标准的“强制性的、私有的”块,它明确地阻止了解码。我已经修改了我的 png 阅读器来处理这些文件,但我仍然希望跳过这一步的每个项目的方法。pngcrush 的另一个副作用是它不保存透明像素的颜色值,因此 alpha 纹理在较小的 mip 级别显示边缘。

The iphone png format is described here: https://web.archive.org/web/20110519164905/http://modmyi.com/wiki/index.php/Iphone_PNG_images. In short,

iphone png 格式在这里描述:https://web.archive.org/web/20110519164905/http://modmyi.com/wiki/index.php/Iphone_PNG_images。简而言之,

  • Skip the CgBI chunk
  • Skip the zlib headers
  • Swap BGR to RGB channel order
  • 跳过 CgBI 块
  • 跳过 zlib 头文件
  • 将 BGR 交换为 RGB 通道顺序

Edit:It appears it also premultiplies the alpha, so:

编辑:它似乎也预乘了 alpha,所以:

  • Divide by alpha
  • 除以阿尔法

采纳答案by scoopr

You can add "IPHONE_OPTIMIZE_OPTIONS=-skip-PNGs" to your project settings to prevent the png mangling, but be careful with it, you might need to optimize the icon and Default.png separately then.

您可以将“IPHONE_OPTIMIZE_OPTIONS=-skip-PNGs”添加到您的项目设置中以防止 png 修改,但要小心,您可能需要单独优化图标和 Default.png。

回答by benzado

The iphoneos-optimize script converts PNG files into a nonstandard format that is optimized for display on the iPhone. The script will convert any files with the png extension that it finds inside your app bundle.

iphoneos-optimize 脚本将 PNG 文件转换为非标准格式,该格式针对在 iPhone 上的显示进行了优化。该脚本将转换在您的应用程序包中找到的带有 png 扩展名的任何文件。

I had a similar problem, and solved it by giving my file the extension _png (i.e., prefixed an underscore). iphoneos-optimize ignored it and left it a regular PNG file. If you can deal with it that way, it's probably a lot safer than mucking about with the build scripts.

我有一个类似的问题,并通过给我的文件扩展名 _png (即,前缀一个下划线)来解决它。iphoneos-optimize 忽略它并将其保留为常规 PNG 文件。如果你可以这样处理它,它可能比处理构建脚本安全得多。

回答by sashmackinnon

  • Open build settings
  • Under "packaging" choose Compress PNG files
  • Choose "NO"
  • 打开构建设置
  • 在“打包”下选择压缩 PNG 文件
  • 选择“否”

回答by jblocksom

If you look at the build output you'll see that the CompressResources step runs the script /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/iphoneos-optimize. This appears to be just a shell script that runs pngcrush and compiles plists into binary format. You could probably modify this script to not run pngcrush.

如果您查看构建输出,您将看到 CompressResources 步骤运行脚本/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/iphoneos-optimize。这似乎只是一个运行 pngcrush 并将 plist 编译为二进制格式的 shell 脚本。您可能会修改此脚本以不运行 pngcrush。

Note that someone in this threadnoticed that if they did not run their icon file through pngcrush it wasn't showing up on the phone.

请注意,此线程中的某个人注意到,如果他们没有通过 pngcrush 运行他们的图标文件,它就不会显示在手机上。

Interestingly, the version of pngcrush in the directory of the script has a -iphone argument. Anybody know if this is standard or something Apple just ships with their build of it?

有趣的是,脚本目录中的 pngcrush 版本有一个 -iphone 参数。有谁知道这是标准的还是苹果只是随其构建的东西?

回答by Shai Wininger

That might be another issue all together. In many cases the problem has to do with naming and can be solved very easily.

这可能是另一个问题。在许多情况下,问题与命名有关,很容易解决。

read this: http://cocoapi.wordpress.com/2009/03/22/iphone-images-not-appearing-in-real-iphone-this-is-why/

读这个:http: //cocoapi.wordpress.com/2009/03/22/iphone-images-not-appearing-in-real-iphone-this-is-why/