My application got rejected by Apple due to :
2.23: Apps must follow the iOS Data Storage Guidelines or they will be rejected
so
You can mark as no-backup only the parent folder, not every file. But it should not be a Documents directory as it should contain only user-created content. You should use Library/Application Support (Technical Q&A QA1719)
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *directory = [paths objectAtIndex:0];
directory = [directory stringByAppendingPathComponent:@"MyData"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:directory] == NO) {
NSError *error;
if ([fileManager createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:&error] == NO) {
NSLog(@"Error: Unable to create directory: %@", error);
}
NSURL *url = [NSURL fileURLWithPath:directory];
// exclude downloads from iCloud backup
if ([url setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error] == NO) {
NSLog(@"Error: Unable to exclude directory from backup: %@", error);
}
}
Credits: xinsight blog
... And finally my application has been approved . just follow this instruction :
put this code on appDelegate.m (didFinishLunching)
NSString *docsDir;
NSArray *dirPaths;
NSURL * finalURL;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
finalURL = [NSURL fileURLWithPath:docsDir];
[self addSkipBackupAttributeToItemAtURL:finalURL];
and skip backup :
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);
NSError *error = nil;
BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
forKey: NSURLIsExcludedFromBackupKey error: &error];
if(!success){
NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
}
return success;
}