Skip to content

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:

  1. What & why – the idea in plain language
  2. Examples – code you should type out yourself
  3. Common mistakes – the traps everyone hits
  4. Exercises – do these; reading is not learning
  5. 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.

swift --version
  • 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 swiftly toolchain 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

  1. Setup & your first program
  2. Constants, variables & types
  3. Numbers & math
  4. Strings & characters
  5. Booleans & conditionals
  6. Loops
  7. Arrays
  8. Dictionaries & sets
  9. Functions
  10. Optionals
  11. Files & error handling
  12. Capstone: command-line task tracker

Intermediate

  1. Structs & classes
  2. Properties & methods
  3. Enums & pattern matching
  4. Protocols & extensions
  5. Generics
  6. Closures & higher-order functions
  7. Memory management & ARC
  8. Error handling in depth
  9. Codable & JSON
  10. Swift Package Manager
  11. Testing
  12. Capstone: Markdown link checker

Advanced

  1. Protocol-oriented design: some, any & dispatch
  2. Advanced generics
  3. Property wrappers, result builders & key paths
  4. Macros
  5. Concurrency: async/await & structured concurrency
  6. Actors, Sendable & data-race safety
  7. AsyncSequence, AsyncStream & continuations
  8. Ownership: noncopyable types, borrowing & consuming
  9. Performance & profiling
  10. Unsafe Swift & C interoperability
  11. Libraries, ABI & distribution
  12. Capstone: parallel file indexer

License

Use freely for learning and teaching.