Marcus Kida's Blog

Hey! 👋 I'm Marcus, a Freelance Senior iOS Developer 📱 CTO-as-a-Service and CEO @Bearologics. I'm solving problems through code. Want to hire me? 👉 Let's talk!

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.

Tagged with: