< Back

# 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.

{% gist kimar/bef23aece1ec3c6e798d %}

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:

{% gist kimar/d411f5feed2bb3549237 %}

./hello.swift Marcus

And voilĂ :

Hello Marcus!

There you go, happy coding.

Impressum • Mastodon • Bluesky