Your first Swift Application — without a Mac OR Xcode

Using Xcode requires a Mac, but you can code in Swift without either!

Many tutorials seem to indicate that you need a Mac with the Xcode IDE to start coding an using Swift. This is not entirely true. Scrub that, it’s not true at all.

Image for post
Image for post
Photo by Max Nelson on Unsplash

This tutorial uses Swift (any version is fine) and covers using an online IDE which at the time of writing (December 2019) defaults to Swift 5.1. You may of course use your installed version of Xcode.


Character: A written character, usually associated with a letter of the alphabet

Console: A simple window for programming that can display output and (usually) process input

“Hello, World!”: A program or script that outputs “Hello World” to the console or has some other way of displaying the appropriate message

Integrated Development Environment (IDE): An application that provides a set of features that are used by software developers to create computer software

Online IDE: An IDE which can run your code through the Internet (often leveraging a browser)

Swift: An open source programming language for macOS, iOS, watchOS and tvOS

String: A collection of Characters

Why Hello World!?

Simple tutorials usually begin with a “Hello world” tutorial. Those outside the programming community can feel that this is an unusual thing to choose, as it seems to have been picked simply because it is a simple word String (or just String) to print to the screen.

But why would anyone choose that particular String?

We can start at the beginning. There is a book about C programming which used a “Hello, World!” example — although this was actually lifted from a Programming in C: A Tutorial (1974) book.

The actual “Hello, World!” application that tutorials ask you to produce vary in sophistication and implementation, but the basic idea is that you print “Hello, World!” in some form.

With that settled, let us move on.

The Online IDE — restrictions

Swift can be accessed through an online IDE. is fairly full-featured, but seems to lack an easy way to upload code — so if you follow along with any of my other tutorials with swift code you will need to copy ⌘- C and paste ⌘- P the code into your chosen web browser. Not too bad (but not ideal).

If you want to create iOS applications with a front-end that looks like your mobile, this isn’t the right solution for you. This is for coding in hard-core Swift only.

Hard core, but not difficult in any sense of the word.

The Online IDE — setup

You simply go to in your favourite (or default) browser.

Image for post
Image for post

By clicking run you…already have a “Hello World” program. But wait — this is not the traditional “Hello, World!” program that we are expecting and want to run.

No. We are going to do this properly and in good time.

The Online IDE — The “Hello, World!” program

You can now simply use Swift to print to the screen.

There isn’t going to be a surprise here, considering what you’d already seen in the default program.

Leave the import Foundation statement at the top of the screen, and replace the next statement (which is print (“Hello World”)) with the next fantastic line:

print (“Hello, World!)

Now you can press therun button

Image for post
Image for post

Well done!

Give yourself a pat on the back!

Using the online IDE to save your file

You might write a particularly great program. It might also have a fantastic algorithm. One of the disadvantages to this is that using the online IDE it might be lost forever.

Worry no more

You can save files easily.

If we take it from our first program that we wrote above, we can now save the target file.

You’ll see that there are two choices once you press Download — Playground.swift and Playground.playground.

Which should you pick?

If you plan to keep coding on Online Swift Playground I’d choose Playground.swift as this gives you a simple Swift file to work with. This means you can open it in any text editor to copy and paste back into the IDE as mentioned above.

If you plan on using a Mac running Xcode in the future it doesn’t really matter which you choose.

Image for post
Image for post


Writing your first program in Swift is not too much of a challenge — admittedly here most of the work has been done for you by just loading up the online IDE.

But there is an important point:

Image for post
Image for post
Photo by Kelly Sikkema on Unsplash

However, it is the first building block on a programming journey that many people have started. It is also crucial to become familiar with the terminology and ideas behind programming, and this has been a great start.

You’ve done great. Well done!

Want to get in contact? Try the link here:

I’d love to hear from you!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store