Chapters

Hide chapters

macOS Apprentice

First Edition · macOS 13 · Swift 5.7 · Xcode 14.2

Section II: Building With SwiftUI

Section 2: 6 chapters
Show chapters Hide chapters

Section III: Building With AppKit

Section 3: 6 chapters
Show chapters Hide chapters

Writing software is fun!

Using a computer is great but nothing beats the satisfaction of writing your own code. It doesn’t have to be a super-complex app — maybe you’d like to write a script for processing some text or a utility that automates part of your workflow. Perhaps you have an idea for a game you’d like to create. But how do you get started?

If you’re an Apple user, you begin by learning the Swift language. There are a lot of resources for this and they nearly all assume that you want to write apps for an iPhone. But the main tool for writing Swift is Xcode and it runs on your Mac, so why not write apps that run on the same device?

The Mac is more powerful, more flexible and less restricted than any other Apple device, so learn to code by writing for it. It’s a terrific feeling when code that you wrote is running on your own computer.

How to Read This Book

This book is split into four sections.

The first section is designed to get you started using Xcode and programming in Swift. If you’re already comfortable with these tools, you may skip right to one of the other sections.

The chapters in sections two and three are designed to take you from start to finish building a particular kind of app. While the book is fun from the first page to the last, if one section especially piques your interest, you’re free to dive right in there.

The final section ties together all you’ve learned in the rest of the book and puts the finishing touches on both sample apps.

Section I: Getting Started

This section shows you how to install Xcode and teaches you the basics of programming in Swift. Along the way, you’ll learn several different ways to execute Swift code.

Section II: Building With SwiftUI

In this section, you’ll use Apple’s newest user interface technology — SwiftUI — to develop a word-guessing game called Snowman. You’ll learn about data flow in SwiftUI, managing multiple windows, using charts and adding macOS-specific features such as toolbars and menus.

Section III: Building With AppKit

From the very beginning of macOS X, AppKit has been the workhorse behind the user interface of all apps and there are still a number of tasks where it is the superior choice. In this section, you’ll explore such an area while building an app to browse movie data from IMDb, the online movie database.

Section IV: Combining SwiftUI & AppKit

Apple has made it simple to include pieces of both user interface frameworks in a single app. In this section, you’ll do just that in order to add some finishing touches to both of the apps from the previous sections.

Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum here.
© 2024 Kodeco Inc.