Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skipping the 'CompressResources' build step for Xcode iPhone apps

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

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.

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.

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

  • Skip the CgBI chunk
  • Skip the zlib headers
  • Swap BGR to RGB channel order

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

  • Divide by alpha
like image 226
James Avatar asked Oct 07 '08 03:10

James


3 Answers

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.

like image 122
scoopr Avatar answered Nov 05 '22 13:11

scoopr


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.

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.

like image 28
benzado Avatar answered Nov 05 '22 15:11

benzado


  • Open build settings
  • Under "packaging" choose Compress PNG files
  • Choose "NO"
like image 5
sashmackinnon Avatar answered Nov 05 '22 15:11

sashmackinnon