CryptoKitError

Hi,

I am using CryptoKit in my app. I am getting an error sometimes with some users. I log the description to Firebase but I am not sure what is it exactly about.

 CryptoKit.CryptoKitError error 2 

 CryptoKit.CryptoKitError error 3

I receive both of these errors. I also save debug prints to a log file and let users share them with me. Logs are line-by-line encrypted but after getting these errors in the app also decryption of log files doesn't work and it throws these errors too.

I couldn't reproduce the same error by myself, and I can't reach the user's logs so I am a little blind about what triggers this.

It would be helpful to understand what these errors mean.

Thanks

Answered by DTS Engineer in 745126022

CryptoKitError is documented here. The docs don’t include the error codes but that’s easy enough to work out with a little code:

import Foundation
import CryptoKit

print((CryptoKitError.incorrectParameterSize as NSError).code)  // 2
print((CryptoKitError.authenticationFailure as NSError).code)   // 3

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

CryptoKitError is documented here. The docs don’t include the error codes but that’s easy enough to work out with a little code:

import Foundation
import CryptoKit

print((CryptoKitError.incorrectParameterSize as NSError).code)  // 2
print((CryptoKitError.authenticationFailure as NSError).code)   // 3

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hey Eskimo, do you know why that information is not on the documentation ? And why nobody is adding it ?

Apple's doc was never the best, but it feels like there's not a lot going on towards better doc for a better developer experience.

do you know why that information is not on the documentation ?

The documentation for most frameworks is generated from the framework’s interface using DocC, and for frameworks implemented in Swift the interface doesn’t contain enum values.

This isn’t a new thing. For example, in Objective-C error domains were traditionally declared like so:

extern NSString * NSSomeErrorDomain;

and so there was no way to work out the actual string you’d see when you logged the error. Swift has just extended this to the error codes.

Making this available in the docs is an interesting ideas. It has obvious utility, but there are obvious drawbacks too, and also implementation challenges. My advice is that you make your case in an enhancement request.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

CryptoKitError
 
 
Q