URLResourceValue and setResourceValues Swift 3
Additionally to what TheEye provided, make sure your URL is a var and not a let.
That is what made my code work after migrating to swift 3.
The Xcode suggestion "Use struct URLResourceValues and URL.setResourceValues(_:) instead" is prompting you to write something like this:
let paths = NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask, true)
for dir in paths {
print("the paths are \(dir)")
var urlToExclude = URL(fileURLWithPath: dir)
do {
var resourceValues = URLResourceValues()
resourceValues.isExcludedFromBackup = true
try urlToExclude.setResourceValues(resourceValues)
} catch { print("failed to set resource value") }
}
Please try.
NOTE
Please note that the file URL has to be a var - if it's a let you will get strange error messages (see comments).