Simple Swift CLI Apps

Using Xcode 6 and xcrun it's super easy to compile and run Swift Apps in a script-like manner.Ideally just create a .swift file and make it executable chmod +x. Take a look at those two Hello World samples and try it out yourself.It's easy and very handy at the same time.

Make the App executable and run it:

chmod +x hello.swift
./hello.swift

The App should echo Hello World!:

Now let's do something more interactive, let's change our code to this:

./hello.swift Marcus

And voilĂ :

Hello Marcus!

There you go, happy coding.