我正在尝试为我的项目设置单元测试。这是现有的Objective-C应用程序,最近我添加了一个Swift类。我已经设置了“ MyProject-Swift.h”和Swift桥接文件(“ MyProject”和“ MyProjectTest”),并且能够使用Objective-C和Swift代码很好地构建和运行该应用程序。
但是,现在我想在新的Swift类上运行一些单元测试。我设置了测试文件,它看起来如下所示:
MySwiftClassTests.swift:
import UIKit
import XCTest
import MyProject
class MySwiftClassTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
// Put the code you want to measure the time of here.
}
}
}
当以测试方式运行应用程序时出现此错误:
'MyProject-Swift.h' file not found
我不确定为什么只有在尝试运行测试时才会发生这种情况。有什么建议?