Xcode - 文件是模块的一部分,忽略导入 [英] Xcode - File is part of module, ignoring import
问题描述
我有现有的 iOS 项目,添加了单元测试目标并在 tests
文件夹中创建了新的测试用例文件.当我尝试导入模块时,我遇到了这个问题.我参考了下面的堆栈溢出问题,但它没有解决我的问题.
I have existing iOS project, added Unit test target and created new test case file in tests
folder. When i tried to import module i'm facing this issue. I referred the below stack overflow question but it did not solve my problem.
@testable import wl_pih // Error: File 'wl_pihTests.swifts' is part of module 'wl_pih'; ignoring import
class wl_pihTests: XCTestCase {
let loginController = INCLoginViewController() //Not accessable
override func setUp() {
super.setUp()
}
override func tearDown() {
super.tearDown()
}
}
推荐答案
错误告诉你,因为你的 test 文件在你的 wl_pih
目标中,所以没有必要对于 @testable import wl_pih
语句.@testable import
用于 单元测试 或 UI 测试 目标中的测试文件,以允许他们访问目标中的文件想测试.最简单的解决方法是删除您的导入.不过,您真正应该做的是将您的测试文件放在您的单元测试目标中(这样它们就不会被捆绑到您的可交付应用程序中),然后离开每个测试文件中的 @testable import
语句.
The error is telling you that because your test file is in your wl_pih
target, there's no need for the @testable import wl_pih
statement. @testable import
is used in test files that are in a unit test or UI test target to give them access to files in the target that you want to test. The easiest fix is to delete your import. What you really should do, though, is to put your test files in your unit testing target (so that they don't get bundled into your deliverable app), and leave the @testable import
statement in each test file.
这篇关于Xcode - 文件是模块的一部分,忽略导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!