iOS & Swift

macOS by Tutorials

If you've always wanted to write your own native macOS apps, this is the book for you! Learn to build beautiful and functional native apps. By Sarah Reichelt.

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 (1) · 1 Review

Download materials
Buy paperback—Amazon Comments
Save for later
Share

Who is this for?

This book is for developers with some experience developing for iOS and who are familiar with Swift, Xcode and SwiftUI.

Covered concepts

  • Building windowed apps
  • Building menu bar apps
  • Building document-based apps
  • Enabling automation
  • Distributing macOS apps

macOS by Tutorials is a series of epic-length tutorials where you’ll learn to build four complete native macOS apps! Each app explores a different style of interface and takes you step-by-step from start to finish. By the end of the book, you’ll be experienced enough to turn your ideas into...

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: On This Day

Begin your journey developing for macOS by building a full-featured app using SwiftUI. The app, On This Day, accesses a public network API to collect information about events, births and deaths for a given date. Along the way, you’ll learn how to manage multiple windows, add menu and toolbar commands and choose multiple display options. You’ll experience first-hand the power of SwiftUI and see just how easy it is to build an app that has all of the look and feel you expect in a macOS app.

1
Toggle description
Starting with the source of the data, design the data models that will drive the SwiftUI user interface.
2
Toggle description
Create the main window to display the data models designed in the previous chapter. Style the events into a grid layout.
3
Toggle description
Add menus and menu items to the Mac menu bar and add a toolbar to your windows. Make the grid searchable and the toolbar customizable.
4
Toggle description
Add a table as a different way of displaying the data. Create a custom date picker to show events from other dates.
5
Toggle description
Now that the app is functionally complete, it's time to add the finishing touches: a Preferences window, an app icon and an About box.
6
Toggle description
Now that you've created your first native macOS app, what makes it better than the other possible technology choices? What are the alternatives?

Section II: Building a Menu Bar App

In this section, you’ll use AppKit to build a Pomodoro-style time tracking app that lives only in the macOS menu bar. Along the way, you’ll learn how to manage timers, update the menu in real-time, and integrate a SwiftUI view into an AppKit app. You’ll also learn about how macOS “sandboxes” apps to protect both them and the system itself.

Toggle description
Use AppKit to create an app that runs in the menu bar. Use a custom view to display menu items.
Control your menu bar app. Set up a timer to countdown the tasks. Update the menu bar and menu items as required. Interact with the user via alerts or notifications.
Toggle description
Learn how to save and load data files, use SwiftUI in an AppKit app and deal with the Mac sandbox.

Section III: Building a Document-based App

In this section, you’ll return to using SwiftUI and explore how to build a document-based app. You’ll create a Markdown editor — there can never be enough Markdown editors in the world! — that allows you to preview your text in real time. Along the way, you’ll add menu commands to change the styling of the preview and add formatting to your Markdown text.

Toggle description
Create a document-based app using SwiftUI. Use an AppKit view in a SwiftUI app. Learn about macOS file types while building a Markdown editor.
Toggle description
Add menu controls to your app. Some will adjust app-wide settings, others will focus on the active window. Open a secondary window from a menu item.

Section IV: Advanced Wizardry

Because macOS has its roots in Unix, it provides a vast array of command line tools which allow power users to perform tasks ranging from system management to image manipulation. In this section, you’ll learn how to build a graphical front-end for one such command: sips. Once you’ve built your sips GUI, you’ll enable automation to allow your new command to appear in the Services menu and Shortcuts app. When you complete this section, you, too, will be a wizard!

Toggle description
Learn about using Terminal to run commands. Use a Swift playground to explore using commands from within an app. Start using an image processing command.
Toggle description
Set up a SwiftUI app to act as a user interface to the sips Terminal commands. Use file handling and drag & drop to manage image files and folders.
Toggle description
Your app automates complex processes, but now you'll learn how to publish Services and Shortcut intents so other automations can access these parts of your app.

Section V: Distributing Your macOS Apps

Once you’ve written your app, you’ll want to distribute it to others so they can benefit from your creativity. On macOS, you have more distribution options than you do on iOS. In this section, you’ll explore the pros and cons of those options so you can choose which is best for you.

Toggle description
Now that you've built some apps, you want to distribute them. In this chapter, you'll learn how to upload, test and release through the Mac App Store.
Toggle description
You can also distribute your apps outside the Mac App Store. Bundle your app, get it notarized by Apple and package it for distribution.