With the coming update, our iOS app is supposed to export data to a text file in the iCloud and to import data from it. The implementation is mostly completed and we started beta-testing. Everything seems to be working fine for all but one of the beta-testers.
What I gather from debugging output collected by the TestFlight API, one of the testers somehow managed to get the file into the UIDocumentStateSavingError
state. So far, we could not manage to pop the file out of that state no matter what we had him try.
This is what happens on the tester's device:
- iCloud access is successfully detected using
URLForUbiquityContainerIdentifier
. - An
NSMetadataQuery
is started to locate the file and returns exactly one result. - An subclass of
UIDocument
is created for the resulting URL usinginitWithFileURL:
. - The document is in the
UIDocumentStateSavingError
state. Also, this is the only state flag that is set. - The call to
openWithCompletionHandler:
returns failure to the handler andloadFromContents:ofType:error:
on theUIDocument
is not called.
We then made a new version of the app that continues as follows:
- The app tries to delete the erroneous file using
[[NSFileManager defaultManager] removeItemAtURL:doc.fileURL error:&err]
. - The resulting
NSError
indicates that "The operation couldn’t be completed. No such file or directory".
Deleting the file was about the last thing we could come up with in order to resolve the file's state. Any hints on how to solve this or on what might be causing the error in the first place would be very much appreciated!