OCUnit & NSBundle

Found only one solution for this problem.

When I build my unit-tests, the main bundle’s path is not equal to my project’s bundle (created .app file). Moreover, it’s not equal to LogicTests bundle (created LogicTests.octest file).

Main bundle for unit-tests is something like /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk/Developer/usr/bin. And that’s why program can’t find necessary resources.

And the final solution is to get direct bundles:

NSString *path = [[NSBundle bundleForClass:[myClass class]] pathForResource:name ofType:@"png"];

instead of

NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"png"];

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)