【问题标题】:How to add files to an App Group shared directory?如何将文件添加到 App Group 共享目录?
【发布时间】:2017-03-29 19:31:27
【问题描述】:

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

我似乎没有写入共享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]];
    }});

我在这里缺少什么?

【问题讨论】:

  • 你是怎么写的?看看使用 NSFileManager:containerURLForSecurityApplicationGroupIdentifier
  • @Essenceofchickens 我更新了原始问题以显示我如何保存目录。
  • 你试过没有 URLByAppendingPathComponent: 部分吗?

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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-13
    • 1970-01-01
    • 2022-06-17
    • 2015-01-23
    相关资源
    最近更新 更多