[swift-users] ProcessInfo arguments when running as a script?

Jon Shier jon at jonshier.com
Thu Aug 18 21:14:12 CDT 2016


Swift Users:
	I’m trying to parse the command-line arguments of a Swift 3 script using Xcode 8 beta 6. However, ProcessInfo’s arguments array now contains all of the swift compiler arguments as well as the command itself. For example, this script:

#!/usr/bin/env swift

import Foundation

print(ProcessInfo.processInfo.arguments)

now prints:

["/Users/jshier/Downloads/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift”, 
"-frontend”, 
"-interpret”, 
"./processInfo.swift”,
 "-target”,
 "x86_64-apple-macosx10.9”,
 "-enable-objc-interop”, 
"-sdk”, 
"/Users/jshier/Downloads/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk”,
"-color-diagnostics”,
 "-module-name”,
 "processInfo"]

(arguments broken into lines for readability)

Is this a bug (and if so, does it need to be reported) or is it an intentional change (if so, how are we supposed to parse arguments now?)?



Jon



More information about the swift-users mailing list