Ivan VorobeiandClaude Opus 5 1ccec73d24 refactor: drop dead branches and unused imports across the permissions
EKAuthorizationStatusAuthorized is declared as an alias of fullAccess and
kCLAuthorizationStatusAuthorized as an alias of authorizedAlways, so in
Calendar, Reminders and Location the branch listed first swallowed the one
below it. Location now says plainly what it always did: always covers either
access level, when-in-use covers only its own.

Calendar and Location kept a Permission.Kind and unpacked it with switches
ending in fatalError, although each type only ever holds its own kind. They
store the access level instead and build the kind from it, which also lets
Calendar request the level directly rather than through two intermediate
closures.

The location handlers no longer implement locationManager(_:didChangeAuthorization:),
deprecated since iOS 14 and never called at the current deployment target.
Location imported EventKit instead of CoreLocation and Bluetooth imported
CloudKit without using it. The German strings file still carried nine keys
from an interface the package no longer ships.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 14:41:12 +04:00
2023-04-10 15:05:53 +03:00

PermissionsKit

Universal API for requesting permissions and reading their status — .authorized, .denied & .notDetermined. Each permission ships as a separate product, so the app compiles only the ones it actually uses.

Installation

In Xcode: File → Add Package Dependencies → paste URL:

https://github.com/sparrowcode/PermissionsKit

Then pick the products you need. Add only those — every permission API you link is visible to App Review, and unused ones invite questions about why the app needs them.

Permissions

Permission Product Key for Info.plist
Bluetooth BluetoothPermission NSBluetoothAlwaysUsageDescription, NSBluetoothPeripheralUsageDescription
Calendar CalendarPermission NSCalendarsUsageDescription, NSCalendarsFullAccessUsageDescription, NSCalendarsWriteOnlyAccessUsageDescription
Camera CameraPermission NSCameraUsageDescription
Contacts ContactsPermission NSContactsUsageDescription
FaceID FaceIDPermission NSFaceIDUsageDescription
Health HealthPermission NSHealthUpdateUsageDescription, NSHealthShareUsageDescription
Location LocationPermission NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription
Media Library MediaLibraryPermission NSAppleMusicUsageDescription
Microphone MicrophonePermission NSMicrophoneUsageDescription
Motion MotionPermission NSMotionUsageDescription
Notification NotificationPermission —
Photo Library PhotoLibraryPermission NSPhotoLibraryUsageDescription, NSPhotoLibraryAddUsageDescription
Reminders RemindersPermission NSRemindersUsageDescription, NSRemindersFullAccessUsageDescription
Siri SiriPermission NSSiriUsageDescription
Speech Recognizer SpeechRecognizerPermission NSSpeechRecognitionUsageDescription
Tracking TrackingPermission NSUserTrackingUsageDescription

Usage

Request a permission:

import PermissionsKit
import NotificationPermission

Permission.notification([.alert, .badge, .sound]).request {
    // Called once the user answers the system dialog.
}

Read its status:

import PermissionsKit
import CameraPermission

let authorized = Permission.camera.authorized

Warning

FaceID can't tell .authorized from .notDetermined — both come back as .notDetermined. Only .denied is reliable.

Keys in Info.plist

Apple requires a usage description for most permissions. Get the key for a permission:

let key = Permission.bluetooth.usageDescriptionKey

Note

Use the key itself, not the description text — Xcode won't build otherwise.

Localisation

An xliff export creates the keys for you. Doing it by hand means adding an InfoPlist.strings file, selecting the languages in the inspector, and writing the keys there:

"NSCameraUsageDescription" = "Here description of usage camera";
Languages
Swift 100%