Thursday, October 9, 2014

Document Directory path in iOS 8




Problem-

You may have noticed that iOS8 simulator is not visible when you go to the given path-

 Users/Library/Application Support/iPhone Simulator/ 





Solution-

Now in XCode6, data directories are per-devices rather than per-version.

To find the document directory for Xcode6 & iOS8 is not as easy as it was earlier. You have to play guessing game twice. Once for finding the appropriate device. Once you find the device you have to search the application. 

You can find the document directory in the given path.

Library/Developer/CoreSimulator/Devices/cryptic number/data/Containers/Data/Application/cryptic number

Steps to Find Document Directory-

1) Follow the given path.

Users/Library/Developer/CoreSimulator/Devices/ 

2) Now, Device folder will have some cryptic number folders. Each folder will have Data folder & device.plist. Check the devicePlist to know about the deviceType.






3) Once you find your device, you have to follow the given path to find the application & document directory.
Data/Containers/Data/Application/cryptic number


4) Now this cryptic number folder will have 3 folders- Documents ( Document directory), Library & temp.




Note- As finding the document directory path become tedious. So, if you are testing the application then you can check the document directory path programaticaly.
NSLog(@"Documents Directory: %@", [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);




1 comment:

  1. Hi Meenakshi,

    Thanks for the information. I have a doubt, so what will happen if I am still using the way , is it obsolete in iOS8?

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true);
    NSString *documentPath = [paths objectAtIndex:0];

    My app is still working with this old way.

    This change ([[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]) is mandatory in iOS 8?

    ReplyDelete