88

When I build my app with Xcode 4 it always show this error message:

CopyPNGFile /Users/michaelchen/Library/Developer/Xcode/DerivedData/iMusicBox-boeawugacmhacbdtyymnprzfobyq/ArchiveIntermediates/iMusicBox/InstallationBuildProductsLocation/Applications/iMusicBox.app/list_cell.png Images/list_cell.png
    cd /Volumes/WORK/Works/iMusicBox
    setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    "/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneOS Build System Support.xcplugin/Contents/Resources/copypng" -compress "" /Volumes/WORK/Works/iMusicBox/Images/list_cell.png /Users/michaelchen/Library/Developer/Xcode/DerivedData/iMusicBox-boeawugacmhacbdtyymnprzfobyq/ArchiveIntermediates/iMusicBox/InstallationBuildProductsLocation/Applications/iMusicBox.app/list_cell.png

While checking alphas in /Volumes/WORK/Works/iMusicBox/Images/list_cell.png pngcrush caught libpng error: Not enough image data

but It's OK with Xcode 3.2 - why?

Paul R
  • 208,748
  • 37
  • 389
  • 560
Michael Chen
  • 883
  • 1
  • 7
  • 5

22 Answers22

191

You have to save your PNG files as NOT INTERLACED. Try to open the file in photoshop (or similar), save as, and select "Not interlaced".

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Eva Madrazo
  • 4,731
  • 2
  • 23
  • 33
  • Eva, you're right, thanks! I export from web in pixelmator and it's OK. – Michael Chen Mar 15 '11 at 16:06
  • 6
    man! thank God! and you! I was about to go to the rooftop to throw my stupid laptop from there when I saw this answer and it worked. Thanks a lot. I guess its time to sleep now. – Sahil Chaudhary Jul 20 '12 at 20:18
  • 7
    In my case it turned out that I had several references to the same file in Xcode (this probably meant it tried to process the file more than once?) Removing the duplicate reference removed the problem. – Peter Johnson Nov 16 '12 at 14:24
  • I saved my png as NOT INTERLACED, still got this error when building first time, but the second time I build, this error gone... – Jing Dec 01 '12 at 05:13
23

That happens when you have multiple entries for the image file in your project file. I have no idea why but I just removed all entries, reloaded the project and added the file again.

banane
  • 251
  • 2
  • 2
  • Hmm, are you sure you had the same compiler message from having doublettes? – brainray Oct 05 '12 at 15:07
  • 8
    This was my problem too. My Launch Images where causing issues. By default, XCode had added black images in my Supporting Files folder, then I added more, but the black ones didn't go away. If the Launch image holder is black, that means there's an image in your project for it. Remove the black images and bring in your correct ones. Did that and now all is well again! – dbDev Nov 05 '12 at 01:57
15

Check that you don't have duplicate entries in the Target's "Build Phase"-> "Copy Bundle Resources"

Yohann T.
  • 1,915
  • 2
  • 23
  • 28
  • for anyone else who doesn't even have images in their project...this solution was the only one of all the answers that worked. I don't have images, but I am using the Facebook SDK and I had to delete anything that was red in Build Phases->Copy Bundle Resources. – Jeff Grimes Jun 01 '14 at 05:30
9

It may be the "Compress PNG Files" setting (from the Packaging section of Build Settings).

I solved this error by switching it to "No".

siburb
  • 4,880
  • 1
  • 25
  • 34
sunset
  • 91
  • 1
  • 2
6

In my case I discovered my corrupted png wouldn't open in photoshop. I opened in preview, saved as psd, and then saved again from photoshop (save-as -> png -> not-interlaced). Compiles fine now in xcode 4.

jaime
  • 927
  • 8
  • 13
5

Try to find and resave this *.PNG files using "Preview", to be exact: File - Export... - "save as PNG". It seems to me, that it happens when you saving image in Photoshop with mode "Save for Web" and after this image will be saved with special compressing (LZW). That's all, good luck!

Resty
  • 111
  • 3
  • 10
3

In my case I solved the problem by removing the blank "space-key" in folder/filename.

Hope this works for somebody too.

gnat
  • 6,213
  • 108
  • 53
  • 73
inox
  • 31
  • 1
3

