LCAppSandboxFileKit is a framework for writing and accessing files outside of the macOS application sandbox file!
- Define the path for which authorization is required
let authorizedDirectory = "/"
- Clear the access permissions of the specified path
LCAppSandboxFileKit.standard.clearAccessForPath(authorizedDirectory) { status in
if status {
print("Successfully cleared access to the root directory.")
} else {
print("Failed to clear access to the root directory.")
}
}
- Check if the directory has access permissions
let isPermiss = LCAppSandboxFileKit.standard.checkAccessForPath(authorizedDirectory)
if isPermiss {
print("Directory access granted, starting search.")
} else { // No access, request permission
print("No directory access, requesting permission.")
LCAppSandboxFileKit.standard.requestAccessForPath(authorizedDirectory, canChooseDirectories: true) { status in
if status {
print("Permission granted, proceeding with the process.")
} else {
print("Failed to obtain permission.")
}
}
}
PermissionsKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'LCAppSandboxFileKit'
Add https://github.com/DevLiuSir/LCAppSandboxFileKit.git
in the “Swift Package Manager” tab in Xcode.
MIT License
Copyright (c) 2024 Marvin
DevLiuSir Software Engineer |
---|