Xcode5 pngcrush caught libpng error
Asked Answered
M

6

27

I am looking to complete an app I have created within xcode5. When I run it with the simulator everything goes smoothly with no errors, but when I try to archive the app I get countless amounts of errors in regards to the images in the project. Many of the are flagged with the text "pngcrush caught lilpng error.

All my images are png files and when I finish the project being archived even with the errors some images come thru while others are left blank. Any suggestions or pointers?

Mears answered 12/7, 2014 at 16:9 Comment(1)
This duplicates some other questions with the "pngcrush" tag, for example #20655651 .. Your images have been run through Apple's modified "pngcrush" which makes them invalid PNG files.Beverly
S
39

You can stop XCode shrinking images with pngcrush by going into Your App -> Build Settings and setting "Compress PNG Files" to No.

This stops pngcrush running at all, but will also likely result in bigger images. Ensure there isn't a genuine problem with your PNGs before doing this.

Backstory: I've had similar issues with pngcrush /libpng crashing with PNGs (checksum errors / freeing object that have been freed etc). These could be reproduced on the command line so I recreated the PNGs, even converted them to other formats then back but the errors persisted. In my case Xcode then rejected the resulting archive for not having iPhone 5 support (as pngcrush killed the [email protected] image). The above fix resolved this.

Spite answered 22/1, 2015 at 10:2 Comment(0)
Y
20

In my case I had 2 image files in the project with the same name and the error actually was telling me which files were problematic (without saying there were 2 files with the same name) but I arrogantly thought it was something else! After growing tired of the error, I did more investigation into those particular files and it was obvious which ones were from a previous build and were now not intended (hence could be deleted). Once I deleted the "older" images this error went away.

Yazzie answered 6/10, 2015 at 23:29 Comment(2)
I was able to solve this by filtering the file name in the "project navigator". It is ok to have multiple files with the same name, as long as they are included into different targets of the project (notice the check marks in the right pane). Never allow two files with same name into the same target. And a question to Apple: do you EXPECT us to find the solution in stackoverflow? because the error you emit for duplicate images is totally misleading!Coactive
I've had this before and opening the offending image in Pixelmator and re-exporting it fixed it for me.Dolli
D
15

If you have images in your images.xcassets AND the raw images linked, it runs into this issue. Delete the references to the images (keep the images.xcassets). Will fix the problem

Divvy answered 19/12, 2014 at 9:1 Comment(1)
This was my scenario. Images were fine but project.pbxproj had multiple references. Closing Xcode, deleting them all using a text editor, then restarting Xcode and "add files" cleaned it up (after a couple of tries...)Clawson
R
4

I resolved it by opening that image in Preview and exporting it to png and replacing the image in Xcode with the new one.

Retardant answered 6/12, 2016 at 11:39 Comment(0)
D
1

I am also facing the same problem in Xcode5 pngcrush caught libpng error,

just quick fix: i checked the png files which i was adding(reading) using xcode. Actually png file is having content error(png was corrupted file), so i changed the png files, and upload, now it is working.

Dylandylana answered 31/7, 2015 at 5:55 Comment(0)
A
0

I resolved it by opening that image in Preview and exporting it to png without alpha and replacing the image in Xcode with the new one.

Archipelago answered 11/8, 2018 at 11:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.