How to run Swift from Command Line

Posted by Daniel Vela on June 16, 2015

To run a Swift script in Terminal type the following:

$ swift fileName.swift

Alternatively you can put the following line of text at the top of the script file and run that file

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