At WWDC 2019, Apple released SwiftUI, a new declarative programming framework to replace UIKit. We immediately started exploring the framework, and we really enjoyed writing all kinds of apps in it, as you might have seen in our Swift Talk series about SwiftUI — in fact, we liked it so much that we knew we wanted to write a book about it.
However, it quickly became clear to us that SwiftUI was radically different from UIKit. And that meant we would have much more exploring and learning to do before we could begin to write an outline that went beyond basic examples.
After a few months spent delving into SwiftUI, we decided to write a short book: it’s called Thinking in SwiftUI. Since SwiftUI is still in its early days, the book focuses on the concepts behind the framework that we believe are essential to understand. It is not a reference for SwiftUI’s platform-specific APIs, but rather a guide to honing your intuition about how SwiftUI works.
We wrote Thinking in SwiftUI for developers who have both prior experience with Apple’s platforms and a good understanding of the Swift language. The book focuses on three major areas that you’ll have to rethink:
- View construction and view updates — These are very different from UIKit or AppKit due to SwiftUI’s declarative nature. Instead of modifying views, all view updates happen through state changes. There’s a single code path for both constructing and updating views.
- View layout — While views are often simple to lay out in SwiftUI, there are many parts you need to understand to build more complicated layouts. These include preferences, anchors, geometry readers, stacks, and overlays.
- Animations — Similarly to view updates, animations are triggered by state changes. We’ll show how to create both implicit and explicit animations and how to write custom animations that go beyond the built-in animations.
However, to really understand a framework, we believe you need to use it. So to give you hands-on experience, we have added exercises to each chapter. Once the book has been finalized, we will also offer accompanying videos in which we live code advanced layouts, custom animations, and the solutions to the exercises.
Thinking in SwiftUI is available as a prerelease today: we’ll publish a chapter each week, for a total of six weeks, before the final version of the book and the videos are released. If you buy the book during prerelease, you’ll get exclusive access to a weekly video Q&A during those six weeks, along with the chance to ask us questions directly.
Now, let’s start thinking in SwiftUI!