Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS App Crashes while loading image from Assets.xcassets

There is an image file named "5.jpg", in the Assets.xcassets named "5".

I wrote code UIImage *image = [UIImage imageNamed:@"5"]; to create the image but app crashes and outputs *** Assertion failure in -[_CUIThemePixelRendition _initWithCSIHeader:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/CoreUI/CoreUI-432.4/CoreTheme/ThemeStorage/CUIThemeRendition.m:3797 in the console.

like image 728
Mokyz Avatar asked Dec 10 '25 12:12

Mokyz


2 Answers

I had this problem in the XCode 9 beta, running iOS 10 or below. It seems that Apple has dropped support for JPEG files in XCAssets. You can either use do as @Esha suggested and switch to PNG's or you can not use an XCAsset, put the image in your local directory, and refer to it by its URL.

It's possible that Apple did this intentionally (though if they did, I couldn't find any documentation for it) or that this is an XCode 9 bug. I have reported to apple and you can track the progress of the bug here.

like image 160
doctorBroctor Avatar answered Dec 12 '25 00:12

doctorBroctor


Try puting .png images in the asset folder. jpg images will make this issue.

like image 35
Esha Avatar answered Dec 12 '25 00:12

Esha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!