Mac App沙箱组容器问题 [英] Mac App Sandbox Group Container problems

查看:76
本文介绍了Mac App沙箱组容器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm having some trouble with two Sandboxed applications in one Application Group. In my Entitlements file i have the following:

<?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>

将公司"和"AppName"替换为我的公司,将应用程序名称和TEAM_ID替换为我的团队的ID.这两个应用程序都具有完全相同的权利.

Where 'Company' and 'AppName' are replaced with my company and the App name and TEAM_ID with my team's id. Both applications have these exact same entitlements.

现在,当我构建并启动这两个应用程序时,一切似乎都还可以.除了在我的〜/Library文件夹中找不到"Group Containers"文件夹外,还有一个"Containers"文件夹,其中包含两个应用程序的文件夹.但是没有组容器"文件夹.

Now, when i build and launch both apps everything seems to be going quite allright. Except for the fact that there is no 'Group Containers' folder to be found in my ~/Library folder... There IS a 'Containers' folder with a folder for both apps. But no Group Containers folder.

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

I'm running 10.8.2 and my app's deployment target is 10.8.

根据开发者库,它应该从10.7.4起可用.我使用了它:

According to the Developer Library it should be available from 10.7.4. I've used this: https://developer.apple.com/library/mac/#documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingAppSandbox.html#//apple_ref/doc/uid/TP40011195-CH4-SW19 to create my entitlements.

我在做什么错了?

谢谢

推荐答案

Apple开发者论坛上的某人建议以编程方式创建文件夹,这是解决我的问题的方法!

Someone on the official Apple Developer Forums suggested creating the folder programmatically, which was the solution to my problem!

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:方法).现在可以完美运行了:)

I've used the Group Container folder for a plist file in which my main application can write settings that my helper (deamon) application can read (using the initWithContentsOfFile: and writeToFile: methods of NSMutableDictionary). This works perfectly now :)

这篇关于Mac App沙箱组容器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