简体   繁体   English

调试 iOS 应用时如何查看 App Group Shared Container 目录的内容?

[英]How can I view the contents of the App Group Shared Container directory when debugging an iOS app?

Fairly self explanatory.相当不言自明。

We can view the app's documents, library, tmp directories via Window > Devices (this has been the case forever).我们可以通过 Window > Devices 查看应用程序的文档、库、tmp 目录(一直如此)。

But when app extensions came on the scene with iOS8, the App Group shared container came with them.但是当应用程序扩展随着 iOS8 出现时,App Group 共享容器也随之而来。 How can I view its contents?如何查看其内容?

Edit: to clarify, I'm not asking how to interact with this directory in code.编辑:澄清一下,我不是在问如何在代码中与这个目录交互。 I'm asking about how to interact with this directory in the context of Finder.我在询问如何在 Finder 的上下文中与该目录进行交互。

Get App Group Path获取应用组路径

#define APP_GROUP_PATH [[[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"yourGrpupId"] path]

Following code to view Shared container data以下代码查看共享容器数据

NSLog(@"Shared container data:%@",[self listFileAtPath:APP_GROUP_PATH]);

-(NSArray *)listFileAtPath:(NSString *)path
{
    int count;

    NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:NULL];
    for (count = 0; count < (int)[directoryContent count]; count++)
    {
        NSLog(@"File %d: %@", (count + 1), [directoryContent objectAtIndex:count]);
    }
    return directoryContent;
}

You can't exactly interact with it in a finder way.您不能以查找器的方式与它完全交互。 Altough you can view the container and download it.尽管您可以查看容器并下载它。

  1. Go to Devices and select the device转到设备并选择设备
  2. You can download the container with the three dotted button under the app that has the container setup.您可以使用具有容器设置的应用程序下的三个虚线按钮下载容器。

You can also show or download the container.您还可以显示或下载容器。

You can print the path to the directory in your code, then open the path in finder using Shift + CMD + G .您可以在代码中打印目录的路径,然后使用Shift + CMD + G在 finder 中打开路径。

print(urlToAFileInTheDirectory.absoluteString)

where urlToAFileInTheDirectory is a URL that contains the path to a file in the shared documents directory.其中urlToAFileInTheDirectory是一个URL ,其中包含共享文档目录中文件的路径。

This works in the simulator in Xcode 13. I'm not sure if it works on an actual device.这适用于 Xcode 13 的模拟器。我不确定它是否适用于实际设备。

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

相关问题 如何创建/使用共享应用程序组容器作为包含应用程序及其在ios中的扩展名之间的缓存存储 - How to create/use a shared app group container as cache storage between containing app and it's extension in ios 如何找到Apple App Group共享目录 - How to find Apple App Group shared directory 如何将文件添加到App Group共享目录? - How to add files to an App Group shared directory? 我可以在iOS设备上访问共享容器的内容吗? - Can I access the contents of a shared container on my iOS device? 如何为iOS应用创建自定义容器视图? - How do I create a custom container view for an iOS App? 如何在iOS共享Gmail应用中显示HTML正文? - How I can display a HTML body in iOS shared Gmail app? 如何在 Linux 中打印 ios 应用程序的共享依赖项 - How do I can print shared dependencies of ios app in Linux Ios:当应用程序处于非活动状态时,如何让我的应用程序返回到根视图 - Ios: How can I make my app go back to root view when App goes Inactive 如何从Cordova访问应用程序组共享容器? - How to access app group shared container from Cordova? 无法从iOS 10中的App组共享容器中获取扩展程序中的图像 - Not able to fetch images in extension app from App group shared container in iOS 10
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM