Handle CryptoKit archiving error

Kevin ABRIOUX
Apr 26, 2022

In some case, during the creation of your application Archive, you can have this error:

No such module ‘CryptoKit’

This case can append when you are trying to target an old iOS version < iOS13.

Even if you are checking iOS 13 availability like #available(iOS 13, *) or @available(iOS 13, *), you can’t compile your application.

A simple solution is to use pre compilation operator, like #if canImport. With this operator, you can exclude CryptoKit from your application if it’s not available:

You have also to wrap your CryptoKit usage in order to prevent any issue during archiving, for example:

With this syntax, you can generate your archive, even if your device target does not have CryptoKit available

--

--