Learn Swift
Learn the language of iPhone and Mac apps, from optionals to SwiftUI.
Free to start. Built from a single prompt. No credit card.
Swift is the modern, open-source language Apple introduced in 2014 for building apps on iPhone, iPad, Mac, Apple Watch and Apple TV. It is fast and type-safe, and its signature feature is optionals, which force you to handle the possibility that a value is missing instead of crashing on nil. Swift favors value types like structs, protocol-oriented design and concise closures, and it pairs with SwiftUI for declarative interfaces. Learnr builds a personalized Swift course from your prompt and teaches it through short, interactive lessons, starting with the language itself before you build screens.
How to learn Swift, step by step
- Experiment in a playground first. Use an Xcode playground on a Mac or the Swift Playgrounds app on iPad or Mac to run code instantly. Test let versus var, string interpolation and type inference before thinking about apps.
- Learn optionals until they feel natural. Understand why a String? may be nil, and practice if let, guard let, nil coalescing with ?? and optional chaining. Avoid force unwrapping with !, which crashes the app when the value is missing.
- Choose structs by default and know why. Structs are copied, while classes are shared references. Model most data as structs, use enums with associated values for states, and reach for classes only when you need shared identity.
- Practice closures and higher-order functions. Use map, filter, reduce and sorted(by:) with trailing closure syntax. SwiftUI and many Apple APIs take closures constantly, so reading them fluently pays off immediately.
- Learn protocols and error handling. Define protocols, adopt standard ones like Codable and Identifiable, and handle failure with throws, do and try. Decode a small JSON file into structs with Codable as practice.
- Build a small SwiftUI app. Make a tip calculator, a habit tracker or a list app with @State and navigation, following Apple's free SwiftUI tutorials. A short Learnr lesson each day keeps language details sharp as the app grows.
What you'll learn
- Write Swift with constants, variables, collections and control flow
- Handle missing values safely with optionals, if let and guard
- Model data with structs, classes and enums with associated values
- Use closures and protocols to write flexible, reusable code
- Build a simple SwiftUI screen backed by your own data model
What's inside your Swift course
A sample path Learnr builds for Swift. Your real course adapts to your goal and level.
- 1. Swift basics in Xcode playgrounds
- 2. Collections, control flow and functions
- 3. Optionals and safe unwrapping
- 4. Structs, classes, enums and protocols
- 5. Closures, error handling and async/await
- 6. Your first SwiftUI view
How long does it take to learn Swift?
Swift language basics take about 4 to 8 weeks at 5 hours a week. Building a small working SwiftUI app usually takes 2 to 4 months in total. Experience with another typed language like Kotlin or C# shortens the language phase considerably.
What you need before you start
No programming experience is required. Building iPhone apps in Xcode requires a Mac, though you can learn the language itself in Swift Playgrounds on an iPad.
Common mistakes to avoid
- Force unwrapping optionals with ! to make errors go away. Use if let, guard let or a default value so missing data does not crash the app.
- Jumping into app screens before learning the language. Spend a few weeks on Swift itself and SwiftUI code will be far easier to read.
- Using classes everywhere out of habit from other languages. Default to structs and learn why value semantics prevent many shared-state bugs.
How Learnr builds your course
Type your topic
Tell Learnr you want to learn Swift, or get as specific as you like.
Get a personalized course
Learnr instantly builds a full Swift course tailored to your goal and skill level.
Learn and level up
Move through bite-sized lessons and interactive practice, earning XP and keeping your streak.
Swift questions, answered
Do I need a Mac to learn Swift?
To build and submit iPhone or Mac apps, yes, because Xcode runs only on macOS. You can learn the language in Swift Playgrounds on an iPad, and Swift itself also runs on Linux and Windows.
Should I learn Swift or SwiftUI first?
Learn core Swift first, especially optionals, structs and closures. SwiftUI is a framework written in Swift, and its code reads much more clearly once the language is familiar.
Is Swift similar to Kotlin?
Quite similar in spirit. Both are modern, type-safe languages with null safety and concise syntax, and many concepts transfer, though their platforms and frameworks differ.
Explore more courses
More programming and tech courses
- Learn PHP
- Learn Ruby
- Learn R Programming
- Learn HTML and CSS
- Learn Git
- Learn Linux
- Learn Bash Scripting
- Learn Docker
See all programming and tech courses
Ready to learn Swift?
Start your free, personalized Swift course in seconds. .