4

i know that Pngcrush is an image optimisation technique in iOS , but my doubt is does X-code will perform this internally during each build or before deploying our app to iTunes store we need to do this image optimization?

Graham Bell
  • 1,139
  • 1
  • 14
  • 30

3 Answers3

4

Xcode does the conversion during build. The final app will have modified pngs, you don't have to do anything manually.

wrock
  • 1,349
  • 9
  • 9
  • Are there any performance benefits by crushing images downloaded for in app use(such in uitableview)? – Mateus Feb 11 '13 at 04:14
  • I suppose that's the reason they're doing it in the first place. They premultiply the alpha, so they don't have to do it at load time or at draw time; they swap the channels so the channel order is what I guess is the HW channel order, so they don't have to do that at load time either. – wrock May 24 '13 at 11:32
4

The PNG crushing is done using the pngcrush tool which you can access manually with this command:

xcrun -sdk iphoneos pngcrush -iphone ...

Xcode will do this automatically for any files added to your target with the "PNG" file type:

enter image description here

If you include resources using a directory reference, the PNG crushing will not be performed by Xcode and you will have to do this manually.

You can crush all the PNGs in a directory manually using this little bash snippet:

find /path/to/directory -name "*.png" | while read filename; do
    xcrun -sdk iphoneos pngcrush -iphone "$filename" "${filename}_crushed"
    mv "${filename}_crushed" "${filename}"
done
Mike Weller
  • 45,401
  • 15
  • 131
  • 151
2

By default, XCode performs automatically the crunching.

You can control this behavior from your project's build settings:

Search for the setting "Compress PNG Files" and set the value you want.

rockeye
  • 2,765
  • 2
  • 30
  • 44