I am trying to exit the command line utility with error codes in Swift 2.2 on Linux. I tried to solve the problem this question , but I still get an unresolved identifier. A simple test script that replicates the problem:
$> cat exit_test.swift import Foundation guard 0 == 1 else { exit(0) }
The following error message appears:
$> swift exit_test.swift exit_test.swift:3:21: error: use of unresolved identifier 'exit' guard 0 == 1 else { exit(0) }
It seems that exit no longer imported with Foundation , but I'm not sure where to look for the next way to exit the given error code. I am running Swift 2.2-dev :
$> swift --version Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c) Target: x86_64-unknown-linux-gnu
source share