ios 8: Bundle path changes

In iOS 8, The file system layout of app containers has changed. Applications and their content are no longer stored in one root directory.

From the iOS 8 Release Notes:

The file system layout of app containers has changed on disk. Rather
than relying on hard-coded directory structure, use the
NSSearchPathForDirectoriesInDomains function or the
URLForDirectory:inDomain:appropriateForURL:create:error: method of the
NSFileManager class. See Accessing Files and Directories in File
System Programming Guide
.

This is not a bug. Make sure you use the recommended APIs (from the above quote) and you won’t have a problem.

So, If you are trying to access a bundled resource you added to the project, you would use:

[[NSBundle mainBundle] pathForResource:@"resourceName" ofType:@"extension"];

But if you want to use something that you put in the documents directory, you would use:

[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"resourceName.extension"];

Leave a Comment