Getting Started with Swift Development

In This Tutorial

  1. What Is Swift and Why Learn It?
  2. What You'll Need
  3. Installing Xcode
  4. Creating Your First Playground
  5. Writing Your First Swift Code
  6. How Playgrounds Work
  7. Next Steps

Welcome to the Ultimate Swift Language Series. In this first chapter, you'll set up everything you need to start writing Swift code. By the end, you'll have Xcode running and your first Swift program working in a playground.

No prior programming experience is required. If you've never written a line of code before, you're in the right place.

What Is Swift and Why Learn It?

Swift is Apple's programming language for building apps on every Apple platform — iPhone, iPad, Mac, Apple Watch, Apple TV, and Vision Pro. Apple introduced it in 2014 as a modern replacement for Objective-C, and it has since become one of the most popular programming languages in the world.

Here's why Swift is worth learning:

Whether you want to build the next great iPhone app, a macOS productivity tool, or an Apple Watch companion — it all starts with Swift.

What You'll Need

Before writing any code, let's make sure your setup is ready. You need two things:

1. A Mac running macOS Sequoia 15 or later

Swift development requires a Mac. If you're on an older macOS version, open System Settings → General → Software Update and install the latest version. Always keep security patches current — Apple ties Xcode versions to macOS versions, so staying updated avoids compatibility headaches.

Which Mac do I need?

Any Mac from 2018 or later will work fine. Apple Silicon Macs (M1 and newer) compile Swift significantly faster than Intel models, but either works. Xcode needs about 35 GB of disk space, so make sure you have room.

2. Xcode 16.2 or later

Xcode is Apple's free development environment. It includes everything you need: a code editor, compiler, debugger, simulator, and Interface Builder. We need version 16.2 at minimum because it ships with Swift 6 — the version this entire series is based on.

Swift 6 introduced major language changes including strict concurrency checking and typed throws. All code examples in this series use Swift 6 features, so running an older version will cause compiler errors.

Setup checklist

Installing Xcode

Open the App Store on your Mac and search for "Xcode." Tap Get, then Install. The download is large (around 13 GB compressed), so give it some time on slower connections.

First launch takes a while

When you open Xcode for the first time, it will ask to install additional components (command-line tools and platform support). Click Install and wait — this can take 5-10 minutes. It only happens once.

Once installation finishes, launch Xcode from your Applications folder. You'll see the Welcome window with options to create a new project, clone a repository, or open an existing project. For now, we'll use something simpler: a playground.

Creating Your First Playground

A playground is a special Xcode file that lets you write and run Swift code instantly, without building a full app. Think of it as a scratch pad — you type code on the left, and results appear on the right in real time. It's the fastest way to learn Swift.

Here's how to create one:

  1. Open Xcode (if it's not already open)
  2. From the menu bar: File → New → Playground
  3. Choose Blank under the macOS or iOS tab (either works for learning Swift)
  4. Name it something like SwiftBasics and save it anywhere convenient

Xcode will create the playground and open it. You'll see a code editor on the left with some starter code, and a results sidebar on the right.

Writing Your First Swift Code

Your new playground should contain one line of code:

import Cocoa var greeting = "Hello, playground"

Let's break this down:

Now let's add our own code. Click at the end of the last line, press Return, and type:

import Cocoa var greeting = "Hello, playground" // My first Swift code print("Hello, Swift!") let myName = "Swift Developer" print("My name is \(myName)") let currentYear = 2026 print("I'm learning Swift in \(currentYear)")

Press Shift + Return or click the blue Play button at the bottom of the editor to run the playground. In the results sidebar (and the console at the bottom), you should see:

Hello, Swift! My name is Swift Developer I'm learning Swift in 2026

Congratulations — you just wrote and ran your first Swift program.

Let's unpack what we wrote:

Try it yourself

Change "Swift Developer" to your actual name and run the playground again. Experiment! Change the year, add more print() statements, see what happens. Playgrounds are designed for tinkering.

How Playgrounds Work

Playgrounds are different from normal Xcode projects in a few important ways:

Playground quirks

Playgrounds can sometimes be slow with large code blocks or when importing heavy frameworks. If the playground seems stuck, try pressing Editor → Run Playground from the menu bar, or restart Xcode. This is normal — playgrounds prioritize convenience over performance.

Next Steps

You now have a working Swift development environment and you've written your first code. Here's what we covered:

In Chapter 2: Variables, Constants & Types, we'll dive deeper into how Swift handles data. You'll learn about integers, doubles, booleans, type inference, type safety, and why Swift makes you think about types more carefully than most languages.

Ship your apps faster

When you're ready to publish your Swift app to the App Store, Simple App Shipper handles metadata, screenshots, TestFlight, and submissions — all in one place.

Try Simple App Shipper