简体   繁体   English

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

[英]How to add files to an App Group shared directory?

So I have an app with a share extension each with their own target. 所以我有一个分享扩展的应用程序,每个都有自己的目标。 The core of the apps' bundle identifier is com.company.app and the share extensions is com.company.app.share . 应用程序包标识符的核心是com.company.app ,共享扩展名是com.company.app.share Each have their own entitlements file, with the core apps being App Groups -> group.com.company.app and the share extension being the same. 每个都有自己的权利文件,核心应用程序是App Groups -> group.com.company.app ,共享扩展名是相同的。 Both of the bundle identifiers are listed on the apple developer website but for some reason, 两个软件包标识符都列在Apple开发人员网站上,但由于某些原因,

I don't seem to have the right permissions to write to the shared private/var/mobile/Containers/Shared/AppGroup/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/Library/Caches/ directory. 我似乎没有权限写入共享private/var/mobile/Containers/Shared/AppGroup/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/Library/Caches/目录。

The error message I get is: You don't have permission to save the file “Caches” in the folder “Library”. 我得到的错误消息是: You don't have permission to save the file “Caches” in the folder “Library”.

The directory is being saved like this: 该目录正在保存如下:

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]];
    }});

What am I'm missing here? 我在这里缺少什么?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM