Swift运行错误(module name "Swift" is

2019-10-27  本文已影响0人  小宝二代

错误描述:

module name "Swift" is reserved for the standard library
Command CompileSwiftSources failed with a nonzero exit code

错误描述.png
第一句module name "Swift" is reserved for the standard library的意思是Swift是保留在标准库里面的组件名字,所以呢我们不能把它作为工程的名字,我们换一个工程名字就不会报错了。
第二句Command CompileSwiftSources failed with a nonzero exit code意思就是编译失败。Apple对这句话做了解释:

Compilation might fail without displaying the errors responsible for the failure. For example, you might see the message “Command CompileSwiftSources failed with a nonzero exit code” without an accompanying failure reason. (43033749)
Workaround: Disable batch mode by adding a user-defined build setting named SWIFT_ENABLE_BATCH_MODE and set it to NO.

意思就是编译失败时,可能会出现这种提示Command CompileSwiftSources failed with a nonzero exit code,但是并没有明确指出失败的原因,此时可以通过在Build Setting里面自添加一条user-defined(备注:点击Levels边上的 + 号就可以添加),属性为SWIFT_ENABLE_BATCH_MODE,值为NO。再次编译就会提示编译失败的真正原因。文档链接:Swift 4.2 Release Notes for Xcode 10

综上,文章开头截图里面的错误意思就是编译失败,原因是使用了标准库中组件名Swift作为了工程名。

上一篇下一篇

猜你喜欢

热点阅读