Swift测试失败并出现“模块映射文件”错误

时间:2017-12-21 06:04:26

标签: swift server ubuntu-16.04

我在Ubuntu 16.04上使用Swift 4.0.2进行开发(在Docker容器下)。我使用脚本在命令行运行一系列Swift测试(使用swift test ...)。示例命令行是:

swift test -Xswiftc -DDEBUG -Xswiftc -DSERVER -Xswiftc -DPRIMARY_OWNING_GOOGLE1 --filter ServerTests.UserControllerTests

为了完整起见,这是我用来运行测试的脚本: https://github.com/crspybits/SyncServerII/blob/master/Tools/runTests.sh

在测试之间,我的脚本使用swift package clean来清理构建产品。然而,看似随机的我有时会得到测试失败的输出:

<unknown>:0: error: module map file '/root/Apps/SyncServerII/SyncServerII/.build/checkouts/CCurl.git--3354261816655650653/module.modulemap' not found <unknown>:0: error: module map file 
'/root/Apps/SyncServerII/SyncServerII/.build/checkouts/CCurl.git--3354261816655650653/module.modulemap' not found <unknown>:0: error: module map file 
'/root/Apps/SyncServerII/SyncServerII/.build/checkouts/CCurl.git--3354261816655650653/module.modulemap' not found <unknown>:0: error: module map file 
'/root/Apps/SyncServerII/SyncServerII/.build/checkouts/CCurl.git--3354261816655650653/module.modulemap' not found

或者像这样:

<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "/root/Apps/SyncServerII/SyncServerII/.build/checkouts/Kitura-net.git-7914159224218470268/Sources/CHTTPParser/include/CHTTPParser.h"
         ^ /root/Apps/SyncServerII/SyncServerII/.build/checkouts/Kitura-net.git-7914159224218470268/Sources/CHTTPParser/include/CHTTPParser.h:21:10: error: 'utils.h' file not found
#include "utils.h"
         ^ /root/Apps/SyncServerII/SyncServerII/.build/checkouts/Kitura-net.git-7914159224218470268/Sources/KituraNet/HTTPParser/HTTPParser.swift:17:8: error: could not build C module 'CHTTPParser' import CHTTPParser
       ^

请注意,这是执行测试的问题,而是当Swift工具构建代码以准备运行我的测试时出现的问题。

我可以删除swift test次调用之间的整个构建产品目录(.build),但这会大大增加我的测试时间。有任何想法吗?感谢。

1 个答案:

答案 0 :(得分:0)

可能与上面的内容不完全相关,但是如果您正在使用CocoaPods,并且由于任何pod依赖项而丢失“模块映射文件”错误,请尝试更新到较新的CocoaPods版本。首先使用pods --version,然后使用sudo gem install cocoapods检查您的版本。