9
OS的使用:Ubuntu的16.04错误:无法解析的标识符 '过程'
斯威夫特版本:3.0预览版6
我按照这个getting started page
在greeter.swift
func sayHello(name: String) {
print("Hello, \(name)!")
}
main.swift
if Process.arguments.count != 2 {
print("Usage: hello NAME")
} else {
let name = Process.arguments[1]
SayHello(name: name)
}
错误我收到
$ swift build
Compile Swift Module 'myapp' (2 sources)
/Sources/main.swift:1:4: error: use of unresolved identifier 'Process'
if Process.arguments.count != 2 {
^~~~~~~
/Sources/main.swift:4:16: error: use of unresolved identifier 'Process'
let name = Process.arguments[1]
^~~~~~~
<unknown>:0: error: build had 1 command failures
error: exit(1): swift/bin/swift-build-tool -f .build/debug.yaml
CommandLine是GitHu中的一个项目b而不是Swift核心库的一部分。 https://github.com/jatoben/CommandLine –
这工作!谢谢。 – ECMAScript
@ChristianAbella:'CommandLine'是核心Swift 3的一部分:https://github.com/apple/swift/blob/master/stdlib/public/core/CommandLine.swift。另见https://github.com/jatoben/CommandLine/issues/77。 –