With Xcode installed, I would like to compile and run a .swift file in the command line. Understood, this can be done:
xcrun swift sayHello.swift
However, I would like to pass an argument in the command line.
For example, with the following function in sayHello.swift:
func sayHello(personName: String) -> String {
let greeting = "Hello, " + personName + "!"
return greeting
}
How do you pass an argument, e.g. Bob? This looked promising:
-D Specifies one or more build configuration options
xcrun swift -D sayHello(Bob) sayHello.swift
But, it's not what I expected.