所以,我已经开始使用FBSnapshotTestCase了,除了那些不能从包中正确加载的图像之外,一切都按预期的方式工作。我已经测试过了,它们装在另一个包里。
请参见下面的调试详细信息:
(lldb) po [NSBundle allBundles]
<__NSArrayI>(
NSBundle </Applications/Xcode.app/Contents/.../Xcode/Agents> (loaded),
NSBundle </.../DerivedData/.../ProjectTests.xctest/Frameworks> (not yet loaded),
NSBundle </.../DerivedData/.../ProjectTests.xctest> (loaded)
)
(lldb) po [NSBundle mainBundle]
NSBundle </Applications/Xcode.app/Contents/.../Xcode/Agents> (loaded)
(lldb) po [NSBundle bundleForClass:[self class]]
NSBundle </.../DerivedData/.../ProjectTests.xctest> (loaded)因此,当我运行[UIImage imageNamed:@"image"]时,它返回nil,但当我运行时:
[UIImage imageNamed:@"image" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil]装得很好。但是我不能改变应用程序中的所有图像负载,我也不知道如何在故事板中改变它。我已经尝试过研究,手动设置mainBundle是不可能的。
底线:是否有特定于目标的配置来为目标设置包,或者创建脚本以将资产移动到正确的包?
编辑:
我已经验证了所有资产都被检查过测试目标,并且它们都在测试目标的Copy Bundle Resources构建阶段。事实上,它们是装载的,但是不知怎么的,主包不是我所期望的那样。
发布于 2017-05-19 12:30:05
遵循本指南中的步骤之后,它就可以正常工作了,但是我不得不重新配置一些依赖项。我错过的是:
4)单击选项卡,将捆绑加载程序设置设置为$(BUILT_PRODUCTS_DIR)/MyExistingApp.app/MyExistingApp 5)将测试主机构建设置设置为$(BUNDLE_LOADER)
https://stackoverflow.com/questions/44067931
复制相似问题