Escape from Tutorial Hell
by Sarah Reichelt
1st Edition, June 2025
Copyright © 2025 Sarah Reichelt.
Notice of Rights
All rights reserved. No part of this book or corresponding materials (such as text, images, or source code) may be reproduced or distributed by any means without prior written permission of the copyright owner.
Notice of Liability
This book and all corresponding materials (such as source code) are provided on an “as is” basis, without warranty of any kind, express of implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the author or copyright holder be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of other dealing in the software.
Trademarks
All trademarks and registered trademarks appearing in this book are the property of their own respective owners.
License
By purchasing Escape from Tutorial Hell, you have the following license:
-
You are allowed to use and/or modify the source code in Escape from Tutorial Hell in as many apps as you want, with no attribution required.
-
You are allowed to use and/or modify all art, images, and designs that are included in Escape from Tutorial Hell in as many apps as you want, but must include this attribution line somewhere inside your app: "Artwork/images/designs: from Escape from Tutorial Hell".
-
The source code included in Escape from Tutorial Hell is for your personal use only. You are NOT allowed to distribute or sell the source code in Escape from Tutorial Hell without prior authorization.
-
This book is for your personal use only. You are NOT allowed to sell this book without prior authorization, or distribute it to friends, coworkers or students; they would need to purchase their own copies.
All materials provided with this book are provided on an “as is” basis, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
All trademarks and registered trademarks appearing in this guide are the properties of their respective owners.
Preface
Welcome to the first edition of Escape from Tutorial Hell.
When learning to code, everyone hits a block at a certain point. You’ve read books and articles, watched videos, done tutorials and courses. You feel like you know what’s being taught — the code is familiar and you can write small functions when told what the functions should do, but now what? How do you take that knowledge and use it to write a complete app? You’re stuck in tutorial hell so how do you escape?
This book aims to fill in that gap and take you from a person who knows the basics of Swift and SwiftUI to a developer with an app that’s ready to ship.
You do need to have that basic knowledge first. I’ll explain some code, but I’ll ask you to write some of it on your own, and I won’t always explain every line. This book is more about building an app than it is about learning to code.
I’m primarily a Mac developer, so the app we’ll build together in this book is a Mac app but the concepts and techniques I use are applicable to any Apple platform.
Every project in this book has been tested with macOS Sequoia and Xcode 16 using Swift 5.10. The Swift team released Swift 6 in 2024. The main focus of this update is strict concurrency checking, which can lead to some interesting errors and warnings. Since the default for new Xcode projects is still Swift 5, I have decided not to switch to Swift 6 yet. I think that the team needs more time to improve this and make it usable.
I hope you enjoy this first edition of Escape from Tutorial Hell.
About the Author
I got hooked onto trying to make computers do what I told them a very long time ago and have never stopped loving it. I’m a keen evangelist for developing native Mac apps. When not at my computer, I love coffee, puzzles, reading and cooking — the day hasn’t started until the first cup of coffee is drunk and the crossword is done! — Sarah
About the Language Engineer (Editor)
I’m a fan of words and the things you can do with them, and I’ve spent a decade floating between different forms of writing — academic, fiction, technical. I hope that in this book I’ve succeeded at easing the passage of ideas between Sarah’s brain and your own, and I ask only that you blame me for any typos, stray capitals, Australianisms, and unoxfordenised commas that have made it into the final manuscript. — Peter
Dedication
To Jack who persists in trying to teach his mother some computer science and to Jerry who was here at the start of this book but couldn’t make it to the end.
Introduction
Most books, articles, and tutorials issue a lot of orders: create this project, add that file, insert some properties, write some code. Usually, only the write some code section is explained in any detail, and even then, the explanations tend to be focussed on the details of the programming language. I know, because I’ve written those sorts of books and articles myself.
But knowing the nuts and bolts of programming doesn’t make you an app developer and this is why many learners get stuck in tutorial hell. They can understand the code snippets that have been taught and they can write functions to perform specific tasks, but there is a crucial gap.
It isn’t easy to sit down at your computer and create an app from scratch. There are a lot of decisions to make before you can start coding:
-
What app should I build?
-
What platform am I building for?
-
What frameworks and libraries should I use?
Once you start writing the code, there are even more decisions:
-
What do I write first — data or user interface?
-
How should I structure my data?
-
How should I lay out my code files?
-
What goes where in my project?
In this book, I am not going to concentrate on the code itself — there are lots of other resources for that, including my other books. Instead, I’m going to show you how to take an app from the original idea, through development and on to distribution.
First, you’ll configure Xcode so as to maximize your productivity and improve your workflow.
Then you’ll see how to design an app, before using various resources to learn how to code it.
Next you’ll look at ways to use Xcode more efficiently, we’ll discuss coding with AI, and finally, you’ll learn how to distribute your apps.
It is a very opinionated book - I’m going to teach you how I do things. Once you learn how I operate when creating or modifying an app, you’ll have the tools and knowledge to adapt those lessons to create your own style. But you’ll have escaped from tutorial hell and you’ll have the confidence to start writing your own apps.
What you need
To follow along with this book, you’ll need the following:
-
A Mac computer with an Intel or M series processor, running macOS 15 or later. Any Mac that you’ve bought in the last few years will do, even a Mac mini or MacBook Air.
-
Xcode 16 or later. Xcode is the main development environment for building macOS Apps. It includes the Swift compiler, the debugger and other development tools you’ll need. You can download the latest version of Xcode for free from the Mac App Store. Note: Xcode 16.3 has a bug that crashes any playground using JSON. You must use another version of Xcode 16 when running the playgrounds in this book.
-
A basic understanding of Swift and SwiftUI. If you’re new to Swift, you might want to read my macOS Apprentice book first: https://www.kodeco.com/books/macos-apprentice
Where to download the materials for this book
The source code for this book can be downloaded from the GitHub repository:
Click the link to open it in your browser. You’ll see a big green Code button. Click on that and on Download ZIP. This puts all the code files in your Downloads folder. Please download instead of cloning as this gives you a clean set of files, without my source control.
Depending on your browser settings, you may need to double-click the ZIP file to expand it. That gives you a folder containing one sub-folder for each chapter. The text of each chapter tells you when you need to use any of these files or folders, but every chapter that involves coding has a final folder showing the end result of working through that chapter.
How to read this book
Each section is designed to cover a particular aspect of development but they can each be read independently.
When you get to the code blocks, if the code is unfamiliar to you, then I strongly recommend that you type it in for yourself, rather than copy and paste it. Xcode’s auto-suggestions will help you, and having to get every detail correct will embed the new knowledge in your brain in a way that reading it can’t.
As you read, you’ll find boxes like this one where I ask you to perform a programming task. Please give it your best shot before looking up my solution. Writing code yourself is the only real way to learn. After trying, your code may be very different to mine - that’s fine! Test it. If it works, use your version. Coding is like any form of writing - everyone has their own style and while you can learn from others, you’ll never write exactly the way they do, but that doesn’t make either version wrong.
The downloaded material contains a folder for every chapter. For chapters that deal with coding or that have a task for you, the final folder will contain my solutions.
If you are using copy and paste for any of the code blocks, then go to Xcode’s Settings and in Text Editing → Indentation, turn on Re-Indent on paste. This will solve a lot of issues with the format of the text in the book differing from Xcode’s format.
This book is available as HTML, PDF or ePub. I recommend reading this book from the HTML version. It has good light and dark variations and the most accurate formatting. Also, the code blocks have a COPY button for when you want it, and there are no issues with pagination. My next favorite is PDF — use the light or dark version to suit your preference. If you’re reading either PDF, I suggest you use Preview or Firefox. Do not use Adobe Reader or Acrobat as they are unable to fully read the embedded fonts so will miss out some characters. My least favorite reading option is the ePub, as its display depends greatly on your ePub reader.
If you find any errors or typos, please report them to me at [email protected]. For problems with the code, please open an issue at https://github.com/trozware/escape_book_code/issues.
Section I: Configuring Your Tools
Before you can start any development work, you need to configure the tools and make sure that you are familiar with the important parts of these tools. When developing apps for any Apple platform, your main tool will be Xcode.
If you’ve learned any Swift you’ll have Xcode installed already, but in Chapter 1 I’ll take you through how I like to set it up.
The other important tool you’ll need is source control. Chapter 2 shows you how to use GitHub from within Xcode.
Chapter 1: Setting up Your Coding Environment
I assume you’ve done some coding tutorials or courses and have a basic understanding of Swift, SwiftUI and Xcode. It doesn’t matter if your knowledge is iOS-based - I’ll take you through the process of making an app more Mac-like in a later chapter.
In this chapter, you’ll configure your main Xcode window and some of Xcode’s many options. You’ll set it up to make your workflow more efficient and productive, and you’ll learn some important keyboard shortcuts. As an added bonus, you’ll find out how you can personalize the header at the top of every Swift file.
Xcode is the primary tool used for Apple development. It has a lot of view options, configuration options, and keyboard shortcuts, but don’t stress — you don’t have to learn them all.
Creating a Sample Project
I assume you have Xcode installed already, but if not, download it from the Mac App Store. When it runs for the first time, you only need the macOS components which are installed by default. Get the Predictive Code Completion Model too, if it’s offered to you.
Launch Xcode and create a new project using the macOS App template. Set the options for your project like this:
- Product Name
-
When choosing a name, always keep it simple with no spaces or non-standard characters - underscores or dashes are fine. You can change the display name of your app later, but keeping the project name plain makes some things easier in Xcode. In this case, use Xcode_Config as this project is for configuring Xcode and seeing the effects.
- Team
-
If you haven’t added an Apple ID to Xcode yet, Team shows an Add Account… button. I reset Xcode to start as if it was a fresh install, so that’s what I see now. If you’ve already added an Apple ID, leave Team set to None.
- Organization Identifier
-
You must enter an Organization Identifier. Every app has a bundle identifier, and when publishing in the App Store this must be unique. The conventional format is to use your domain name reversed as the organization identifier. Xcode uses this to create the bundle identifier by appending the product name.
For example, my domain name is troz.net, so I reverse that and enter net.troz into the Organization Identifier. Xcode then appends the product name to give a bundle identifier of net.troz.Xcode-Config. I’m not sure why it replaces my underscore with a hyphen, but that makes Xcode and the App Store happy :-)
If you own a domain name, use it here. If you don’t, you can make one up e.g. my.org. The domain does not have to exist.
For the rest of this dialog, set the following:
-
Interface: SwiftUI
-
Language: Swift
-
Testing System: None
-
Storage: None
Click Next and you get to decide where to save your project.
I like to use a folder called Developer in my user folder. Finder gives it a neat hammer icon and it’s a logical place to store your development work.
If you don’t have a Developer folder, navigate to your user folder and click New Folder to create it. Unselect Create Git repository on my Mac and click Create to create and save your project files.
Xcode opens with the default view for a new project:
As Xcode prepares the preview, you may see a message like this:
This is because you haven’t assigned a team yet, so click Open Anyway whenever you see this. You’ll fix it in a minute.
|
Tip
|
In Finder, locate your Developer folder and drag it into your Finder window sidebar for easy access in the future. |
Setting Up the Main Window
The first thing to do now is to make this window as large as possible. Full screen mode makes the menus harder to see and access, so I prefer to maximize the window instead. Mouse over the green blob at the top left of the window, and when the window resizing popup appears, choose the first Fill option to expand the window as much as possible. If you have a very wide screen, you may prefer to shrink the width, but keep the height as large as you can.
|
Note
|
I’ll be showing smaller windows in my screenshots for ease of reading, but I always work in a large window. |
Now that the main project window is large, you can make some more changes to increase your working space even more.
First, turn off the minimap. This is the view beside the code pane that shows a miniaturized version of your code for navigation purposes. It’s a neat implementation that shows more detail as you mouse over it, but in my opinion, if a file is long enough to make this valuable, then it’s too long and should be split into multiple files.
Go to Editor → Minimap and toggle this off.
The next thing to hide is the sidebar on the right. If you’re editing an AppKit or UIKit storyboard, then it’s important, but you don’t need it for anything else - its space is more valuable.
Click the Hide or Show the Inspectors toggle at the top right corner of the window, or press Option-Command-Zero to hide it.
Now you’ve got a large window with three vertical panes:
-
The navigators
-
The code editor
-
The SwiftUI preview
One final tweak before leaving this section. In the top toolbar, you may see a cloud icon with a blue dot. This is an Apple advertisement for Xcode Cloud. To get rid of it, click the cloud icon and then click Dismiss:
It keeps popping back, but this is how you can get rid of it, temporarily at least.
Now your project window looks like this: