Mac OS in App Sandbox权利目录读取问题

问题描述 投票:1回答:2

我的应用沙盒权利有问题。

我的Mac OS应用程序允许用户打开XML文件。解析该文件后,它将读取与XML文件位于同一目录中的图像文件。

如果应用沙箱为False,则图像加载就很好。如果“应用程序沙箱”为True,则无法加载图像。 (仍然读取XML文件)

应用程序沙箱必须为True才能推送到App Store。

我已经尝试过

com.apple.security.files.user-selected.read-write = TRUE
com.apple.security.temporary-exception.files.home-relative-path.read-only = TRUE
com.apple.security.temporary-exception.files.absolute-path.read-only = TRUE

我从Apple的文档中提取了此信息:Apples Entitlement Doc

是否可以读取两个文件?其他人遇到这样的事情吗?

此外,这两个文件可以位于用户通常保存文件的任何位置。包括网络驱动器。

objective-c plist sandbox entitlements
2个回答
0
投票

没有为了读取文件,它必须是:

  • 在世界可读的位置,或
  • 在可以在权利首选项中启用的文件夹中,即下载文件夹,或
  • 由用户使用NSOpenPanel手动打开或保存到该位置,然后可以选择将其保存为一个
  • 作为安全范围的书签存储,之后可以自由访问它。参见here

0
投票

com.apple.security.files.user-selected.read-write = TRUE

这是一个布尔值,没关系,授权文件中的XML表示为:

<key>com.apple.security.files.user-selected.read-write</key>
<true/>

其他2种权利不是布尔值,而是字符串数组。因此,在权利文件中表示它的正确方法是:

<key>com.apple.security.temporary-exception.files.home-relative-path.read-only</key>
<array>
    <string>example/local/path1/</string>
    <string>example/local/path2/</string>
</array>
<key>com.apple.security.temporary-exception.files.absolute-path.read-only</key>
<array>
    <string>/usr/local/bin/</string>
    <string>/usr/local/lib/</string>
</array>
© www.soinside.com 2019 - 2024. All rights reserved.