'Module was not compiled for testing' when using @testable

前端 未结 10 883
难免孤独
难免孤独 2020-12-04 14:00

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:

10条回答
  •  忘掉有多难
    2020-12-04 14:25

    This is probably because your main target Enable Testability is set to NO. You should set it to YES in the debug scheme (which is used for running your tests).

    If you use Carthage, this problem can be caused by importing frameworks with @testable, because they are built with a release scheme.

    Most of the times it's bad practice to import frameworks with that prefix, so you could avoid it. If you can't, you should Enable Testability in the frameworks' release scheme. https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html#//apple_ref/doc/uid/TP40001051-CH1-SW326

提交回复
热议问题