使用@testable时,“模块未编译进行测试” [英] 'Module was not compiled for testing' when using @testable
问题描述
我正在尝试使用Swift 2的新 @testable
声明来将我的类公开给测试目标。但是我收到这个编译错误:
I'm trying to use Swift 2's new @testable
declaration to expose my classes to the test target. However I'm getting this compiler error:
间隔
是包含我试图公开的类的模块。如何摆脱此错误?
Intervals
is the module that contains the classes I'm trying to expose. How do I get rid of this error?
推荐答案
在主目标中,您需要设置启用可测试性
构建选项为是。
In your main target you need to set the Enable Testability
build option to Yes.
根据以下@earnshavian的评论,这应仅用于调试版本,如苹果发行说明:Enable Testability构建设置应仅在您的Debug配置中使用,因为它禁止依赖于不从应用程序或框架导出内部符号的优化 https://developer.apple.com/library/content/ releasenotes / DeveloperTools / RN-Xcode / Chapters / Introduction.html#// apple_ref / doc / uid / TP40001051-CH1-SW326
As per the comment by @earnshavian below, this should only be used on debug builds as per apple release notes: "The Enable Testability build setting should be used only in your Debug configuration, because it prohibits optimizations that depend on not exporting internal symbols from the app or framework" https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html#//apple_ref/doc/uid/TP40001051-CH1-SW326
这篇关于使用@testable时,“模块未编译进行测试”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!