5

我在一个应用程序组中的两个沙盒应用程序中遇到了一些问题。在我的权利文件中,我有以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/    PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
     <key>com.apple.security.app-sandbox</key>
     <true/>

     <key>com.apple.security.application-groups</key>
     <array>
          <string>TEAM_ID.com.Company.AppName</string>
     </array>
</dict>
</plist>

其中“公司”和“应用程序名称”替换为我的公司,应用程序名称和 TEAM_ID 替换为我的团队 ID。这两个应用程序具有完全相同的权利。

现在,当我构建并启动这两个应用程序时,一切似乎都很顺利。除了在我的 ~/Library 文件夹中找不到“Group Containers”文件夹这一事实之外……有一个“Containers”文件夹,其中包含两个应用程序的文件夹。但没有 Group Containers 文件夹。

我正在运行 10.8.2,我的应用程序的部署目标是 10.8。

根据开发人员库,它应该从 10.7.4 开始可用。我用过这个:https ://developer.apple.com/library/mac/#documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingAppSandbox.html#//apple_ref/doc/uid/TP40011195-CH4-SW19来创建我的权利。

我究竟做错了什么?

谢谢,

4

2 回答 2

3

官方 Apple Developer Forums 上的某个人建议以编程方式创建文件夹,这就是我的问题的解决方案!

NSString *groupContainer = [@"~/../../../Group Containers/TEAM_ID.com.Company.AppName" stringByExpandingTildeInPath];

[[NSFileManager defaultManager] createDirectoryAtPath:groupContainer withIntermediateDirectories:YES attributes:nil error:NULL]]

我将 Group Container 文件夹用于 plist 文件,我的主应用程序可以在其中写入我的助手(守护程序)应用程序可以读取的设置(使用 NSMutableDictionary 的 initWithContentsOfFile: 和 writeToFile: 方法)。这现在完美无缺:)

于 2013-03-01T16:22:20.623 回答
0

作为@jeppeb 的更新,我也不得不手动创建文件夹。在 Swift、Mac OSX 10.14 中,我发现使用:

let appSupport: String = NSString(string: "~/Library/Group Containers/com.myCo.myAppName/Library/Application Support").expandingTildeInPath
try fileMan.createDirectory(atPath: appSupport, withIntermediateDirectories: true, attributes: nil)

let caches: String = NSString(string: "~/Library/Group Containers/com.myCo.myAppName/Library/Caches/myCacheFolder").expandingTildeInPath
try fileMan.createDirectory(atPath: caches, withIntermediateDirectories: true, attributes: nil)

let prefs: String = NSString(string: "~/Library/Group Containers/com.myCo.myAppName/Library/Preferences").expandingTildeInPath
try fileMan.createDirectory(atPath: prefs, withIntermediateDirectories: true, attributes: nil)

我不敢相信这是正确的做事方式,但到目前为止我还没有找到任何其他答案,这就是我需要做的来创建一个 Groups Container 文件夹以及一个 Preferences 文件夹来存储任何套件我使用的偏好....

于 2018-12-28T20:57:22.833 回答