OCUnit & NSBundle

隐身守侯 提交于 2019-11-30 01:18:09

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"];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!