首页 > 解决方案 > Xcode 中的测试不会因运行时错误而执行

问题描述

每次我尝试在任何项目上运行测试时,都会遇到一个奇怪的运行时错误。我将此功能添加到一个全新的项目(delete_me)

func easyAdd(x: Int, y: Int) -> Int {
    return x + y
}

和这个测试

import
@testable import delete_me
...
    func test_easyAdd() {
        ...
        let sum: Int = easyAdd(x: 20, y: 30)
        XCTAssertEqual(sum, 50)
    }

我得到一个运行时错误,Undefined symbol: delete_me.easyAdd(x: Swift.Int, y: Swift.Int) -> Swift.Int 还有一点调试错误是

Undefined symbols for architecture x86_64: "delete_me.easyAdd(x: Swift.Int, y: Swift.Int) -> Swift.Int", referenced from: Tests_iOS.Tests_iOS.test_easyAdd() -> () in Tests_iOS.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

我觉得这必须是关于我的 Xcode 是如何安装的,或者一些缺少的工具,或者一些工具安装在错误的位置,但我不确定如何解决这个问题。

标签: iosswiftxcodexctest

解决方案


推荐阅读