为什么在 Xcode 6.3 中 运行 单元测试时构建失败?

Why does the build fail when I run unit tests in Xcode 6.3?

当我尝试 运行 甚至 Xcode 中的默认单元测试时 Swift 项目,构建失败。

import Cocoa
import XCTest

class Test2: 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.
    }
}

}

这发生在我自己的 MBP 和我雇主提供的 MBP 上。不禁想到是项目设置的问题

适用于 Objective-C 测试。

非常感谢任何帮助,我已经拔掉了剩下的一点头发。

您不小心添加了一个 OS X 测试用例(您可以看到它是因为 import Cocoa)。有时会发生这种情况,因为 Xcode 选择了错误的来源。

当您向项目添加测试时,请确保这些是 iOS 测试。