Not a PNG filCommand copypng emitted errors but did not return a nonzero exit code to indicate failure

23,759

Solution 1

Case 1: Format difference

It worked when i changed the images from jpg to png, using Preview. Previously It might not be working due to .png as name only not as format. This link helped.

Also to convert the multiple images to png in a folder in single step use terminal. Using cd goto the folder containing the images (JPGs or any type). run Code:

mkdir pngs; sips -s format png *.* --out pngs

It will convert your images to .png and will create a pngs folder contain the converted images.

Case 2: Two images with same name or one image added twice:

As Rajneesh071 & Himanshu suggested: There can be two or more images with same name or two targets were added for same image. Goto project target ->Build Phases -> Copy Bundle Resources and search for your image file name. and remove the repeated file.

Solution 2

MY ANSWER:

I had this problem. Two targets were added for same image. Goto project target ->Build Phases -> Copy Bundle Resources and search for your image file name.

Most likely there are two entries. Remove one.

By doing so I got resolved my problem.This works for me :) :)

HAPPY TO HELP :) :)

Solution 3

I'm hoping to give more visibility to @Rajneesh071's comment. In my case, there was more than one Default.png file in my project. When I first created my project, Xcode put Default.png (and other splash screen png files) in my project. After creating my own splash screen, and adding them to the project through Xcode, I started getting the weird png crush errors. After trying many different answers, I came across Rajneesh071's comment that more than one Default.png existed. Did a quick filter on Default and sure enough, the Xcode provided Default files where listed along with my own. Deleted the Xcode provided Default*.png files and no more pngcrush errors.

If you find this useful, please give an uptick to Rajeneesh071's comment on the original question.

Share:
23,759

Related videos on Youtube

HDdeveloper
Author by

HDdeveloper

Updated on February 12, 2020

Comments

  • HDdeveloper
    HDdeveloper over 4 years

    I am getting following error while adding images the running the project on iPad. It worked fine on simulator with all images but on iPad its running but showing no images.

    CopyPNGFile /Users/user/Library/Developer/Xcode/DerivedData/RImageGallery-cmwaittvclhwgxfpcoarddipyliv/Build/Products/Debug-iphoneos/RImageGallery.app/Default.png PhotoBrowserDemo/Default.png
        cd /Users/user/Desktop/Demo
        setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng -compress "" /Users/user/Desktop/Demo/PhotoBrowserDemo/Default.png /Users/user/Library/Developer/Xcode/DerivedData/RImageGallery-cmwaittvclhwgxfpcoarddipyliv/Build/Products/Debug-iphoneos/RImageGallery.app/Default.png
    
       Not a PNG filCommand /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng emitted errors but did not return a nonzero exit code to indicate failure
    
    
    
    
    (null): While reading /Users/user/Desktop/Demo/PhotoBrowserDemo/Default.png pngcrush caught libpng error:
    
    
    
    
    (null): Could not find file: /Users/user/Library/Developer/Xcode/DerivedData/RImageGallery-cmwaittvclhwgxfpcoarddipyliv/Build/Products/Debug-iphoneos/RImageGallery.app/Default.png
    
    
    
    
    Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng emitted errors but did not return a nonzero exit code to indicate failure
    
    • Damien
      Damien over 11 years
      The simulator's file system (HFS on OSX) is case insensitive, where as HFS on iOS is case sensitive. Check that your case of your path is correct.
    • Rajneesh071
      Rajneesh071 over 11 years
      You have more then one image with this name Default.png
    • HDdeveloper
      HDdeveloper over 11 years
      @Damien thanks for help it worked, when I saved it again by changing the format to .png. Thanks :)
    • HDdeveloper
      HDdeveloper over 11 years
      @Rajneesh071, it was not that issue, Thanks for help. :)
  • sachadso
    sachadso over 11 years
    You just made my day sir! :)
  • mblackwell8
    mblackwell8 almost 11 years
    Worth adding that you may think that you have put two images with the same name in different directories, but the folders in Xcode aren't really directories, from the point of view of the final bundle
  • nickthedude
    nickthedude over 10 years
    Sweet! Worked like a champ.
  • Moshe Gottlieb
    Moshe Gottlieb over 10 years
    Xcode somehow decided to add to the copy bundle resources the same file (with the exact same location) more than once in my case.
  • fpauer
    fpauer over 8 years
    In my case, it was png files with the same name in Copy Bundle Resources.
  • Pratik Somaiya
    Pratik Somaiya almost 8 years
    I have used "sips -s format png *.png" as it was related to png files only. I have other jpeg files which were getting converted to png format with previous command. This shows that we should customize commands as per our needs. Still its a life saver.
  • Asad Amodi
    Asad Amodi over 7 years
    whooa you beauty save my life amazing... :)
  • Alex Zavatone
    Alex Zavatone about 7 years
    This is it. Two entries for the same graphic. It's infuriating that this error keeps appearing even in Xcode 7 and 8 in 2017.