Swift as a shell-like interpreted language

Jul 16, 2014 00:00 · 52 words · 1 minute read swift

Firstly you need to setup your environment to use the new Xcode 6

sudo xcode-select --switch /Applications/Xcode6-Beta4.app/Contents/Developer

Next you can now use this in the top of your Swift scripts

#!/usr/bin/env xcrun swift -i

Now it’s playtime!

[peacock@trashcan ~]$ cat helloworld.swift 
#!/usr/bin/env xcrun swift -i

println("Hello, World")
[peacock@trashcan ~]$ ./helloworld.swift 
Hello, World