问题
When I archive the application I get CopyPNGerror for all images in my project.I tried all means deleting all the images,adding them again,check Build Phases(copy bundle resources).No duplicates are found.I couldnot understand what to do further and submit the app.When I archive another application with same images archive is successful
CopyPNGFile "/Users/admin/Library/Developer/Xcode/DerivedData/App1-auevnkwujohdqtflzyputmxbvrmt/Build/Intermediates/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/App1.app/about2 copy.png" "Classes/../about2 copy.png"
cd "/Users/admin/Documents/App/App (1)"
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/admin/Documents/App/App (1)/Classes/../about2 copy.png" "/Users/admin/Library/Developer/Xcode/DerivedData/App1-auevnkwujohdqtflzyputmxbvrmt/Build/Intermediates/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/App1.app/about2 copy.png"
Could not open output file /Users/admin/Library/Developer/Xcode/DerivedData/App1-auevnkwujohdqtflzyputmxbvrmt/Build/Intermediates/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/App1.app/about2 copy.pngCommand /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng failed with exit code 1
What shall I do to solve this error?
回答1:
Solved here -> https://stackoverflow.com/a/18297130/1451462
I removed the duplicate references in my png files!
Build Phases -> Copy Bundle Resources
and removed all the duplicated entries of lunch images DefaultXX.png
回答2:
I had the same problem, in my case the image causing the problem was a JPG renamed manually in PNG. I suggest you to open the image in a Image Editor (Gimp, Photoshop...) and save it as PNG.
回答3:
i face this problem an i solved as @Davide answer
you need to remove any reference for that image
after that clean and build and problem will be fixed
回答4:
To solve this issue open your image (about2 copy.png) in photoshop or gimp or any similar image editor. While saving(save as) your image check it as NOT INTERLACED.
Build your project again will remove the error.
回答5:
I have this happen periodically, my solution, copy the images away, delete them from xcode, then copy them back. Fixes it every time.
Delete the file reference from xcode -> click your project -> Build Phases -> Copy Bundle Resources. Then, add the file again to your project.\
or
Build Settings -> Search for Compress PNG Files and set to NO .
or
You have to save your PNG files as NOT INTERLACED. For example, by using Photoshop, go to menu File->Save For Web and Devices. Unchecked the box of 'Interlaced' and save the file. Usually interlaced box is unchecked already.
回答6:
In my case, I just removed the "$" character from the image name. My case was that, I have image called imagex.png, then I removed that image and added one called imagex$xxx.png, then I got that error, everything went well when I just removed the dollar sign from the name.
回答7:
Delete the file reference from xcode -> click your project -> Build Phases -> Copy Bundle Resources. Then, add the file again to your project.
回答8:
I had the same problem. I have fixed it. In my case. This error occurs because I have multiple files with the same name. To fix this. I delete remove the files from my project and the import again. Instead of create a group in project. I create a folder reference and everything works great as I expected!
回答9:
Just remove the image file from the Xcode project, rename it as you want on FINDER and then readd it to you project. I just had this problem a while ago.
回答10:
This is due to copy of image of same name in Project.
回答11:
if there are icons in the exact path. you should check that all the icons are really png . just open icons in some editors and save as the icon in png format
回答12:
Found those images are red in color in project.Simply deleting & readding them worked.
回答13:
Just try deleting the .png extension for the files which are causing you the trouble. Don't know how, but worked for me!
来源:https://stackoverflow.com/questions/17721177/copypngfile-error