iOS & Swift

SwiftUI Apprentice

If you're new to iOS programming, this is the book for you! Learn to build beautiful, fully-functional apps using Apple’s hottest user interface technology: SwiftUI! By Caroline Begbie & Audrey Tam.

Read for Free with the Personal Plan* * Includes this and all other books in our online library See all benefits
Buy Individually $59.99* *Includes access to all of our online reading features.

5 (2) · 1 Review

Download materials
Buy paperback—Amazon Comments
Save for later
Share

Who is this for?

This book is for developers who are new to iOS and to SwiftUI.

Covered concepts

  • Using Xcode
  • Coding in Swift
  • Designing and developing user interfaces with SwiftUI
  • Modeling and persisting data
  • Accessing remote APIs
  • iPad development

SwiftUI Apprentice is a series of epic-length tutorials where you’ll learn to build three complete apps from scratch, using Apple’s new user interface technology: SwiftUI! Each app is more advanced than the one before, and together, they cover everything to make your own apps using SwiftUI. By the end of...

more

Before You Begin

This section tells you a few things you need to know before you get started, such as what you’ll need for hardware and software, where to find the project files for this book, and more.

Section I: Your first app: HIITFit

At WWDC 2019, Apple surprised and delighted the developer community with the introduction of SwiftUI, a declarative way of building user interfaces. With SwiftUI, you build your user interface by combining fundamental components such as colors, buttons, text labels, lists and more into beautiful and functional views. Your views react to changes in the data they display, updating automatically without any intervention from you!

In this section, you’ll begin your journey to becoming a SwiftUI developer by developing an app called HIITFit, a High Intensity Interval Training Fitness tracker. Along the way, you’ll:

  • Learn how to use Xcode.
  • Discover how to plan and prototype an app.
  • Explore the basic components of SwiftUI.
  • Understand how data moves in a SwiftUI app and how to make it persist.
  • Learn fundamental concepts of Swift, the programming language, needed to build your app.
1
Toggle description
Check your tools are working so nothing slows you down when you dive into this book. Install Xcode and create a new project to take a quick tour of Xcode and Swift basics. You’ll learn some tips for using Xcode efficiently.
2
Toggle description
Plan your app by listing what the user will see and what the app will do. Start learning how to use Xcode, Swift and SwiftUI as you setup a paging tab view.
3
Toggle description
Learn a lot more about Xcode, Swift and SwiftUI while you create subviews to build the most complex view of your app.
4
Toggle description
Learn how to use Date, Form, ZStack and Button to lay out the other full-screen views of your app.
5
Toggle description
Organize your app’s data with structures and enumerations. Store your development code and data to exclude them from your app’s release version. Localize your app to extend its audience.
6
Toggle description
In this chapter, you use @State, @Binding and @Environment properties to implement navigation features, set ratings and show and hide modal sheets and subviews.
7
Toggle description
In this chapter, you’ll replace the prototype exercise timer with a Timer publisher and log the user’s activity in an @EnvironmentObject.
8
Toggle description
Learn to use @AppStorage and @SceneStorage to save your app state. You'll also learn your app's sandbox file system and how to enable multiple windows on iPadOS.
9
Toggle description
Learn about closures, Swift error handling, closures and property list serialization on your way to saving and restoring HIITFit's history data.
10
Toggle description
Make your app pop visually by styling the user interface to match the vision of a professional designer.
11
Toggle description
Learn about the ways SwiftUI manages data through your view hierarchy. Discover how to answer the question "struct or class"? Explore the natural architecture pattern for SwiftUI apps: Model-View-ViewModel (MVVM).
12
Toggle description
Get a bird’s eye view of the whole Apple app development ecosystem with a brief history of SwiftUI, a summary of Apple Developer resources and tips on housekeeping and trouble-shooting.

Section II: Your second app: Cards

Now that you’ve completed your first app, it’s time to apply your knowledge and build a new app from scratch. In this section, you’ll build a photo collage app called Cards and you’ll start from a blank template. Along the way, you’ll:

  • Dive more deeply into Swift’s ways of representing data.
  • Learn how to support user gestures.
  • Discover how Xcode and iOS manage app assets such as images and colors.
  • Learn to use UIKit components in your SwiftUI app.
  • Explore more robust ways of saving and restoring data.
  • Translate a designer’s vision into reality in your app.
Toggle description
Begin work on your second app. You’ll start with an initial idea and a blank slate in Xcode. From there, you’ll build a basic view and a toolbar.
Toggle description
Learn how to use gestures and build a resizable view, convert it to a view modifier and apply it other views in your design.
Toggle description
Learn how to build a data model for your app. Create a single source of truth and implement the necessary steps to Read, Update and Delete data from the model.
Toggle description
Learn to add assets of all varieties — icons, images, colors — to your app. Along the way, you’ll learn how to adjust these assets for different traits such as device size and dark mode. Finally, learn to load assets lazily to keep your app responsive.
Toggle description
Learn to add UIKit views and view controllers to your SwiftUI app. Make the integration even tighter by implementing drag-and-drop into your SwiftUI view.
Toggle description
Learn to draw shapes and use them as clipping masks to frame the pictures in your Cards app.
Toggle description
Learn to save and restore your card compositions. Along the way, you’ll discover Swift’s powerful `Codable` facility and learn to save arbitrary data types.
Toggle description
Change your user interface to match your designer’s vision. Go beyond the basics and learn more advanced SwiftUI layout techniques.
Toggle description
Make your app sparkle by adding animations, view transitions, a share sheet and more!

Section III: Your third app: RWFreeView

You’ve now built two apps with beautiful user interfaces. But, you’re probably wondering how to build an app that accesses resources on the internet. Fear not! In this section, you’ll build RWFreeView, an app that allows you to view all the free video episodes on raywenderlich.com. Along the way, you’ll:

  • Learn how to build lists of information and navigate between views using SwiftUI.
  • Discover the intricacies of REST APIs and how to use them.
  • Explore iOS’s networking support using a Swift Playground.
  • Learn to how add support for iOS Widgets to your app.
Toggle description
Use the SwiftUI List view to present a collection of items in a view that scrolls vertically. Manage a navigation stack in your app’s navigation hierarchy with NavigationView.
Toggle description
Learn about HTTP requests and responses by using RESTed and raywenderlich.docs.apiary.io to explore the raywenderlich.com API with some help from the GitHub API.
Toggle description
Use URLComponents to create a query URL and send it in a URLSession dataTask. Learn how to decode nested JSON values into your app’s data model, flattening the JSON response and using date formatters to convert date strings.
Toggle description
Copy and adapt the previous chapter’s playground code into your app, then implement all the query filters and options. Set a breakpoint to inspect the decoded network response. Look for opportunities to improve your users’ experience.
Toggle description
Add a widget to your app. The widget can run its own networking tasks or you can create an app group to share your app’s data with your widget.