我对Kitura和Xcode很陌生,在添加测试文件时也会遇到一些问题。它似乎与@testing指令有关。我已经设置了与Kitura网站上显示的相同的设置。当我在控制台中调用迅速构建,然后调用快捷测试时,我得到以下错误:
Compile Swift Module 'testTests' (1 sources)
Linking ./.build/debug/testPackageTests.xctest/Contents/MacOS/testPackageTests
Undefined symbols for architecture x86_64:
"__TFC4test3OkoCfT_S0_", referenced from:
__TFC9testTests8OkoTests8test_addfT_T_ in OkoTests.swift.o
"__TMaC4test3Oko", referenced from:
__TFC9testTests8OkoTests8test_addfT_T_ in OkoTests.swift.o
ld: symbol(s) not found for architecture x86_64
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/*user*/Projects/Kitura/test/.build/debug.yaml test但是,当我注释掉行@testable导入测试并键入迅速构建,然后是测试时,我会得到以下错误:
Compile Swift Module 'testTests' (1 sources)
/Users/*user*/Projects/Kitura/test/Tests/testTests/OkoTests.swift:6:17: error: use of unresolved identifier 'Oko'
let o = Oko()
^~~
<unknown>:0: warning: 'cacheParamsComputed' is deprecated
<unknown>:0: warning: 'cacheAlphaComputed' is deprecated
<unknown>:0: warning: 'keepCacheWindow' is deprecated
<unknown>:0: error: 'memoryless' is unavailable
Metal.MTLCommandBufferError:19:14: note: 'memoryless' has been explicitly marked unavailable here
case memoryless
^
<unknown>:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/*user*/Projects/Kitura/test/.build/debug.yaml test当我尝试从Xcode生成的项目测试它(快速包生成-xcodeproj)时,我会得到编译错误:

没有测试文件,一切都正常工作。下文介绍项目结构:

发布于 2017-02-08 17:21:33
我认为问题在于Swift无法为包含main.swift文件的模块编译单元测试(也就是说,与用于其他项目的库相比,这些模块被编译成可执行文件)。我克隆了您的repo,并在删除main.swift和2)取消对可测试导入语句的注释之后,能够编译和运行单元测试。
https://stackoverflow.com/questions/42101177
复制相似问题