Exclude Specified file url from iCloud backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct FileHelpers { | |
@discardableResult static func addSkipBackupAttribute(url: URL) throws -> Bool { | |
var fileUrl = url | |
do { | |
if FileManager.default.fileExists(atPath: fileUrl.path) { | |
var resourceValues = URLResourceValues() | |
resourceValues.isExcludedFromBackup = true | |
try fileUrl.setResourceValues(resourceValues) | |
} | |
return true | |
} catch { | |
print("failed setting isExcludedFromBackup \(error)") | |
return false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment