I am dealing with MacOS, not iOS, and I want to ensure that a file is not backed up to iCloud (if iCloud is enabled). How is that done?
Asked
Active
Viewed 116 times
0
-
I think you can add a `.nosync` to the end of the filename and it should not upload – Mar 26 '19 at 00:02
1 Answers
1
You could use NSURLIsExcludedFromBackupKey:
NSURL* url = //...
[[url setResourceValue:@YES] forKey:NSURLIsExcludedFromBackupKey error:nil];
It sets com.apple.metadata:com_apple_backup_excludeItem
extended attribute on files and directories.

TheNextman
- 12,428
- 2
- 36
- 75
-
But doesn't that affect only the NSURL object? I would think that to change the file itself, it would require using a method of NSFileManager. – xyz Mar 26 '19 at 00:57
-
No. It is confusing as normally `NSURL` doesn't work like that. But this will set the extended attribute above on the file or directory pointed at by the `NSURL`, and exclude it from iCloud backups. – TheNextman Mar 26 '19 at 01:23
-
Your question is actually a duplicate of https://stackoverflow.com/questions/27056556/disable-backup-of-documents-folder-and-all-its-sub-folders-on-icloud – TheNextman Mar 26 '19 at 01:25