I can't get XCTestCase unit tests for a Cocoa Touch Static Library which rely on code that uses imageNamed
to work.
I added my image "plane.png" to the test target, but [UIImage imageNamed]
keeps returning nil.
When I explicitly specify the path of the image in the test and load the image from file it does work.
NSString* imagePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"plane.png"];
UIImage* imageWorks = [UIImage imageWithContentsOfFile:imagePath];
UIImage* imageStaysNil = [UIImage imageNamed:@"plane.png"];
How can I write unit tests for code that uses imageNamed
?