CKError
encountered to the user in the app as an alert. Looks like there is another error in the errorUserInfo[NSUnderlyingError]. Try getting the localizedDescription from that error.
So, that would be:
((error as? CKError)?.errorUserInfo[NSUnderlyingErrorKey] as? NSError)?.localizedDescription
The error.localizedDescription
is really all you have to work with from the error itself.
Your app can provide a better error message (more user-friendly, localized, etc.) by checking for the error code and providing its own message to the user.
(error as? NSError)?.code