I have a UGreen NAS. My app can read the contents of a folder on the NAS from macOS, but it cannot read the contents of a folder from iOS.
I bring up a UIDocumentPickerViewController(forOpeningContentTypes: [UTType.folder], asCopy: false).
I can pick a folder on the iPad’s internal storage, and successfully enumerate its contents. On the UGreen, I can pick a folder, but the content enumeration always returns zero items (no errors).
Enumeration of the UGreen works from macOS. It also works on the iPad when connecting to a Mac mini, or a Synology NAS. .
Files.app is able to view the UGreen folder and its contents. Oddly, my app cannot enumerate the contents, but it IS able to write a file to that UGreen folder.
Since Files.app can enumerate and I can write to the UGreen folder (and I can enumerate contents on other servers) - how can I get the enumeration to work? Feedback is FB22955130
I can pick a folder on the iPad’s internal storage, and successfully enumerate its contents. On the UGreen, I can pick a folder, but the content enumeration always returns zero items (no errors).
So, based on what you've described, this sounds like a known (r.150542999) and fairly weird bug which I mentioned here.
In any case, the basic behavior was exactly what you've described (enumeration returns an empty directory), however, the odd part is that it ONLY did so on the first enumeration attempt. That is, enumerator(at:) returned an empty enumerator but if you then immediately tried again, it succeeded.
Note that I DON'T mean presenting the document picker again, I just mean directly retrieving the contents of the directory again. In terms of your code, doing something like this;
do {
let contents = try fileManager.contentsOfDirectory(at: url, includingPropertiesForKeys: nil)
let contents2 = try fileManager.contentsOfDirectory(at: url, includingPropertiesForKeys: nil)
self.numberOfFilesLabel.text = "\(contents.count):\(contents2.count) items found"
}
Assuming it the issue above, then you'll get something like:
0:<#> items found
Please test with the retry above and let me know what you find.
Finally, it's still unclear what exactly is causing this issue. When I originally reproduced the issue in late iOS 18 it was specifically happening when macOS was presenting an external USB device over USB, but when I tested today I could not reproduce the issue. My guess is there is an underlying factor which ultimately triggers the issue, but at this point we haven't identified it.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware