My iOS app crashes in production at UIDocument.revert(toContentsOf url: URL,
completionHandler: ((Bool) -> Void)? = nil)
. From the error message, it looks as if the document is supposed to be reverted to itself. For example:
**** Terminating app due to uncaught exception
'NSInternalInconsistencyException',
reason: 'attempt to revert document at URL (
file:///private/var/mobile/Library/Mobile%20Documents/
iCloud~com~myapp/Documents/sampledocument.test)
to URL (
file:///private/var/mobile/Library/Mobile%20Documents/
iCloud~com~myapp/Documents/sampledocument.test)
that is not yet open'
I don't have any specific code to revert the document version and I have not been able to reproduce this myself, but it happens for a number of users.
What would be a scenario where UIDocument would try to revert its contents and why would it try to revert the same file to itself?
Could this be a race condition where the document is closed, but for some reason tries to discard changes?