Copying PNG image files copied from NSBundle to Documents seems wrong

My task was to have some image resources in my iOS application bundle, and copy them into my Documents folder for use later, namely HTML5 code generation. I had a big problem, in that the image sizes were all wrong. When I’d download the package contents from Organizer, and look at then in Finder, the images looked simply transparent. They looked fine in the Xcode project, so what happened?

Normally, images, particularly PNG images, are used for GUI elements, not as assets for use later, like uploading to a server. Xcode build settings use a utility called pngcrush to squeeze a touch more file size out of them. This is the default. To fix this, you go into your Build Settings, the Packaging section and change Compress PNG Files to NO. Now the files do not get crushed, and they keep their original form.

XCode 4.2 screenshot

Category(s): iOS

Comments are closed.