Book Image

Learn SwiftUI

By : Chris Barker
Book Image

Learn SwiftUI

By: Chris Barker

Overview of this book

SwiftUI is the new and powerful interface toolkit that lets you design and build iOS, iPadOS, and macOS apps using declarative syntax. It is a powerful way to develop the UI elements of applications, which would normally be tightly coupled to application logic. Learn SwiftUI will get you up to speed with the framework and cross-device UI development in no time. Complete with detailed explanations and practical examples, this easy-to-follow guide will teach you the fundamentals of the SwiftUI toolkit. You'll learn how to build a powerful iOS and iPadOS application that can be reused for deployment on watchOS. As you progress, you'll delve into UI and unit testing in iOS apps, along with learning how to test your SwiftUI code for multiple devices. The book will also show you how to integrate SwiftUI features such as data binding and network requests into your current application logic. By the end of this book, you will have learned how to build a cross-device application using the SwiftUI framework and Swift programming.
Table of Contents (17 chapters)

To get the most out of this book

In order to follow and code along with this book, you will need to own an Apple Mac that is capable of running macOS Catalina or later.

All the sample code examples have been tested on macOS Catalina 10.15.1, running Xcode 11.3. An understanding of the Swift programming language would be advantageous but is not essential.

In order to get the latest version of macOS Catalina, or to see whether your hardware supports it, please visit https://support.apple.com/en-us/HT210222.

To obtain the latest version of Xcode, please visit the Mac App Store and search for Xcode or visit the store at https://apps.apple.com/us/app/xcode/id497799835.

If you are new to iOS and macOS development and want to learn more about the Swift programming language, either prior to or after reading this book, I highly recommend Mastering Swift 5 from Packt.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the Support tab.
  3. Click on Code Downloads.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Learn-SwiftUI. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Let's start by creating an instance of TableView in an empty ViewController."

A block of code is set as follows:

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int 

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

class ViewController: UIViewController {

var tableView: UITableView!

override func viewDidLoad() {

tableView = UITableView(frame: view.frame)
view.addSubview(tableView)

}

}

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select SwiftUI View from the User Interface options and then click Next."

Warnings or important notes appear like this.
Tips and tricks appear like this.