11

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.

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
巫妖王
  • 425
  • 2
  • 6
  • 18

9 Answers9

13

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.

Liz
  • 171
  • 4
9

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

Community
  • 1
  • 1
thomas
  • 5,637
  • 2
  • 24
  • 35
  • any guess how iExplorer able to access these. I need to access my app share document folder from my MacOS app – Shohrab Sep 20 '16 at 21:55
6

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;
}
Community
  • 1
  • 1
Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
  • 2
    Thanks for the answer! 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. – 巫妖王 Sep 11 '11 at 09:21
  • It's hard to tell what you mean by "to view data quickly without coding", but I'm assuming you mean you want to be able to store and retrieve objects in memory to disk easily. For that I'd use the NSCoding protocol on your objects. Makes it very easy to save/load objects to/from disk – lmirosevic Sep 11 '11 at 09:50
  • How to get file chooser window just as in the case of android, like when we click on choose file, the window appears for user to choose & upload – Eshwar Chaitanya Dec 15 '14 at 13:50
  • @巫妖王 How to get file chooser window just as in the case of android, like when we click on choose file, the window appears for user to choose & upload – Eshwar Chaitanya Dec 16 '14 at 08:01
  • just use `return [dirContent mutableCopy]` instead of that silly loop – ardnew Feb 11 '16 at 19:40
3

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

lmirosevic
  • 15,787
  • 13
  • 70
  • 116
1

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

Community
  • 1
  • 1
Chris W. Rea
  • 5,430
  • 41
  • 58
1

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.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
0

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

user501836
  • 1,106
  • 1
  • 12
  • 20
0

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.

Cian
  • 263
  • 4
  • 8
0

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

Jakob
  • 1,126
  • 3
  • 16
  • 38