Search code examples
watchkitapple-watch

"Unable to find image named XXX on watch" when I use image cache


I use - (BOOL)addCachedImage:(UIImage *)image name:(NSString *)name API of WKInterfaceDevice to store images.

The issue is that most of the time, when I try to use those cached image by using setImageNamed: on WKInterfaceImage, I get this Unable to find image named XXX on watch error that results in an empty image on screen. I insist on the fact that this does NOT happen all the time.

This occurs both on simulator and on device.


Solution

  • I figured out that image names that are too long (character count > 255) lead to the bug. As soon as the image name used to cache the image is shorter, I don't get the error anymore.