【问题标题】:Error: Use of unresolved Identifier 'Process'错误:使用未解析的标识符“进程”
【发布时间】:2016-08-23 01:53:40
【问题描述】:

操作系统:Ubuntu 16.04

Swift 版本: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

【问题讨论】:

    标签: swift


    【解决方案1】:

    在 swift 3.0 中进程已更改为命令行

    尝试将Process 替换为CommandLine


    这是更改它的提交的链接: Rename Process to CommandLine [SE-0086].

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多