SwiftUI Cookbook – Second Edition

SwiftUI Cookbook - Second Edition

This is the code repository for SwiftUI Cookbook – Second Edition , published by Packt.

A guide to solving the most common problems and learning best practices while building SwiftUI apps

What is this book about?

SwiftUI provides an innovative and simple way to build beautiful user interfaces (UIs) for all Apple platforms, right from iOS and macOS through to watchOS and tvOS, using the Swift programming language. In this recipe-based cookbook, you’ll cover the foundations of SwiftUI as well as the new SwiftUI 3 features introduced in iOS 15 and explore a range of essential techniques and concepts that will help you through the development process.

This book covers the following exciting features:
Explore various layout presentations in SwiftUI such as HStack, VStack, LazyHStack, and LazyVGrid
Create widgets to quickly display relevant content at glance
Get up to speed with drawings in SwiftUI using built-in shapes, custom paths, and polygons
Discover modern animation and transition techniques in SwiftUI
Add user authentication using Firebase and Sign in with Apple
Manage concurrency with Combine and async/await in SwiftUI
Solve the most common SwiftUI problems, such as integrating a MapKit map, unit testing, snapshot testing, and previewing layouts

If you feel this book is for you, get your copy today!


Instructions and Navigations

All of the code is organized into folders. For example, Chapter01.

The code will look like the following:

struct ContentView: View {
@State var password = "1234"
@State var someText = "initial text"
var body: some View {

Following is what you need for this book:
This book is for mobile developers who want to learn SwiftUI as well as experienced iOS developers transitioning from UIkit to SwiftUI. The book assumes knowledge of the Swift programming language. Knowledge of object-oriented design and data structures will be useful but not necessary. You’ll also find this book to be a helpful resource if you’re looking for reference material regarding the implementation of various features in SwiftUI.

With the following software and hardware list you can run all code files present in the book (Chapter 1-15).

Software and Hardware List

Chapter Software required OS required
01-15 Xcode 13 Mac OS X

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.


  • Page 317 (Pragraph 3, line 8): @ObserveObject should be @ObservedObject
  • Page 304 (Pragraph 7, line 26): even it is should be even if it is
  • Page 80 (line 5): ‘ Text((result)).searchCompletion(result) should be Text((result)).searchCompletion(result)

Related products

Get to Know the Authors

Giordano Scalzo is a developer with 20 years of programming experience, since the days of ZX Spectrum. He has worked in Swift, Objective-C, C/C++, Java, .Net, Ruby, Python, and in a ton of other languages that he has forgotten the names of. After years of backend development, over the past 10 years, Giordano has developed extensively for iOS, releasing more than 20 apps—apps that he wrote for clients, enterprise applications, or on his own. He is currently a Tech Lead Consultant in London, where he leads mobile digital transformations through his company, Effective Code Ltd.

Edgar Nzokwe is a software engineer with 6+ years of experience building web and mobile applications. His areas of expertise include SwiftUI, UIKit, and Kotlin, Python, and a few Javascript frameworks. Edgar is dedicated to advancing the knowledge base of SwiftUI because he believes it empowers developers to design and build dazzling cross-platform apps with minimal development time.

Other books by the authors

Swift by Example

SwiftUI Cookbook

Hands-On Design Patterns with Swift

Swift: Developing iOS Applications


View Github