It looks like your PNG file list_cell.png is corrupt. Xcode 4 makes more checks than Xcode 3 in many areas and reveals problems that have been lurking in your project all the time.

Have you tried to open your PNG file in an image editor and save it again?

Codo
  • 75,595
  • 17
  • 168
  • 206
  • 1
    Yes, I already open it in Preview, it's OK. and I try to save it again but the error still show. – Michael Chen Mar 13 '11 at 14:30
  • Don't just open it in Preview. It might also try to work around the errors in the image. Open it with an application that can edit images and store a new version of the image. – Codo Mar 13 '11 at 14:36
2

Mine weren't interlaced but I kept getting odd errors from pngcrush. Eventually I deleted the files not just disk but through XCode. I added them back in one by one by drang-and-drop into XCode, building after each, expecting to hit one that had an issue. I never did. My conclusion is that you really need to manipulate the files from XCode and not the filesystem at all.

hofo
  • 522
  • 1
  • 4
  • 16
2

in my case with xcode 4.5 the problem is solved by permission giving with terminal

chmod -R +rw /yourprojectpath/yourprojectfolder

this is maybe not the best solution because of locking files with file sharing. But will do if you are in hurry.

2

I had to remove the references to PNGs and add them to the project again. Anyone has a better solution?

Alex L
  • 8,419
  • 6
  • 43
  • 51
1

Follow the steps:

 1. Take an image. 

 2. Rename it to the showing error png's name. 

 3. Drag it back to the Xcode.
NeverHopeless
  • 11,077
  • 4
  • 35
  • 56
1

I had to remove png files and then go to Targets -> AppName -> Build Phases -> Bundle Resources and remove the files from there too.

zirinisp
  • 9,971
  • 5
  • 32
  • 38
1

I got the same error. Turned out my pngs where actually jpeg. XCode showed them properly but an iOS device didn't. Solved it by saving the jpg as png.

1

This error happens because you have an image in resources that's smaller than 5 pixels in width or height and you are trying to resize that image. Set all images to minimum of 5 pixels and error disappears.

AndroC
  • 4,758
  • 2
  • 46
  • 69
0

In my case, I had to remove all PNG files from the folder and then re-adding the files again without drag-and-dropping the images into the Xcode UI (under Launch Images). The latter was key in my case, first adding the files to the folder and then dragging them into the UI somehow cause a duplicate which screwed it all up. Try that out if nothing else's working for you.

Jonathan
  • 2,953
  • 3
  • 26
  • 37
0

I had the same problem. I resolved it removing the duplicate pictures. Check out in different folders. That was my problem.

Javier Roberto
  • 1,293
  • 11
  • 17
0

I solved this error, it's appear when you rename the images after put into the project, so for solve this problema first should delete the current images, rename files from finder and later copy this images into the project.

kakashy
  • 714
  • 9
  • 24
0

May be help you. Check Alpha Channel property as shown in attached screenshot. It should be YES if its NO.

enter image description here

Ashvin
  • 8,227
  • 3
  • 36
  • 53
0

May be help you. Check Alpha Channel property as shown in attached screenshot. It should be YES if its NO.

enter image description here

Ashvin
  • 8,227
  • 3
  • 36
  • 53
0

Eva Madrazo posted the right answer (at least for problems with interlaced PNGs), but for those having this problem with a bunch of images as I did, you can use mogrify recursively to de-Interlace every file at once.

find ./ -name "*.png" -exec mogrify -interlace none {} \;

Changing the interlace method doesn't appear to affect the image quality, but affects the image size, none will give you a smaller image.

Mogrify comes with ImageMagick and you can install it with homebrew.

Douglas Schmidt
  • 368
  • 1
  • 2
  • 12
0

Error:

While reading /Volumes/Mac OS/RDC/Workpot/RestApp/RestApp/default1024_768.png pngcrush caught libpng error: Not a PNG file..

Solution:

  1. I have opened "default1024_768" file in PaintBrush tool and saveAs PNG file with same name.
  2. Replaced the Icon file in Xcode project.
  3. Clean --> Build
Nimantha
  • 6,405
  • 6
  • 28
  • 69
swiftBoy
  • 35,607
  • 26
  • 136
  • 135