Setting Up Swift
Installing Swift, running your first file, and where Xcode and Swift Playgrounds fit in.
2 min de lecture
You don't need a Mac to write Swift, but you do need one to build a real iOS or macOS app — Apple's app-building tools (Xcode, the simulators) only run on macOS. For learning the language itself, though, you have options on any platform.
On macOS: Xcode
Xcode is Apple's IDE, and it bundles the Swift compiler along with everything needed to build and run apps. If you're on a Mac and plan to build real apps eventually, install Xcode from the App Store — it's the standard tool professional Swift developers use daily.
Xcode also includes Playgrounds, a scratchpad mode that runs Swift code live as you type it, showing results inline next to each line. It's the fastest way to experiment with a language feature without setting up a full project.
On any platform: the Swift toolchain
Swift itself is open source and installable on Linux and Windows via the official toolchain. Once installed, you interact with it the same way you would with any compiled language:
swift hello.swiftThat command compiles and immediately runs a single file — perfect for working through language exercises without the overhead of a full app project. For anything longer than a few lines, most people just download a toolchain and use a plain text editor plus the terminal.
Your first file
Create a file named hello.swift:
let name = "Swift"
print("Hello, \(name)!")Running it (swift hello.swift on the command line, or pasting it into a Playground) prints:
Hello, Swift!
That's the entire program — no boilerplate, no required main function for a top-level script file. Swift executes top-level statements in a file named this way in order, top to bottom.
What this course assumes
Every code example in this course is a self-contained Swift snippet you can paste into a Playground or run with swift filename.swift. You won't need Xcode's app-building features (storyboards, simulators, project settings) until you move on to building actual apps — which is exactly what the closing SwiftUI lesson points you toward.
For now, the only tool that matters is something that can compile and run a .swift file, so you can see each concept work rather than just read about it.