NSFileManager.setUbiquitous fails with error 256: can't open file

I am trying to implement the functionality that Apple suggests to move application document files to/from iCloud containers and the local docs folder when iCloud is enabled/disabled. However, NSFileManager.setUbiquitous failed with an unhelpful error 256, which says something like:


Failed to move file:///Users/patrick/Documents/Test%20Case%201.fd to file:///Users/patrick/Library/Mobile%20Documents/iCloud~com


Permissions on the files are typical, I can read/write the files just fine with normal user rights.


The files in question are document packages with the extension

.fd
which have a registered UTI in my project. These document packages function properly in every other context of macOS system services (opening in finder, showing correct, icon, etc).

How can I fix this problem? This is supposed to be a simple call to setUbiquitous. Maybe document packages have to be handled differently?

NSFileManager.setUbiquitous fails with error 256: can't open file
 
 
Q