Okay, thanks. Entitlements may be on the nose, as I'm seeing weird behavior when trying to run ditto from within Swift, as opposed to in the Terminal. I wanted to do a quick comparison, and running ditto via this code, in a Swift Playground, didn't work:
import Foundation
let srcPath = "/Users/thomas/Desktop/test.txt"
let destFolderPath = "/Users/thomas/Desktop/test-folder/"
func util_shell(_ command: String) - String {
let task = Process()
task.launchPath = "/bin/bash"
task.arguments = ["-c", command]
let pipe = Pipe()
task.standardOutput = pipe
task.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
let output: String = NSString(data: data, encoding: String.Encoding.utf8.rawValue)! as String
return output.trimmingCharacters(in: .whitespacesAndNewlines)
}
let theCommand = "ditto -v \(srcPath) \(destFolderPath)"
print(theCommand)
let theOutput = util_shell(theCommand)
print(theOutput)
This resulted in the following output:
ditto -v /Users/thomas/Desktop/test.txt /Users/thomas/Desktop/test-folder/
Copying /Users/thomas/Desktop/test.txt
ditto: /Users/thomas/Desktop/test-folder/.BC.T_hHCsH6: Operation not permitted
Of course, maybe this isn't about entitlements and just means I screwed up the util_shell function somehow. It works for other shell commands, though.
I'm guessing I'll probably need to write more complex code, that captures important metadata about the source file(s) and writes that out to the destination. Sounds like a big job, though. I shudder at the thought of recursing through an entire folder tree and accurately copying everything inside...
Thanks for your suggestions!