Xcode 6 (beta 3): Unsupported pixel format in CSI

2019-02-11 12:45发布

问题:

When loading UIImages with png images in Xcode 6 beta 3 in Swift as follows:

    PipsImg = (UIImage(named: "Die-1"))

or

    PipsImg = [(UIImage(named: "Die-1")),(UIImage(named: "Die-2"))]

from associated images stored in the Images.xcassets folder, I receive the following fatal runtime errors:

 SimpleAnimation[680:60b] Unsupported pixel format in CSI
 SimpleAnimation[680:60b] Unable to create unsliced image from csi bitmap data.

this appears to be resolved in beta 4, however will leave in place for a bit as sometimes these regress

回答1:

This is caused by a bug in Xcode 6 (beta 3 at this time). It appears to occur only if your build target is iOS 7.x

To work around this issue:

1) delete the files from the Images.xcassets container.

2) place the images directly into the "Supporting Files" folder.

Note: It is not required to add the ".png" extension within your code, making this a clean workaround.

Please create a RADAR (bug report) to Apple.



回答2:

XCode 6.0.1 still have this problem. If you add .jpg to Images.xcassets and try to install app to the iOS 7 device.

To fix it just convert .jpg to .png



回答3:

Apple engineer's response:

The issue is that iOS 7 apps cannot have JPEG images in the CAR file. actool should have copied the JPEG as a loose image into your app's folder. To work around this issue, you should either convert the image to a PNG or include the JPEG as a resource outside of the asset catalog.



回答4:

I solved this problem via:

  1. Run iOS Simulator
  2. Reset content and settings via "iOS Simulator > Reset Content and Settings" menu.
  3. It works.


回答5:

In Xcode we now have a possibility to do a slicing for the image resources. If slicing is added the corresponding json for an image in asset catalog gets resizing info. This may look for example like this

"resizing" : {
    "mode" : "3-part-vertical",
    "center" : {
      "mode" : "fill",
      "height" : 6
    },
    "capInsets" : {
      "top" : 16,
      "bottom" : 6
    }
  }

iOS 7.0 doesn't handle slicing properly. So removing the slicing info from json may help to fix the problem (in my case that was a solution).