我试图在没有模拟器的情况下使用xctool运行单元测试。我按照this comment的指示,在测试目标的General选项卡中将'Host‘设置为None。
当我运行xctool -project MyProject.xcodeproj/ -scheme MyProject test时,我会得到这个错误。
<unknown>:0: failed: caught "NSInvalidArgumentException",
"Could not find a storyboard named 'Main' in bundle NSBundle
</Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/
Developer/SDKs/iPhoneSimulator9.2.sdk/Developer/usr/bin> (loaded)"我确保Main.storyboard是测试目标的成员。为什么会发生这种事,我该怎么解决呢?
发布于 2016-07-06 14:57:31
明白了这一点,this post帮忙了。
我的测试用例设置方法像下面这样初始化了故事板
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:DEVMainStoryboardName
bundle:nil];问题是将nil传递给bundle参数,它使用的主要包不是测试目标中使用的包所以您必须通过编写指定要使用测试包。
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:DEVMainStoryboardName
bundle:[NSBundle bundleForClass:[self class]]];然后,不要忘记将故事板作为目标的成员。
https://stackoverflow.com/questions/38221608
复制相似问题