---
title: 0xwdg/preferencekit
framework: Swift Package Catalog
role: article
path: packages/0xwdg/preferencekit
---

# 0xwdg/preferencekit

PreferenceKit provides a ready-made SwiftUI settings screen with application

## Requirements

- Swift 6.0+ (Xcode 16+) - iOS 15+, macOS 12+, watchOS 8+, tvOS 15+

## Installation (Package.swift)

```swift dependencies: [     .package(url: "https://github.com/0xWDG/PreferenceKit.git", branch: "main"), ], targets: [     .target(name: "MyTarget", dependencies: [         .product(name: "PreferenceKit", package: "PreferenceKit"),         // Add only the privacy products used by this app.         .product(name: "PreferenceKitCamera", package: "PreferenceKit"),     ]), ] ```

## Installation (Xcode)

1. In Xcode, open your project and navigate to **File > Swift Packages > Add Package Dependency...** 2. Paste the repository URL (`https://github.com/0xWDG/PreferenceKit`) and click **Next**. 3. Click **Finish**.

## Usage

```swift import SwiftUI import PreferenceKit

struct ContentView: View {     @State private var sendsDiagnostics = true

var body: some View {         PreferenceKit(             createdBy: "[Example Studio](https://example.com)",             privacyPolicyURL: URL(string: "https://example.com/privacy"),             supportEmail: "support@example.com",             socialMediaLinks: [                 .init(platform: .github, profile: "example"),                 .init(platform: .mastodon, profile: "@example@mastodon.social"),                 .init(platform: .website, profile: "https://example.com")             ],             changeLog: [                 .init(version: "1.2.0", date: "2026-09-24", text: "Improved settings.")             ],             acknowledgements: [                 .init(                     name: "Example Dependency",                     copyright: "Example Authors",                     licence: "MIT",                     url: "https://github.com/example/dependency"                 )             ]         ) {             Section("Support") {                 Toggle("Include diagnostics in feedback", isOn: $sendsDiagnostics)             }         } bottomContent: {             Section {                 Text("Thanks for using Example App.")             }         }     } } ```

`privacyPolicyURL` is displayed in an in-app web view where supported; on other platforms or OS versions, PreferenceKit opens the URL in the system browser. When a configured capability has a supported nonempty privacy usage description in the host app's `Info.plist`, PreferenceKit adds a Privacy destination. It lists those selected capabilities, shows each system-prompt reason, and links to Settings where the platform supports changing the permission. Notifications have no `Info.plist` usage-description key and are shown whenever their product is configured. Each detail view shows the current authorization status without requesting access.

Privacy purpose strings belong to the consuming app's `Info.plist`. They must truthfully describe the feature that accesses the protected data; see [the privacy-permissions guide](Sources/PreferenceKit/PreferenceKit.docc/UsingPreferenceKit.md#privacy-permissions) for the required keys and examples.

Each protected framework is an opt-in product. Add only the products used by your app, then import them and pass their capabilities to `PreferenceKit`. This prevents an unused protected framework from being linked into the final binary.

```swift import PreferenceKit import PreferenceKitCamera import PreferenceKitPhotos

PreferenceKit(     changeLog: nil,     acknowledgements: nil,     privacyPermissions: [.camera, .photos] ) ```

| Capability | Product | Value | Purpose-string key | | --- | --- | --- | --- | | Camera | `PreferenceKitCamera` | `.camera` | `NSCameraUsageDescription` | | Microphone | `PreferenceKitMicrophone` | `.microphone` | `NSMicrophoneUsageDescription` | | Photos | `PreferenceKitPhotos` | `.photos` | `NSPhotoLibraryUsageDescription` | | Location | `PreferenceKitLocation` | `.location` | `NSLocationWhenInUseUsageDescription` | | Contacts | `PreferenceKitContacts` | `.contacts` | `NSContactsUsageDescription` | | Calendar | `PreferenceKitCalendar` | `.calendar` | `NSCalendarsFullAccessUsageDescription` | | Reminders | `PreferenceKitReminders` | `.reminders` | `NSRemindersFullAccessUsageDescription` | | Speech Recognition | `PreferenceKitSpeechRecognition` | `.speechRecognition` | `NSSpeechRecognitionUsageDescription` | | Notifications | `PreferenceKitNotifications` | `.notifications` | None |

## Configuration

All configuration is optional except `changeLog` and `acknowledgements`, which accept `nil` when the corresponding row should be hidden.

| Parameter | Effect | | --- | --- | | `createdBy` | Displays an attributed Markdown link below the app name. | | `privacyPolicyURL` | Adds a Privacy Policy row. | | `privacyPermissions` | Selected capabilities from imported privacy products. | | `privacyContent` | Adds a custom row or section in the Privacy destination. | | `supportEmail` | Adds a Feedback row and includes app and diagnostic details. | | `socialMediaLinks` | Adds links for developer profiles and communities. | | `changeLog` | Adds a Changelog destination. | | `acknowledgements` | Adds an Acknowledgements destination. | | `topContent` / `bottomContent` | Places your own `Section` views around the built-in content. |

Use a platform-specific profile identifier for social media when possible—for example, `"example"` for GitHub or `"@example@mastodon.social"` for Mastodon. You can also pass a complete HTTP or HTTPS URL for custom community, invite, or profile destinations.

See the [DocC usage guide](Sources/PreferenceKit/PreferenceKit.docc/UsingPreferenceKit.md) and [configuration reference](Sources/PreferenceKit/PreferenceKit.docc/Configuration.md) for details.

## Screenshot

<img width="296" height="487" alt="image" src="https://github.com/user-attachments/assets/838fcd55-05c7-4efd-a4c0-fda3c9b214eb" />

## Contact

[https://wesleydegroot.nl](https://wesleydegroot.nl)

Interested learning more about Swift? [Check out my blog](https://wesleydegroot.nl/blog/).

## Package Metadata

Repository: 0xwdg/preferencekit

Default branch: main

README: README.md
