Skip to content

Latest commit

 

History

History
156 lines (105 loc) · 5.11 KB

File metadata and controls

156 lines (105 loc) · 5.11 KB

 LCAppSandboxFileKit 是一个用于写入和访问 macOS 应用程序沙盒文件之外的文件的功能的框架!

Swift Versions Supported Platforms

中文 | English

如何使用

  • 定义需要授权的路径
let authorizedDirectory = "/"
  • 清除指定路径的访问权限
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.")
    }
}
  • 清除所有路径的访问权限
LCAppSandboxFileKit.standard.clearAllBookmarkData()
  • 检查目录是否有访问权限
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.")
        }
    }
}
  • 请求指定路径的访问权限,自定义面板信息
 LCAppSandboxFileKit.standard.requestAccessForPath("/", title: "custom title", panelButtonTitle: "button title", canChooseDirectories: true) { status in
     if status {
        print("Permission granted, proceeding with the process.")
    } else {
        print("Failed to obtain permission.")
    }
}
  • 请求指定路径的访问权限,是否显示附件面板
 LCAppSandboxFileKit.standard.requestAccessForPath("/Users", isRootOptionEnabled: true, canChooseDirectories: true) { status in
     if status {
        print("Permission granted, proceeding with the process.")
    } else {
        print("Failed to obtain permission.")
    }
}

设计

附件面板
普通

安装

CocoaPods

PermissionsKit 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中:

pod 'LCAppSandboxFileKit'

SwiftPackage

添加 https://github.com/DevLiuSir/LCAppSandboxFileKit.git Xcode 中的“Swift Package Manager”选项卡.

许可证

MIT License

Copyright (c) 2024 Marvin

作者

DevLiuSir

Software Engineer