Michael Crump bio photo

Michael Crump

Works at Microsoft on Azure

Twitter Google+ LinkedIn Instagram Github Youtube

Introduction

After reading through the Apple Developer Docs I found this:

“Xcode’s debugger includes an interactive version of the Swift language known as the REPL (Read-Eval-Print-Loop)… you can access it through Xcode’s console or from Terminal.”

Unfortunately it does not tell you how to access it from the terminal but thankfully it is very easy.

Simply enter the following command as shown below (replacing the app name for whichever beta you are using to setup an alias):

alias swift="/Applications/Xcode6-Beta2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift"

You should see the following in your terminal window. Now simply type swift and you will see the welcome message.

terminal

Note: When a new beta comes out just update your alias with the same command but new app name… i.e. Xcode6-Beta3.app.

You can begin entering your Swift code:

terminal2

Finally if you type :help as stated when it first runs you have the LLDB debugging commands at your fingertips.

help

Why wouldn’t you just load the Swift Playground?

Good question. I personally love the ability to play with the syntax without launching Xcode 6 Beta and opening a Swift Playground. Also I am bound to an NDA that says I can’t post screenshots of  Xcode 6 until the final release. This allows me to get around that.