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 (
Listing 1: Undoing iOS PNG optimization
1 2 3
If you have Xcode installed in a non-standard place, you can locate the tool using xcode-select, as shown in Listing 2.
Listing 2: Using xcode-select to locate pngcrush
1 2 3