[英]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.
尽管您可以查看容器并下载它。
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.