Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ylluminate/ad944a761180e462ac87 to your computer and use it in GitHub Desktop.
Save ylluminate/ad944a761180e462ac87 to your computer and use it in GitHub Desktop.

How to use swift in your terminal

setup

First, install Xcode 6 beta.

And run it.

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

By xcrun swift, repl will start.

$ xcrun swift
Welcome to Swift!  Type :help for assistance.
  1> var x = 3
x: Int = 3

How to compile

Write swift code.

foo.swift

func x() -> Int {
	return 3
}

println("hello")

compile

$ xcrun swift foo.swift
$ ./foo
hello

It works! yey!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment