Technical Q&A QA1681

Viewing iOS-Optimized PNGs

Q:  When I build my iOS application, Xcode optimizes the PNG files within my application's bundle, meaning that Preview can't display them. How can I view these optimized files?

A: This optimization is done by the pngcrush tool, which you can find inside Xcode. The pngcrush tool supports a command line option, -revert-iphone-optimizations, that undoes the optimizations done during the Xcode build process. So, to view an optimized PNG file, you should first undo the optimization and then open it with Preview.

Listing 1 shows how you can use the pngcrush tool to convert an iOS-optimized PNG file (Local.png) to a standard PNG file (Local-standard.png). It uses xcrun to run the tool from within your currently selected Xcode (as determined by xcode-select).

Listing 1  Undoing iOS PNG optimization

$ xcrun -sdk iphoneos pngcrush \
-revert-iphone-optimizations -q Local.png Local-standard.png

Document Revision History


Updated to use xcrun (r. 13698179).


Updated to account for Xcode being packaged as an application (r. 11396673).


New document that explains how you can view a PNG file that's been optimized for iOS by the pngcrush tool.