iOS开发者可以查看文件系统吗?

发布于 2024-12-04 01:02:46 字数 168 浏览 0 评论 0原文

我想知道开发人员是否有某种方法可以在不越狱设备的情况下查看 iOS 设备上的文件系统(例如 iFile)? 需要它用于开发目的。

编辑 感谢您的回答!我知道应用程序文件夹中有一个位置可以读取和写入。 但我一直在寻找一种无需编码即可快速查看数据的方法,例如 iFile。这样我就可以检查我的写入功能是否成功。

I wonder if developer has some sort of ways to be able to view file system on iOS device like iFile but without jailbreak the device?
Need it for devlopement purpose.

EDIT
Thanks for your answers! I know there is a place inside app folder and can be read and write to.
But I was looking for a way to view the data quickly without coding, like iFile. So I can check if my write functions suceed or not.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

生生不灭 2024-12-11 01:02:46

虽然 iDevice 上的文件系统是沙盒的,但 iPhone Simulator 中的文件系统却不是。您可以使用模拟器运行您的应用程序并通过以下方式检查内容:

~/Library/Application Support/iPhone Simulator/5.0/Applications

它应该可以满足您的需求。

While the file system on the iDevice is sandboxed, the one in iPhone Simulator is not. You can run your app with the simulator and check the content via:

~/Library/Application Support/iPhone Simulator/5.0/Applications

It should work for your needs.

廻憶裏菂餘溫 2024-12-11 01:02:46

对于设备:使用桌面应用程序 iPhone-Explorer 它通过 USB 读取文件系统(它可以读取并为 iPhoneSimulator 写入整个用户指定区域(应用程序、音乐、照片、视频、笔记等),但不是整个系统,除非你越狱并安装 afc2add)

(如 Liz 提到的): ~/Library/Application Support/iPhone Simulator/5.0/Applications

For device: use the desktop-application iPhone-Explorer it reads the filesystem via USB (It can read and write the entire user-designated zone (applications, music, photos, videos, notes, etc.), but not the entire system unless you jailbreak and install afc2add)

for iPhoneSimulator (like Liz mentioned): ~/Library/Application Support/iPhone Simulator/5.0/Applications

一身仙ぐ女味 2024-12-11 01:02:46

人们可以在 iOS 设备中查看文件,但只能在您的应用程序的沙箱中查看。每个应用程序都有一个 DocumentsCachetemp 文件夹。我认为前两个是在您连接设备时由 iTunes 自动备份的,后者不会备份。

例如,获取缓存目录路径 -

- (NSString *)getCacheDirPath
{
    NSString *path = nil;
    NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    if([myPathList count])
    {
        NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
        path = [[myPathList objectAtIndex:0] stringByAppendingPathComponent:bundleName];
    }
    return path;
}

查看 caches 目录中的所有文件 -

- (NSMutableArray *)showFiles
{
    NSError *err        = nil;
    NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *myPath    = [myPathList  objectAtIndex:0];
    NSArray *dirContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:myPath error:&err];
    if(err) NSLog(@"showFiles() - ERROR: %@",[err localizedDescription]);
    NSMutableArray *filePaths  = nil;

    int count = (int)[dirContent count];
    for(int i=0; i<count; i++)
    {
        [filePaths addObject:[dirContent objectAtIndex:i]];
    }
    return filePaths;
}

One can view files in an iOS device but only in that your App's sandbox. Every App has got a Documents, Cache and temp folders. I think the first two are automatically backed up by iTunes when you connect your device, the latter is not backed up.

Example, to get Cache directory path -

- (NSString *)getCacheDirPath
{
    NSString *path = nil;
    NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    if([myPathList count])
    {
        NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
        path = [[myPathList objectAtIndex:0] stringByAppendingPathComponent:bundleName];
    }
    return path;
}

To see all files in caches directory -

- (NSMutableArray *)showFiles
{
    NSError *err        = nil;
    NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *myPath    = [myPathList  objectAtIndex:0];
    NSArray *dirContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:myPath error:&err];
    if(err) NSLog(@"showFiles() - ERROR: %@",[err localizedDescription]);
    NSMutableArray *filePaths  = nil;

    int count = (int)[dirContent count];
    for(int i=0; i<count; i++)
    {
        [filePaths addObject:[dirContent objectAtIndex:i]];
    }
    return filePaths;
}
再见回来 2024-12-11 01:02:46

是的,您可以访问文件系统。但是,您仅限于自己的应用程序沙箱。而且您无法更改应用程序包,您作为应用程序一部分下载的所有内容都无法更改(出于安全原因,因为每个应用程序都经过签名)。但您可以将文件存储在应用程序的文档文件夹中。

看看这个讲座,解释了你需要知道的一切:

http://www.stanford.edu/class/cs193p/cgi-bin/drupal/system/files/lectures/09_Data.pdf

Yeah you can access the filesystem. You are limited to your own application sandbox only however. And you cannot make changes to the app bundle, everything you download as part of the app, this cannot be changed (for security reasons because every app is signed). But you can store files in your app's Documents folder.

Have a look at this lecture, explains everything you need to know:

http://www.stanford.edu/class/cs193p/cgi-bin/drupal/system/files/lectures/09_Data.pdf

噩梦成真你也成魔 2024-12-11 01:02:46

如果您将 plist 中的 UIFileSharingEnabled 键设置为 true,那么您将能够在 Mac 上使用 iTunes 查看应用程序沙盒文档目录中的文件系统,而无需额外编码。如果您想查看缓存目录或查看应用程序沙箱之外的内容,这将无济于事。

If you set a UIFileSharingEnabled key in your plist as true, then you will be able to use iTunes on your Mac to view the file system inside your app's sandboxed Documents directory without additional coding. This won't help if you want to view your Caches directory or look outside your app's sandbox.

如梦亦如幻 2024-12-11 01:02:46

当您的 iOS 设备连接到计算机并正确配置用于开发时,您可以使用 Xcode 4 下载您自己项目的文件,而不仅仅是 Documents 目录中的文件。

请参阅另一个答案:How to download app data in Xcode 4.2

When your iOS device is connected to your computer and correctly provisioned for development, you can use Xcode 4 to download files for your own projects, and not only the files in the Documents directory.

Refer to this other answer: How to download app data in Xcode 4.2

森林迷了鹿 2024-12-11 01:02:46

可以,有一个示例。你可以看看。

Can, there have a sample. you can have a look.

暗地喜欢 2024-12-11 01:02:46

是的,lms 是正确的。 Apple 已将文件访问权限限制为应用程序本身(文档目录)。所以没有其他方法可以访问它。我在一个项目中遇到了这个问题,我开始开发完整的文件访问系统。像 iFile 一样支持所有操作。您可以像 iFile 应用程序一样直观地完成所有操作。

https://github.com/CianApple/FileSystem

我已将该项目发布到 github 上供公众使用。请随意使用它。它可能会帮助您解决您的问题。

Yes lms is correct. Apple has limited the file access to just the app itself's (Document directory). So there is no other way of accessing it. I faced this issue in one of my projects and I started developing the full file accessing system. All operations are supported like iFile. You can do everything similarly as iFile app visually.

https://github.com/CianApple/FileSystem

I have posted the project on github for public. Feel free to use it. It might help you with your issue.

冷默言语 2024-12-11 01:02:46

itools 是一个围绕苹果保护 iPhone 的小工具。因此,它可能会违反苹果的一些政策,但确实可以完成工作

itools is a little tool that works around apples efforts to protect the iPhone. it therefor might infringe with some of apples policies but does the job

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文