I have an already running enterprise application which stores a lot of documents inside the documents folders. I wish to disable the iCloud backup of all these documents and
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *directory = paths[0];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *url = [NSURL fileURLWithPath:directory];
NSError *error;
// exclude from iCloud backup
if ([url setResourceValue:@(YES) forKey:NSURLIsExcludedFromBackupKey error:&error] == NO) {
NSLog(@"Error: Unable to exclude directory from backup: %@", error);
}
You can call these once at first install. And it will apply on subfolders and files.