我有一个混合的objective-c和Swift项目,我尝试为它编写单元测试。 我的项目名称是:Alphaproject 我的产品模块名称是:Alphaproject 我在主目标(Alphaproject)中设置为YES定义模块 并在同一个目标中设置为YES EnableTestability for Debug。
在我的Test类中,我尝试导入我的产品模块名称:
@testable import Alphaproject
附加说明:
还有其他想法吗?
答案 0 :(得分:3)
OK!问题来自于我在有效架构的调试配置中使用了arm64这一事实。 由于主要目标也不包含有效架构中的arm64,它显然无法找到模块...... 我认为苹果可以在这里更好地展示正确的错误。 (Apple,如果你读了我,请)
答案 1 :(得分:1)
In my case, the initial Xcode project was Objective-C, and I added testing targets that were Swift-based, and the import <Product Moodule Name>
failed. I ensured that Defines Module
was set to YES
in Build Settings, but still got the error as indicated. The fix for me was to add a Bridging Header into the Objective-C main project.