Skip to content

Instantly share code, notes, and snippets.

@zlargon
Last active August 29, 2015 14:12
Show Gist options
  • Save zlargon/936d7643a9fe5a86bac7 to your computer and use it in GitHub Desktop.
Save zlargon/936d7643a9fe5a86bac7 to your computer and use it in GitHub Desktop.
Using Swift command line
  1. install Xcode

  2. install Xcode command line tools

http://cmd.hhmr.biz/2013/09/mavericksxcode-command-line-tools.html

  1. setup the xcode path
$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/

use swift to execute the source code file

$ swift <your_source_code>.swift

or

(1) add this line at the top of the file

#!/usr/bin/swift

(2) change the file to executable

$ chmod +x <your_source_code>.swift

(3) execute the file in Terminal

$ ./<your_source_code>.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment