For hiding your app from iTunes file sharing, you can set the below key to No
in your info.plist.
Application supports iTunes file sharing
Alternatively, prepend your filenames / directories added the the Documents directory with a .
to hide it without disabling iTunes File Sharing. E.g. .folderName
.
Use this to prevent iCloud backup, from Prevent Backup to iCloud,is following code correct?
- (BOOL)addSkipBackupAttributeToItemAtPath:(NSString *)filePathString {
NSURL *fileURL = [NSURL fileURLWithPath:filePathString];
assert([[NSFileManager defaultManager] fileExistsAtPath: [fileURL path]]);
NSError *error = nil;
BOOL success = [fileURL setResourceValue:[NSNumber numberWithBool: YES]
forKey: NSURLIsExcludedFromBackupKey
error: &error];
return success;
}
And to prevent app backup from XCode Organizer when the device is locked, use this snippet
//************************************************************************
// Method for making files and folders secure
//************************************************************************
+ (void)makeItemAtPathSecure:(NSString *)path
{
NSError *securingFilesError;
NSFileManager *manager=[NSFileManager defaultManager];
NSDictionary *attrs = [manager attributesOfItemAtPath:path error:&securingFilesError];
if(![[attrs objectForKey:NSFileProtectionKey] isEqual:NSFileProtectionComplete])
{
if(![manager setAttributes:[NSDictionary dictionaryWithObject:NSFileProtectionComplete forKey:NSFileProtectionKey] ofItemAtPath:path error:&securingFilesError])
{
NSLog(@"Problem in securing files: %@",[securingFilesError localizedDescription]);
}
}
else
{
NSLog(@"Problem in securing files: %@",[securingFilesError localizedDescription]);
}
}
For selectively hiding folders in iTunes try renaming the folder with a . before it, like folderName should be .folderName