如何将文件添加到App Group共享目录?

时间:2016-11-15 19:15:34

标签: ios permissions filesystems ios8-share-extension bundle-identifier

所以我有一个带有共享扩展的应用程序,每个应用程序都有自己的目标。应用程序的核心'捆绑包标识符为com.company.app,共享扩展名为com.company.app.share。每个都有自己的权利文件,核心应用程序为App Groups -> group.com.company.app,共享扩展名相同。两个软件包标识符都在Apple开发人员网站上列出,但出于某种原因,

我似乎没有正确的权限来写入共享的private/var/mobile/Containers/Shared/AppGroup/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/Library/Caches/目录。

我得到的错误信息是: You don’t have permission to save the file “Caches” in the folder “Library”.

目录的保存方式如下:

GetZipURLInItems(self.extensionContext.inputItems, ^(NSURL *url, NSError *error) {
    if (error == nil) {

        NSURL *containerURL = [[[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:GroupIdentifier] URLByAppendingPathComponent:@"Library/Caches"];
        NSLog(@"EXT: containerURL: %@", containerURL);

        [WPZipArchive unzipFileAtPath:[url path] toDestination:[containerURL absoluteString]];

        [self listDirectoryAtPath:[containerURL absoluteString]];
    }});

我在这里失踪了什么?

1 个答案:

答案 0 :(得分:3)

问题实际上是使用[url absoluteString] vs [url path],将所有url更改为路径解决了权限错误。

相关问题