I'm going to file this one away as a bug in cocos2d (or a feature request). Upon trying to load a file, it will attempt to only load it from the bundle. It simple won't load it from the Documents Directory.
So I fixed it!
In CCFileUtils.m:
- (NSString *)applicationDocumentsDirectory;
{
return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
}
This is a convenience method to get the iOS application's directory.
I then change pathForResource:ofType:inDirectory:
to be:
-(NSString*) pathForResource:(NSString*)resource ofType:(NSString *)ext inDirectory:(NSString *)subpath
{
// An absolute path could be used if the searchPath contains absolute paths
if( [subpath isAbsolutePath] ) {
NSString *fullpath = [subpath stringByAppendingPathComponent:resource];
if( ext )
fullpath = [fullpath stringByAppendingPathExtension:ext];
if( [_fileManager fileExistsAtPath:fullpath] )
return fullpath;
return nil;
}
if (resource) {
NSString *fullPath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:resource];
if( ext )
fullPath = [fullPath stringByAppendingPathExtension:ext];
if ([_fileManager fileExistsAtPath:fullPath]) {
return fullPath;
}
}
// Default to normal resource directory
return [_bundle pathForResource:resource
ofType:ext
inDirectory:subpath];
}
Basically, before defaulting into the Bundle directory, check if the resource exists in the Documents Directory. If it does, return it!
Now my map loads without a problem.