Our app has recently been rejected for violating iOS Data Storage Guidelines about backing up files on iCloud.
I must mark data with the do not ba
Swift 5 version:
func addSkipBackupAttributeTo(url constURL: URL) {
do {
// Need a mutable URL to call setResourceValues
var url = constURL
var resourceValues = URLResourceValues()
resourceValues.isExcludedFromBackup = true
try url.setResourceValues(resourceValues)
} catch {
print("Unable to set isExcludedFromBackup on \(constURL)")
}
}
URLResourceValues keeps track of which values are modified and only writes those out, so it's fine to initialize a new object, set one key and call setResourceValues with it.