Search code examples
iosios9xcasset

Impossible to load an image from xcassets on iOS 9


I got several images stored in my Images.xcassets that I load both through code and Interface Buider. However the iOS 9 update broke everything : the images are not showing neither when loaded from code or IB.

Everything was working fine except that images dont load up anymore.

Say I have an image named Image in my .xcassets. On iOS 8,

 [UIImage imageNamed:@"Image"]

returned a valid pointer, but it returns nil on iOS 9. The same thing goes on in Interface Builder : all UIImageView that are set from IB are empty.

There are two exceptions though : two small (48x48) images do indeed load correctly. I noticed they both are compiled into Assets.car, all the others are sitting as pngs and jpegs in the main directory ... But the configuration is the same far all the images.

This problem didn't exist on iOS 8.

Any ideas ?


Solution

  • The answer is that I was using JPEGs. It looks like Xcode 7 now requires the Render As options set to Original Image though Xcode 6.1 was supposed to also require this option (from this SO thread). However it worked before without it ... (I started the project on Xcode 6.1).

    The solution was to change the Render As option from Default to Original :