Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Programming languages

Swift

Swift from a first program to safe concurrency: types and optionals, protocols and generics, memory and ownership, packages, testing and interop.

19 lessons to read 4 modules

19 lessons: 19 free with Pro answers.

Examples run with Swift 6.4.

Who it is for

Beginners who want Swift before SwiftUI, iOS and Mac developers moving to the Swift 6 language mode and strict concurrency, and Windows or Linux users who want to learn the language before they buy a Mac.

What you will be able to do

  • Install a Swift 6.4 toolchain, build programs with swiftc and SwiftPM, and read what the compiler reports
  • Write programs with values, optionals, control flow, strings, collections, functions and closures
  • Model data with structs, classes, enums and pattern matching, and choose between value and reference types
  • Handle errors with throws and Result, and test code with Swift Testing
  • Design flexible code with protocols, generics, opaque types and existential types
  • Explain how ARC, value semantics, exclusivity and ownership manage memory, and measure what code costs
  • Write concurrent code with async/await, tasks, actors and Sendable in the Swift 6 language mode
  • Use property wrappers, result builders, key paths and macros where they make code clearer
  • Build packages and command-line tools, and call C, C++, Objective-C and Java code
  • Run Swift on Linux servers, in WebAssembly and on microcontrollers

Revise and practise

Modules and lessons

What the labels mean

Free lesson, Pro answers
the whole lesson is free; the model answers to its interview questions open with a pass
Pro
opens with a Pro, Premium or Ultimate pass

Minutes are reading time.

What a pass opens in this track

38 interview answers. The same pass opens every other track and every Pro tool.

  1. Module 1

    Getting started: Swift 6.4, toolchains and your first program

    What Swift is and where it runs, installing a toolchain on macOS, Linux or Windows, a first program three ways, and reading the compiler's errors and language modes.

    1. What Swift is and where it runs Beginner Free lesson, Pro answers: 10 minutes
    2. Install Swift 6.4 on macOS, Linux and Windows Beginner Free lesson, Pro answers: 10 minutes
    3. Your first program: scripts, swiftc and packages Beginner Free lesson, Pro answers: 15 minutes
    4. Compiler errors, language modes and feature flags Beginner Free lesson, Pro answers: 15 minutes
  2. Module 2

    Basics: values, types, operators and control flow

    Constants and type inference, integers and overflow, floating point and Decimal, operators, ranges and tuples, optionals, conditionals and loops.

    1. Constants, variables and type inference Beginner Free lesson, Pro answers: 15 minutes
    2. Integers, overflow traps and wrapping operators Beginner Free lesson, Pro answers: 15 minutes
    3. Floating point, rounding and Decimal for money Beginner Free lesson, Pro answers: 15 minutes
    4. Operators, ranges and tuples Beginner Free lesson, Pro answers: 15 minutes
    5. Optionals: nil, if let, guard let and ?? Beginner Free lesson, Pro answers: 20 minutes
    6. Conditionals: if, guard, switch and expressions Beginner Free lesson, Pro answers: 20 minutes
    7. Loops, labels and control transfer Beginner Free lesson, Pro answers: 20 minutes
  3. Module 3

    Strings, text and collections

    Strings and Unicode, indices and substrings, arrays, sets and dictionaries, map, filter and reduce, lazy sequences and regular expressions.

    1. Strings and Unicode: characters that look right Beginner Free lesson, Pro answers: 20 minutes
    2. String indices, Substring and fast text processing Intermediate Free lesson, Pro answers: 15 minutes
    3. Arrays, sets and dictionaries Beginner Free lesson, Pro answers: 20 minutes
    4. map, filter, reduce and lazy sequences Intermediate Free lesson, Pro answers: 15 minutes
    5. Regex literals and RegexBuilder Intermediate Free lesson, Pro answers: 20 minutes
  4. Module 4

    Functions and closures

    Functions, argument labels and default values, closures and higher-order functions, escaping closures and capture lists.

    1. Functions, argument labels and parameters Beginner Free lesson, Pro answers: 20 minutes
    2. Closures and higher-order functions Intermediate Free lesson, Pro answers: 15 minutes
    3. Escaping closures, capture lists and [weak self] Intermediate Free lesson, Pro answers: 20 minutes

Official documentation

More in Programming languages

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.