Unfortunately it seems like coordinateWritingItemAtURL:options:error:byAccessor: suffers from the same issue and calls, but coordinateReadingItemAtURL:options:error:byAccessor: does actually work. It's a bit annoying because it complicates both updating files and syncing multiple files (e.g. bundle-based formats), but it is something I can work around. It's very unfortunate that it's indeed a bug and not some API-misuse, because it seems to affect at least iOS 15 and up, and I'm targeting iOS 13-18.
Thanks for your help!
Post
Replies
Boosts
Views
Activity
Any update on this? I can't add iCloud support to my app without being able to safely download and sync files.
Note that I use a writing intent because I sometimes need to update some of these files, but using a reading intent instead does not solve the issue.
I first obtain the directory listing with NSMetadataQuery, which works fine. Once the query is done, I great an array of intents like this:
for (NSMetadataItem *item in query.results) {
NSURL *itemURL = [item valueForAttribute:NSMetadataItemURLKey];
if (![allowedExtensions containsObject:itemURL.pathExtension.lowercaseString]) {
continue;
}
NSFileAccessIntent *intent = [NSFileAccessIntent writingIntentWithURL:itemURL
options:0];
[intents addObject:intent];
}
Then, after stoping the query and removing the notification observer for it, I create a coordinator with the intents array I created and use it:
NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];
[coordinator coordinateAccessWithIntents:intents
queue:queue
byAccessor:^(NSError *error) {
// This gets called with error = nil in Airplane Mode
for (NSFileAccessIntent *intent in intents) {
// Sometimes, the file at intent.URL does not exist!
}
}];
Long-press and Share seems to work for most users even with this conflict, although some still have this problem. However, if my app uses UIDocumentPickerViewController with my UTI type, it can't select any file if another app "snatched" the extension first. I can use UTTypeCreatePreferredIdentifierForTag to dynamically obtain the effective UTI for the extension, but then I have this problem where apps erroneously declare a single UTI with multiple, unrelated extensions, which UIDocumentPickerViewController to select files I don't even support. Even when I use the newer UTType API, I can't seem to get any UTType that works just for my file extension.
My app, which isn't particularly large, has been in review for almost 6 days with not sign of progress. That's almost 3 times more than "90% of the apps". Other people I asked about the review process also complained about exceptionally long review times. I'm under the impression that the estimate in this FAQ collection has no basis in reality.