macos - 快速访问应用程序组容器权利
问题描述
你好新年的人们。
我需要访问应用程序组容器中的 plist。
要在沙盒系统中获得访问权限,我应该怎么做才能让它正确。我确实在应用程序组容器中的创建目录中快速阅读然后回答,但在 XCode 11 中找不到相应的权利设置。
是否有相应的 URL 或路径(字符串)函数可以调用?据我所知,没有 .groupContainerDirectory 选项可用。
现在我尝试使用以下代码...
let appIdentifier = "UBF8T346G9.Office"
let fileManager = FileManager.default
let container = fileManager.containerURL(forSecurityApplicationGroupIdentifier: appIdentifier)
print("Container \(container)")
do{
if let container = container {
let directoryPath = container.appendingPathComponent("Profile Settings")
var isDir : ObjCBool = false
let path = directoryPath.path
if fileManager.fileExists(atPath: path, isDirectory: &isDir) {
if isDir.boolValue {
print("file exists and is a directory")
let plistPath = url.appendingPathComponent( "com.microsoft.visualbasic.plist").path
let plistDict = NSDictionary(contentsOfFile: plistPath)
if let dict = plistDict {
print("Dict: \(dict)") // <<<<<< Never comes here
}
}
}
}
} catch let error as NSError {
print(error.description)
}
}
当然不起作用,因为我需要一些访问应用程序的“组容器”
谢谢你。
解决方案
创建一个
com.apple.security.temporary-exception.files.home-relative-path.read-write
使用 Xcode 中项目内的项目权利文件中的相对路径键入密钥。
推荐阅读
- continuous-integration - CICD Java 应用程序(Maven)
- bash - 陷阱不退出循环
- python - 如何使用正则表达式解析日志以列出
- node.js - 在nodejs中处理大型excel数据
- node.js - 有没有办法在原子的核素调试器中为命令添加参数?
- asp.net - JsonConvert.DeserializeObject<> 正在返回 null 两个子令牌的最后一个子令牌
- python - 根据条件用来自其他文件的信息填充列
- python - 接收 SSL:CERTIFICATE_VERIFY_FAILED 仅在一页上
- r - Problem with encoding of character strings when loading json files to RStudio under Windows 10
- php - Update user profile Laravel