Facing PNGCrush issue on some of XCode / Mac OS (Not specific)

1.1k Views Asked by At

I have developed an application using Mac OS 10.7.5 and XCode 4.6.2. Application is working fine in my machine without any error/warnings.

But when I try to run in another machine Mac OS 10.8 and XCode 4.6.2, it shows pngcrush error for some of the images in that machine. Though there are few pngcrush errors, still application runs fine over simulator or device.

My question is: Why there is difference in debugging at both end and how to resolve it. (How to avoid such kind of errors)

Error Message

While reading ImagePath/ImageName.png pngcrush caught libpng error: Not a PNG file.
2

There are 2 best solutions below

0
On

Pngcrush is an optimizer for PNG (Portable Network Graphics) files used by Xcode to compress PNG images contained in an app, with the aim of reducing the final size of the packet built.

This will be under below path

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin

There must be two possibilities,

  1. Your image is corrupted. Resave it as .png from photoshop or take new one.
  2. Check whether you have added two/ multiple references in Xcode or not. If yes, then delete old references.
0
On

The images that are "not a PNG file" have probably been already run through Apple's private Xcode SDK version of pngcrush, which produces "optimized" files that are no longer valid PNG files.

Look at the beginning of a file that throws the error and see if the bytes beginning at byte 12 are "CgBI" instead of "IHDR". If so, you'll need to reverse the changes. Search SO for "pngcrush" and "CgBI" to find out how.