Preferences alternatives and similar libraries
Based on the "UI" category.
Alternatively, view Preferences alternatives based on common mentions on social networks and blogs.
-
Animated Tab Bar
:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion -
JTAppleCalendar
The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable -
FSPagerView
FSPagerView is an elegant Screen Slide Library. It is extremely helpful for making Banner View、Product Show、Welcome/Guide Pages、Screen/ViewController Sliders. -
Alerts Pickers
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date... -
SideMenu
Simple side/slide menu control for iOS, no code necessary! Lots of customization. Add it to your project in 5 minutes or less. -
Pagemenu
A paging menu controller built from other view controllers placed inside a scroll view (like Spotify, Windows Phone, Instagram) -
SwiftEntryKit
SwiftEntryKit is a presentation library for iOS. It can be used to easily display overlays within your iOS apps. -
SwipeCellKit
Swipeable UITableViewCell/UICollectionViewCell based on the stock Mail.app, implemented in Swift. -
Scrollable-GraphView
An adaptive scrollable graph view for iOS to visualise simple discrete datasets. Written in Swift. -
ESTabBarController
:octocat: ESTabBarController is a Swift model for customize UI, badge and adding animation to tabbar items. Support lottie! -
Material Components for iOS
[In maintenance mode] Modular and customizable Material Design UI components for iOS -
NotificationBanner
The easiest way to display highly customizable in app notification banners in iOS -
ActiveLabel
UILabel drop-in replacement supporting Hashtags (#), Mentions (@) and URLs (http://) written in Swift -
SlideMenuControllerSwift
iOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift. -
PopupDialog
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style. -
TLYShyNavBar
DISCONTINUED. Unlike all those arrogant UINavigationBar, this one is shy and humble! Easily create auto-scrolling navigation bars! -
StarWars.iOS
This component implements transition animation to crumble view-controller into tiny pieces. -
KMNavigationBarTransition
A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically. -
Whisper
:mega: Whisper is a component that will make the task of display messages and in-app notifications simple. It has three different views inside -
PaperOnboarding
:octocat: PaperOnboarding is a material design UI slider. Swift UI library by @Ramotion -
CircleMenu
:octocat: ⭕️ CircleMenu is a simple, elegant UI menu with a circular layout and material design animations. Swift UI library made by @Ramotion -
RazzleDazzle
A simple keyframe-based animation framework for iOS, written in Swift. Perfect for scrolling app intros.
CodeRabbit: AI Code Reviews for Developers

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Preferences or a related project?
README
Preferences
Add a settings window to your macOS app in minutes
Just pass in some view controllers and this package will take care of the rest. Built-in SwiftUI support.
This package is compatible with macOS 13 and automatically uses Settings
instead of Preferences
in the window title on macOS 13 and later.
Requirements
macOS 10.13 and later.
Install
Add https://github.com/sindresorhus/Preferences
in the “Swift Package Manager” tab in Xcode.
Usage
Run the Example
Xcode project to try a live example (requires macOS 11 or later).
First, create some settings pane identifiers:
import Preferences
extension Settings.PaneIdentifier {
static let general = Self("general")
static let advanced = Self("advanced")
}
Second, create a couple of view controllers for the settings panes you want. The only difference from implementing a normal view controller is that you have to add the SettingsPane
protocol and implement the preferencePaneIdentifier
, toolbarItemTitle
, and toolbarItemIcon
properties, as shown below. You can leave out toolbarItemIcon
if you're using the .segmentedControl
style.
GeneralSettingsViewController.swift
import Cocoa
import Preferences
final class GeneralSettingsViewController: NSViewController, SettingsPane {
let preferencePaneIdentifier = Settings.PaneIdentifier.general
let preferencePaneTitle = "General"
let toolbarItemIcon = NSImage(systemSymbolName: "gearshape", accessibilityDescription: "General settings")!
override var nibName: NSNib.Name? { "GeneralSettingsViewController" }
override func viewDidLoad() {
super.viewDidLoad()
// Setup stuff here
}
}
Note: If you need to support macOS versions older than macOS 11, you have to add a fallback for the toolbarItemIcon
.
AdvancedSettingsViewController.swift
import Cocoa
import Preferences
final class AdvancedSettingsViewController: NSViewController, SettingsPane {
let preferencePaneIdentifier = Settings.PaneIdentifier.advanced
let preferencePaneTitle = "Advanced"
let toolbarItemIcon = NSImage(systemSymbolName: "gearshape.2", accessibilityDescription: "Advanced settings")!
override var nibName: NSNib.Name? { "AdvancedSettingsViewController" }
override func viewDidLoad() {
super.viewDidLoad()
// Setup stuff here
}
}
If you need to respond actions indirectly, the settings window controller will forward responder chain actions to the active pane if it responds to that selector.
final class AdvancedSettingsViewController: NSViewController, SettingsPane {
@IBOutlet private var fontLabel: NSTextField!
private var selectedFont = NSFont.systemFont(ofSize: 14)
@IBAction private func changeFont(_ sender: NSFontManager) {
font = sender.convert(font)
}
}
In the AppDelegate
, initialize a new SettingsWindowController
and pass it the view controllers. Then add an action outlet for the Settings…
menu item to show the settings window.
AppDelegate.swift
import Cocoa
import Preferences
@main
final class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet private var window: NSWindow!
private lazy var settingsWindowController = SettingsWindowController(
preferencePanes: [
GeneralSettingsViewController(),
AdvancedSettingsViewController()
]
)
func applicationDidFinishLaunching(_ notification: Notification) {}
@IBAction
func settingsMenuItemActionHandler(_ sender: NSMenuItem) {
settingsWindowController.show()
}
}
Settings Tab Styles
When you create the SettingsWindowController
, you can choose between the NSToolbarItem
-based style (default) and the NSSegmentedControl
:
// …
private lazy var settingsWindowController = SettingsWindowController(
preferencePanes: [
GeneralSettingsViewController(),
AdvancedSettingsViewController()
],
style: .segmentedControl
)
// …
.toolbarItem
style:
[NSToolbarItem based (default)](toolbar-item.png)
.segmentedControl
style:
[NSSegmentedControl based](segmented-control.png)
API
public enum Settings {}
extension Settings {
public enum Style {
case toolbarItems
case segmentedControl
}
}
public protocol SettingsPane: NSViewController {
var preferencePaneIdentifier: Settings.PaneIdentifier { get }
var preferencePaneTitle: String { get }
var toolbarItemIcon: NSImage { get } // Not required when using the .`segmentedControl` style
}
public final class SettingsWindowController: NSWindowController {
init(
preferencePanes: [SettingsPane],
style: Settings.Style = .toolbarItems,
animated: Bool = true,
hidesToolbarForSingleItem: Bool = true
)
init(
panes: [SettingsPaneConvertible],
style: Settings.Style = .toolbarItems,
animated: Bool = true,
hidesToolbarForSingleItem: Bool = true
)
func show(preferencePane: Settings.PaneIdentifier? = nil)
}
As with any NSWindowController
, call NSWindowController#close()
to close the settings window.
Recommendation
The easiest way to create the user interface within each pane is to use a NSGridView
in Interface Builder. See the example project in this repo for a demo.
SwiftUI support
If your deployment target is macOS 10.15 or later, you can use the bundled SwiftUI components to create panes. Create a Settings.Pane
(instead of SettingsPane
when using AppKit) using your custom view and necessary toolbar information.
Run the Example
target in the Xcode project in this repo to see a real-world example. The Accounts
tab is in SwiftUI.
There are also some bundled convenience SwiftUI components, like [Settings.Container
](./Sources/Preferences/Container.swift) and [Settings.Section
](./Sources/Preferences/Section.swift) to automatically achieve similar alignment to AppKit's NSGridView
. And also a .preferenceDescription()
view modifier to style text as a setting description.
Tip: The Defaults
package makes it very easy to persist the settings.
struct CustomPane: View {
var body: some View {
Settings.Container(contentWidth: 450.0) {
Settings.Section(title: "Section Title") {
// Some view.
}
Settings.Section(label: {
// Custom label aligned on the right side.
}) {
// Some view.
}
…
}
}
}
Then in the AppDelegate
, initialize a new SettingsWindowController
and pass it the pane views.
// …
private lazy var settingsWindowController = SettingsWindowController(
panes: [
Pane(
identifier: …,
title: …,
toolbarIcon: NSImage(…)
) {
CustomPane()
},
Pane(
identifier: …,
title: …,
toolbarIcon: NSImage(…)
) {
AnotherCustomPane()
}
]
)
// …
If you want to use SwiftUI panes alongside standard AppKit NSViewController
's, instead wrap the pane views into Settings.PaneHostingController
and pass them to SettingsWindowController
as you would with standard panes.
let CustomViewSettingsPaneViewController: () -> SettingsPane = {
let paneView = Settings.Pane(
identifier: …,
title: …,
toolbarIcon: NSImage(…)
) {
// Your custom view (and modifiers if needed).
CustomPane()
// .environmentObject(someSettingsManager)
}
return Settings.PaneHostingController(paneView: paneView)
}
// …
private lazy var settingsWindowController = SettingsWindowController(
preferencePanes: [
GeneralSettingsViewController(),
AdvancedSettingsViewController(),
CustomViewSettingsPaneViewController()
],
style: .segmentedControl
)
// …
[Full example here.](Example/AccountsScreen.swift).
Backwards compatibility
macOS 11 and later supports SF Symbols which can be conveniently used for the toolbar icons. If you need to support older macOS versions, you have to add a fallback. Apple recommends using the same icons even for older systems. The best way to achieve this is to export the relevant SF Symbols icons to images and add them to your Asset Catalog.
Known issues
The settings window doesn't show
This can happen when you are not using auto-layout or have not set a size for the view controller. You can fix this by either using auto-layout or setting an explicit size, for example, preferredContentSize
in viewDidLoad()
. We intend to fix this.
There are no animations on macOS 10.13 and earlier
The animated
parameter of SettingsWindowController.init
has no effect on macOS 10.13 or earlier as those versions don't support NSViewController.TransitionOptions.crossfade
.
FAQ
How can I localize the window title?
The SettingsWindowController
adheres to the macOS Human Interface Guidelines and uses this set of rules to determine the window title:
- Multiple settings panes: Uses the currently selected
preferencePaneTitle
as the window title. Localize yourpreferencePaneTitle
s to get localized window titles. - Single settings pane: Sets the window title to
APPNAME Settings
. The app name is obtained from your app's bundle. You can localize itsInfo.plist
to customize the title. TheSettings
part is taken from the "Settings…" menu item, see #12. The order of lookup for the app name from your bundle:CFBundleDisplayName
CFBundleName
CFBundleExecutable
- Fall back to
"<Unknown App Name>"
to show you're missing some settings.
Why should I use this instead of just manually implementing it myself?
It can't be that hard right? Well, turns out it is:
- The recommended way is to implement it using storyboards. But storyboards... And if you want the segmented control style, you have to implement it programmatically, which is quite complex.
- Even Apple gets it wrong, a lot.
- You have to correctly handle window and tab restoration.
- The window title format depends on whether you have a single or multiple panes.
- It's difficult to get the transition animation right. A lot of apps have flaky animation between panes.
- You end up having to deal with a lot of gnarly auto-layout complexities.
How is it better than MASPreferences
?
- Written in Swift. (No bridging header!)
- Swifty API using a protocol.
- Supports segmented control style tabs.
- SwiftUI support.
- Fully documented.
- Adheres to the macOS Human Interface Guidelines.
- The window title is automatically localized by using the system string.
Related
- Defaults - Swifty and modern UserDefaults
- LaunchAtLogin - Add "Launch at Login" functionality to your macOS app
- KeyboardShortcuts - Add user-customizable global keyboard shortcuts to your macOS app
- DockProgress - Show progress in your app's Dock icon
- Regex - Swifty regular expressions
- More…
You might also like Sindre's apps.
Used in these apps
- TableFlip - Visual Markdown table editor by Christian Tietze
- The Archive - Note-taking app by Christian Tietze
- Word Counter - Measuring writer's productivity by Christian Tietze
- Medis - A Redis GUI by Zihua Li
- vChewing IME - Next-generation bopomofo-phonetic Chinese input method by The vChewing Project
Want to tell the world about your app that is using Preferences? Open a PR!