Over a million developers have joined DZone.

Running Swift from the Terminal

· Java Zone

Discover how AppDynamics steps in to upgrade your performance game and prevent your enterprise from these top 10 Java performance problems, brought to you in partnership with AppDynamics.

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.


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:


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


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.

The Java Zone is brought to you in partnership with AppDynamics. AppDynamics helps you gain the fundamentals behind application performance, and implement best practices so you can proactively analyze and act on performance problems as they arise, and more specifically with your Java applications. Start a Free Trial.


Published at DZone with permission of Michael Crump .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}