The easiest and cleanest way to solve this problem is to partially mock the NSBundle class in your unit tests to return [NSBundle bundleForClass:[self class]]when you call [NSBundle mainBundle].
-setup, :
static id _mockNSBundle;
@implementation MyTests
- (void)setUp
{
[super setUp];
_mockNSBundle = [OCMockObject niceMockForClass:[NSBundle class]];
NSBundle *correctMainBundle = [NSBundle bundleForClass:self.class];
[[[[_mockNSBundle stub] classMethod] andReturn:correctMainBundle] mainBundle];
}
@end
.
[]