Can I add metadata to files in iCloud Drive and read it offline?

I came across a variant of the same issue while developing very different apps: I want to associate some custom metadata with files in the iCloud Drive and be able to read it while the files are offline.

So far I have tried two ways of doing this, but neither seemed to work: I tried adding extended attributes to the files, but it seems they are not stored offline like some other metadata.
I also tried storing the metadata in a CloudKit backed Core Data store. This way the metadata would always be available, I would just have to reference the file from the CoreData database somehow. However, I could not find an identifier that is unique to the file, identical over different devices, accessible while the file is not downloaded and independent of the location of the file (I want the user to be able to move files around freely).

Does anyone know how this problem could be solved? :) I basically just want to know a few custom things about offline iCloud files.

Thanks!


Can I add metadata to files in iCloud Drive and read it offline?
 
 
Q