Steffen L.
Steffen L.

Reputation: 149

Can't get path of image in NSBundle?

I am trying to get the path of an image while UITesting. I've tried multiple ways as shown under here, but none are working?

Name of image file is: TestImage.fff

NSBundle* testBundle = [NSBundle bundleForClass: [self class]];
NSString* testImage = [testBundle pathForResource:@"TestImage.fff" ofType:@"fff"];
NSString* testImage2 = [testBundle pathForImageResource:@"TestImage"];
NSURL* testImage3 = [testBundle URLForResource:@"TestImage" withExtension:@"fff"];

Can someone tell me where I am going wrong?

Upvotes: 0

Views: 76

Answers (1)

yageek
yageek

Reputation: 4455

Inside XCode, select your test target inside the target list. Then select the Build Phases tab and inside the Copy Bundle Resources phase, add the required resources.

Example of project

Upvotes: 1

Related Questions