Is CoreML model encryption backwards compatible?

I tried out the CoreML Model Encryption feature that comes with Xcode 12.

I generated the key and added the --encrypt compiler flag as described in the docs.

Everything works on iOS 14. However on an iOS 13 simulator I get a runtime error saying
Code Block
MLModelAsset: load failed with error Error Domain=com.apple.CoreML Code=3 "No known class for loading model type INVALID" UserInfo={NSLocalizedDescription=No known class for loading model type INVALID}
So iOS 13 can't handle the encrypted model and says it's invalid, which makes sense I guess. But how are we supposed to maintain backwards-compatibility to iOS 13?

(As expected the error goes away if I remove the --encrypt compiler flag again.)

I want to add that I did NOT use the new async API to load the model, but instead the automatically generated wrapper class from my local model and it's init method.

Replies

Use the newly released load method


and I guess model encryption is only for iOS 14 and above

see WWDC tutorial on coreml model deployment and encryption it will help u a lot


gave a nice day.