Setting Up Your Development Environment
Prerequisites: Installing Swift
Which editor you use depends on what you're building:
- Xcode (macOS) — Apple's IDE, required for iPhone, iPad, and Mac apps. It includes a code editor, the interface previews, simulators, a debugger, and performance tools.
- Visual Studio Code with the official Swift extension (from the Swift project) — free and cross-platform, with autocomplete, inline errors, debugging, and test running. A good choice for learning the language on Linux or Windows, and for command-line and server code.
For the lessons in Level 1 and Level 2, you only need a way to run
.swift files. Create a folder for your practice files and open it in
your editor.
Playgrounds
Xcode has playgrounds: files that run your code as you type and show each line's result in a side panel. Create one with File → New → Playground. They're excellent for experimenting with the examples in these lessons.
The REPL
Running swift repl in a terminal (on Linux and macOS) starts an
interactive session where you type one line at a time:
$ swift repl
1> let x = 2 + 3
x: Int = 5
2> :quit