FullDiskAccess

main

Swift package for querying and prompting for Full Disk Access on macOS 10.14+
inket/FullDiskAccess

💾 FullDiskAccess

FullDiskAccess is a Swift package for querying and prompting for Full Disk Access permission on macOS 10.14+

When do you need Full Disk Access?

When your macOS app is not sandboxed and you need to access system files or files belonging to other apps. Example apps: file backup apps, apps that need to search the entire system, etc.

Why a package?

The lack of documentation regarding Full Disk Access creates a lot of confusion online, so I ran 6 VMs to confirm behavior between macOS versions. This package makes clear what's possible and what's not, and makes it easy to check permission and prompt the user.

Usage

Checking the current status

import FullDiskAccess

if FullDiskAccess.isGranted {
    // Great!
}

ℹ️ On macOS 10.15+, checking isGranted will automatically add your app to the Full Disk Access entries in Privacy & Security (unchecked)

Prompting the user to enable Full Disk Access

Apps cannot enable Full Disk Access automatically (for good reason), so the user will have to do that. We make it easy by automatically adding the app to the Full Disk Access entries in Privacy & Security (unchecked) and guiding the user to that screen.

import FullDiskAccess

FullDiskAccess.promptIfNotGranted(
    title: "Enable Full Disk Access for MacSymbolicator",
    message: "MacSymbolicator requires Full Disk Access to search for DSYMs using Spotlight.",
    settingsButtonTitle: "Open Settings",
    skipButtonTitle: "Later",
    canBeSuppressed: false, // `true` will display a "Do not ask again." checkbox and honor it
    icon: nil
)

Other tasks

import FullDiskAccess

// Opens the System Settings (aka System Preferences) with the Privacy & Security preference pane open and the
// Full Disk Access tab pre-selected.
FullDiskAccess.openSystemSettings()

// Resets the prompt suppression (i.e. if the user has selected "Do not ask again.", this resets their choice)
FullDiskAccess.resetPromptSuppression() {

Support the project

Buy Me A Coffee

Contribute

Believe something is not right or have a suggestion for improvements? Your feedback is welcome. Please create an issue!

Contact

@inket / @inket on Mastodon / mahdi.jp

Description

  • Swift Tools 5.4.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Dec 12 2024 07:51:47 GMT-1000 (Hawaii-Aleutian Standard Time)