【发布时间】:2016-07-20 09:05:39
【问题描述】:
在将 Host Application 设置为 none 之前,我的单元测试中有这行代码,这没有给我带来任何问题。
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
设置为 None 后,出现此错误。
<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)”
我找到了this post,它给了我解决方案。我刚刚指定了我正在加载视图控制器的类的捆绑包。
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main"
bundle:[NSBundle bundleForClass:[self class]];
我只是想知道为什么会这样。当我删除导致主包中的资源被排除的主机应用程序时会发生什么?
【问题讨论】:
标签: ios unit-testing storyboard xctest nsbundle