在XCode单元测试中没有这样的模块<product module =“”name =“”>

时间:2016-03-18 02:32:17

标签: objective-c xcode swift unit-testing compilation

我有一个混合的objective-c和Swift项目,我尝试为它编写单元测试。 我的项目名称是:Alphaproject 我的产品模块名称是:Alphaproject 我在主目标(Alphaproject)中设置为YES定义模块 并在同一个目标中设置为YES EnableTestability for Debug。

在我的Test类中,我尝试导入我的产品模块名称:

@testable import Alphaproject

附加说明:

  • 我的所有项目文件只是主要目标的一部分
  • 我的测试文件只是测试目标的一部分
  • 我的测试方案设置为Build Debug configuration。
  • 我还尝试清理Build文件夹(ALT + Clean)
  • 项目编译或尝试运行测试时没有任何错误,除此之外&#34;没有这样的模块Alphaproject&#34;

还有其他想法吗?

2 个答案:

答案 0 :(得分:3)

OK!问题来自于我在有效架构的调试配置中使用了arm64这一事实。 由于主要目标也不包含有效架构中的arm64,它显然无法找到模块...... 我认为苹果可以在这里更好地展示正确的错误。 (Apple,如果你读了我,请)

enter image description here

答案 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.