LCPermissionsKit is a convenient wrapper on the macOS permissions API, including photos, contacts, reminders, and full disk access permissions!
Current implementation supports permissions for:
public enum LCPermissionType: Int {
case calendar = 0
case reminders
case contacts
case photos
case fullDiskAccess
}
- Checking permission status
let status = LCPermissionsKit.shared.authorizationStatus(for: .fullDiskAccess)
switch status {
case .authorized:
print("authorized")
case .notDetermined:
print("notDetermined")
case .denied:
print("denied")
case .limited:
print("limited")
}
- Request Permission
LCPermissionsKit.shared.requestAuthorization(for: .fullDiskAccess) { status in
print(status)
}
10.9+
NSCalendarsUsageDescription
key in info.plist is required.
10.11+
NSContactsUsageDescription
key is required in Info.plist
10.9+
NSRemindersUsageDescription
key is required in Info.plist
10.13+
NSPhotoLibraryUsageDescription
key is required in Info.plist
10.14+
Calling for permissions opens Preferences->Privacy with selected "Full Disk Access" section.
PermissionsKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'LCPermissionsKit'
Add https://github.com/DevLiuSir/LCPermissionsKit.git
in the “Swift Package Manager” tab in Xcode.
MIT License
Copyright (c) 2024 Marvin
DevLiuSir Software Engineer |
---|