The Swift Course¶
A complete, self-paced Swift curriculum in Markdown, from your first print to structured concurrency and ownership. Work through it top to bottom, or jump to the level that matches your experience.
How this course is organized¶
| Folder | For you if... | Outcome |
|---|---|---|
| Beginner | You have never written Swift (or never finished a course) | Write and run real programs, understand the core language, build a command-line app that saves data |
| Intermediate | You know the syntax but structs vs classes, protocols, generics and closures still feel shaky | Value and reference types, enums, protocols, generics, ARC, Codable, SwiftPM, testing, a real project |
| Advanced | You ship Swift and want depth | Protocol-oriented design, advanced generics, macros, async/await, actors, ownership, performance, C interop, a concurrent capstone |
Each lesson is one file and follows the same shape:
- What & why – the idea in plain language
- Examples – code you should type out yourself
- Common mistakes – the traps everyone hits
- Exercises – do these; reading is not learning
- Recap
Each level ends with a capstone project. The complete, buildable source for all three lives in the capstones/ folder of the repository, and CI builds and tests them on Linux and macOS.
Setup (do this first)¶
You need Swift 6.0 or newer. It runs on macOS, Linux and Windows, and you do not need Xcode.
- macOS: install Xcode from the App Store, or just the command-line tools with
xcode-select --install - Windows:
winget install --id Swift.Toolchain -e(plus Visual Studio Build Tools with the C++ workload) - Linux: follow swift.org/install or use the
swiftlytoolchain manager
A good editor helps a lot: VS Code with the official Swift extension (works on every platform), or Xcode on a Mac.
Every example in this course is meant to be run either as a one-file script or inside a package:
swift scratch.swift # run a single file
swift package init --type executable
swift run # build and run a package
swift test # run its tests
How to study¶
- Type every example. Copy-paste teaches you nothing.
- Read the compiler errors. Swift's errors are detailed; start at the first one.
- Break things on purpose. Change a line, predict the result, compile, run.
- Do the exercises before looking anything up.
- One lesson per sitting is plenty. Consistency beats marathons.
Curriculum at a glance¶
Beginner¶
- Setup & your first program
- Constants, variables & types
- Numbers & math
- Strings & characters
- Booleans & conditionals
- Loops
- Arrays
- Dictionaries & sets
- Functions
- Optionals
- Files & error handling
- Capstone: command-line task tracker
Intermediate¶
- Structs & classes
- Properties & methods
- Enums & pattern matching
- Protocols & extensions
- Generics
- Closures & higher-order functions
- Memory management & ARC
- Error handling in depth
- Codable & JSON
- Swift Package Manager
- Testing
- Capstone: Markdown link checker
Advanced¶
- Protocol-oriented design:
some,any& dispatch - Advanced generics
- Property wrappers, result builders & key paths
- Macros
- Concurrency: async/await & structured concurrency
- Actors, Sendable & data-race safety
- AsyncSequence, AsyncStream & continuations
- Ownership: noncopyable types, borrowing & consuming
- Performance & profiling
- Unsafe Swift & C interoperability
- Libraries, ABI & distribution
- Capstone: parallel file indexer
License¶
Use freely for learning and teaching.