Swift
Swift from a first program to safe concurrency: types and optionals, protocols and generics, memory and ownership, packages, testing and interop.
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
- Practice: every exercise and quiz (19 quizzes)
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.
- 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.
- What Swift is and where it runs Free lesson, Pro answers: 10 minutes
- Install Swift 6.4 on macOS, Linux and Windows Free lesson, Pro answers: 10 minutes
- Your first program: scripts, swiftc and packages Free lesson, Pro answers: 15 minutes
- Compiler errors, language modes and feature flags Free lesson, Pro answers: 15 minutes
- 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.
- Constants, variables and type inference Free lesson, Pro answers: 15 minutes
- Integers, overflow traps and wrapping operators Free lesson, Pro answers: 15 minutes
- Floating point, rounding and Decimal for money Free lesson, Pro answers: 15 minutes
- Operators, ranges and tuples Free lesson, Pro answers: 15 minutes
- Optionals: nil, if let, guard let and ?? Free lesson, Pro answers: 20 minutes
- Conditionals: if, guard, switch and expressions Free lesson, Pro answers: 20 minutes
- Loops, labels and control transfer Free lesson, Pro answers: 20 minutes
- 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.
- Strings and Unicode: characters that look right Free lesson, Pro answers: 20 minutes
- String indices, Substring and fast text processing Free lesson, Pro answers: 15 minutes
- Arrays, sets and dictionaries Free lesson, Pro answers: 20 minutes
- map, filter, reduce and lazy sequences Free lesson, Pro answers: 15 minutes
- Regex literals and RegexBuilder Free lesson, Pro answers: 20 minutes
- Module 4
Functions and closures
Functions, argument labels and default values, closures and higher-order functions, escaping closures and capture lists.
- Functions, argument labels and parameters Free lesson, Pro answers: 20 minutes
- Closures and higher-order functions Free lesson, Pro answers: 15 minutes
- Escaping closures, capture lists and [weak self] Free lesson, Pro answers: 20 minutes
Official documentation
- The Swift Programming Language (6.4) (Swift.org)
- Swift.org documentation (Swift.org)
- Swift standard library (Apple)