Capacitor filesystem readdir fails to read/write ios directory

Hi community, new Capacitor user here.

Our team are trying to deploy our Clojurescript project to iOS/Android platform by using Capacitor. Basically we are implementing a simple FoldPicker to get the url of the mobile directory, and read/write content from the directory to our app.

By following the instruction, we made our Android app by using @capacitor/filesystem, and it works pretty well. But the iOS app fails to read from and write to the directory. The full path of directory is like file:///private/var/mobile/Mobile Documents/com~apple~CloudDocs/demo/, Filesytem,readdir({:path "file:///private/var/mobile/Mobile Documents/com~apple~CloudDocs/demo/" returns nothing. There might be some platform specific issues we are not taking good care of. Would you guys please give me some help for resolving this issue?

If someone needs the codes, you can find it at logseq/ios at master · logseq/logseq · GitHub.
and the IO codes are at logseq/capacitor_fs.cljs at 425f688082c9e463031faf23c7da3f35e74c2b11 · logseq/logseq · GitHub.

Greatly appreciated if anyone could offer help.

If you try reading a file that isn’t in the the /private/var directory, do you get results? Does it make a difference if you test on the simulator or on a physical device? Typically /private/var and /var are a bit locked down on Apple devices; but I’m not 100% sure if you can read or write.

We recommend writing to Directory.DOCUMENTS for user-generated content in our docs since that is what Apple recommends and has the most flexibility reading/writing files.

Also, not sure if this would help…but if you open this folder ~/Library/Developer/CoreSimulator/Devices, navigate to your Device ID, you can see what is stored on your simulator when testing. Hopefully, this can help you debug file I/O a bit!