FullDiskAccess is a Swift package for querying and prompting for Full Disk Access permission on macOS 10.14+
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.
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.
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)
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
)
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() {
Believe something is not right or have a suggestion for improvements? Your feedback is welcome. Please create an issue!