简体   繁体   中英

Splash Image naming clash and PNG crush error

I am adding splash images in one of my Universal projects using xCode5.

When I add splash image for iPhone Non-Retina (iOS 6.1 or prior) , xCode asks me to rename the image to Default.png (Good enough)

I add all other images for iPhone.

When I add splash image for iPad Portrait Non-Retina (iOS 6.1 or prior) , xCode again asks me to rename the file to Default.png and places it in a sub-directory.

Now when I try to build the project, it gives the PNG Crush error due to same file names.

Here is the exact error: While reading /Volumes/iosWorkspace/projectName/projectName/Default@2x.png pngcrush caught libpng error: 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

The images should be called:

iPhone:

  • Default.png
  • Default@2x.png
  • Default-568h@2x.png

iPad:

  • Default-Portrait.png
  • Default-Portrait@2x.png
  • Default-Landscape.png
  • Default-Landscape@2x.png

--- or you can use "LandscapeLeft" and "LandscapeRight" & "PortraitUpsideDown"

There's usually no need to add a "~ipad" at the end because you can only choose landscape or portrait loading images for the iPad. If you do really need to specify device specific loading images then you can do it, but use a tilde (~) instead of a hyphen (-).

Apple's documentation on it is here: https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/App-RelatedResources/App-RelatedResources.html

And make sure you get the "D" in uppercase otherwise it will work on the simulator but not the device.

It seems that in xCode5 order of adding splash images matters. If no splash image is added and I directly add an image for iPad non-Retina, xCode forces me to renames it to Default.png which is meant to be for iPhone Splash Image.

I took backup of all the splash images, deleted them from my project and added them again in the order as shown bellow:

在此输入图像描述

Then the xCode didn't force me to rename the iPad Splash Image to Default.png

Another problem (that was actually causing the pngcrush error) was that I had two images with the same name in my project. One on root directory and one in sub-directory. As I explained in the question, this was because xCode was forcefully renaming the two images to the same name.

There must be two possibilities,

Your image is corrupted. Resave it as .png from photoshop or take new one. Check whether you have added two/ multiple references in Xcode or not. If yes, then delete old references.

May be help you. Check Alpha Channel property as shown in attached screenshot. It should be YES if its NO . 在此输入图像描述

Apparently there were two identical files which caused this problem. Deleted the duplicate and the error went away. Tested this on iOS8.1 with Xcode 6.1

Credit goes to the answer from this thread iPad: PNG Crush error

It usually happens when you rename a file of different format say jpg to png.

Create a new .png and use it.

  • Open your new image in preview.
  • cmd+a and select a entire contents of the image.
  • Click on file >select new from clipboard.
  • Save the file specifying the format type png and use it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM