2016-08-23 2 views
9

ОС: Ubuntu 16,04Ошибка: Использование неразрешенного идентификатора 'процесса'

Swift Версия: 3.0 Preview 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 

ответ

19

Процесс был изменен на CommandLine в быстром 3.0

Попробуйте заменить Process с CommandLine


Вот ссылка на коммит, который изменил его: Rename Process to CommandLine [SE-0086].

+0

CommandLine - это проект в GitHu b, а не часть базовой библиотеки Swift. https://github.com/jatoben/CommandLine –

+0

Это сработало! Спасибо. – ECMAScript

+5

@ChristianAbella: 'CommandLine' является частью ядра Swift 3: https://github.com/apple/swift/blob/master/stdlib/public/core/CommandLine.swift. См. Также https://github.com/jatoben/CommandLine/issues/77. –