
The Hacking with macOS tutorial series is designed to make it easy for beginners to get started coding for macOS using the Swift programming language.
For the most part that means we’ll be using SwiftUI, but building for macOS is more than about just traditional SwiftUI apps with windows and lists – we’ll also be building a command-line app using Swift Package Manager, a menu bar app that blends AppKit and SwiftUI, and even a few games built with SpriteKit.
The goal of this book is to help teach you everything you need to know to build great macOS apps, rather than just trying to teach you a specialized subset of SwiftUI. After all, macOS is a powerful, customizable operating system in its own right, and if you want to build software that truly feels at home on the Mac – apps and games that feel Mac-first rather than Mac-ported – it’s important you focus on all the amazing things that make the Mac unique.
My teaching method is designed to be extremely hands-on, which means nearly everything you learn from me will have a direct, practical application to something we're working on. That way, your brain can see exactly why a certain technique is helpful and you can start using it straight away.
This book has been written on the back of my personal motto: "Programming is an art. Don't spend all your time sharpening your pencil when you should be drawing." We'll be doing some "sharpening" but a heck of a lot more "drawing" – if that doesn't suit your way of learning, you should exit now.
Tip: If you’re wondering whether you should follow this newer edition of the book or the original AppKit edition, let me make that decision for you: you should learn SwiftUI. Although there are some places in this book where we have no choice but to dip down into AppKit, for the most part you can more or less forget that AppKit exists and be a great deal happier for it.
The series is crafted around a few basic tenets, and it's important you understand them before continuing:
You'd be surprised by how many people think the path to success is through reading books, attending classes or, well, doing pretty much anything except sitting down in front of a computer and typing. Not me. I believe the best way to learn something is to try to do it yourself and see how it goes.
Sure, going to classes might re-enforce what you've learned, or it might teach you some time-saving techniques, but ultimately I've met too many people with computing degrees who stumble when asked to write simple programs. Don't believe me? Try doing a Google search for "fizz buzz test", and you'll be surprised too.
So, dive in, make things, and please have fun – if you're not enjoying yourself, Swift coding probably isn't for you.
If you spot any errors in this book, either typos or technical mistakes, please do let me know so I can correct them as soon as possible. The best way to get in touch is on Twitter @twostraws, but you can also email paul@hackingwithswift.com.
I'm not going to talk much, because I want to get straight into coding. However, there are some points you do need to know:
Important note: if any bugs are found in the project files, or if Swift updates come out that force syntax changes, I'm going to be updating this book as needed. You should follow me on Twitter @twostraws if you want to be notified of updates.
I'm also happy to answer questions on Twitter if you encounter problems, so please feel free to get in touch!
Swift, the Swift logo, Xcode, Instruments, Cocoa Touch, Touch ID, AirDrop, iBeacon, iMessage, iPhone, iPad, Safari, App Store, Mac, and macOS are trademarks of Apple Inc., registered in the U.S. and other countries.
Hacking with macOS is copyright Paul Hudson. 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.
All the source code for the projects in this book is available on GitHub here: https://github.com/twostraws/macos.
All artwork and audio for projects included with this book is licensed under the public domain, meaning you can re-use it however you want. The only exception is the iPhone picture used in project 13, which is, somewhat predictably, owned by Apple.
A lot of the game artwork came from the Kenney Game Assets pack. The artwork is available under the public domain, but you might want to consider buying the rest of the pack because it includes a huge amount of content for only a few bucks.
You can buy Swift tutorials from anywhere, but I'm pleased, proud, and very grateful that you chose mine. I want to say thank you, and the best way I have of doing that is by giving you bonus content above and beyond what you paid for – you deserve it!
Every book contains a word that unlocks bonus content for Frequent Flyer Club members. The word for this book is FORGE. Enter that word, along with words from any other Hacking with Swift books, here: https://www.hackingwithswift.com/frequent-flyer
When you buy your books from Hacking with Swift, you get Swift updates for free. You can read the full version of my update policy at https://www.hackingwithswift.com/update-policy, but the abridged version is this: whenever I release to the public an updated book or video to reflect these changes, all existing buyers will get that update free.
This edition has the version 2025-06-24.
This book is dedicated to my brother Andrew, who has always given me someone to look up to.
SwiftUI apps for iOS and macOS have vast swathes of things in common, but there are also many things that set them apart – learning to recognize those distinctly “Mac” features is part of the process of building high-quality macOS apps.
Here’s the least you need to know:
Copyright © 2023 Paul Hudson, hackingwithswift.com.
You should follow me on Twitter.