Applying this immediately after copying the file resolves the issue:
var attributes = try FileManager.default.attributesOfItem(atPath: temporaryItemURL.path)
attributes[FileAttributeKey.immutable] = false
try FileManager.default.setAttributes(attributes, ofItemAtPath: temporaryItemURL.path)
That said, it might be better to preserve the original attributes and only modify them right before deleting the file, as you demonstrated. This approach would also address the issue for files that were copied previously.
Thank you for your help, Kevin!
Topic:
App & System Services
SubTopic:
Core OS
Tags: