There appears to be a data loss bug in NSFileWrapper on macOS 26.4. It may have been around longer but I just never noticed ...
So I write a RTFD file wrapper:
NSFileWrapper *rtfd = [attributedString RTFDFileWrapperFromRange:NSMakeRange(0, attributedString.length) documentAttributes:@{NSDocumentTypeDocumentAttribute:NSRTFDTextDocumentType}];
Now IF I use -writeToURL:options:originalContentsURL:error: without using the NSFileWrapperWritingAtomic option and I pass in an existing URL, the followings happens:
-The method returns NO and populates the NSError with NSFileWriteFileExistsError, as expected. This is what I want.
-BUT the existing file is nuked. It just disappears. Foundation kills it. Poof.
Another thing I gotta workaround. Getting pretty ridiculous, I must say. Just my lucky day I guess. It would be wonderful if I could work on my own features and fixing my own bugs.