如何将文件添加到应用组共享目录?

How to add files to an App Group shared directory?

所以我有一个带有共享扩展的应用程序,每个应用程序都有自己的目标。应用程序包标识符的核心是 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]];
    }});

我在这里缺少什么?

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