Ultimate Catalyst Guide

How do I implement preferences on macOS?

released Fri, 05 Jul 2019
Swift Version 5.1

In order to implement the preferences or your app, Apple supports the Settings.bundle technology that has been there since iOS 2.0 (or rather, iPhoneOS 2.0). The documentation is actually so old, that it is archived and the documentation screenshots look like this:

On iOS, this means that you just need to add a new bundle target to your project and fill it with a collection of specially crafted Plist files. These settings then appear in the general iOS settings and any changes done there are stored in the NSUserDefaults.

If your app supports settings bundles, then your Catalyst app will automatically add a Preferences window to your app that looks something like this:

For details on how to achieve this, refer to Apples documentation.

Now, if you have more involved logic in your settings, special view controllers, web views, and other things, then this doesn't work well for you. In that case, you can read here how to implement more complex preferences on macOS.

Preferences with a Toolbar

Now, one thing you might wonder is how to get this wonderful Preferences Toolbar, that Apple has in their Podcast app (see the last screenshot). As it turns out, this is currently completely undocumented, and we're explaining the details of how to achieve this here.