gpt4 book ai didi

swift - 错误 : Use of unresolved Identifier 'Process'

转载 作者:IT王子 更新时间:2023-10-29 05:25:51 25 4
gpt4 key购买 nike

操作系统: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 3.0 中 Process 改为 CommandLine

尝试用 CommandLine 替换 Process


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

关于swift - 错误 : Use of unresolved Identifier 'Process' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39091161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com