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"];

Refer Technical Note 2406 by Apple

The breaking change is

Beginning in iOS 8, the Documents and Library directories are no longer siblings of your application's bundle.

Don't store full path/URL to your documents. Store the file name and always generate full path/URL with recommended approach.

Get the DocumentsDirectory URL

// Returns the URL to the application's Documents directory.
- (NSURL *)applicationDocumentsDirectory
{
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

Then you get path out of url and append the file name to generate full path.