Importing CommonCrypto in a Swift framework

How do you import CommonCrypto in a Swift framework for iOS?

I understand how to use CommonCrypto in a Swift app:
You add #import <CommonCrypto/CommonCrypto.h> to the bridging header.
However, Swift frameworks don’t support bridging headers. The documentation says:

You can import external frameworks that have a pure Objective-C codebase, a pure Swift codebase, or a mixed-language codebase. The
process for importing an external framework is the same whether the
framework is written in a single language or contains files from both
languages. When you import an external framework, make sure the
Defines Module build setting for the framework you’re importing is set
to Yes.

You can import a framework into any Swift file within a different
target using the following syntax:

import FrameworkName

Unfortunately, import CommonCrypto doesn’t work. Neither does adding #import <CommonCrypto/CommonCrypto.h> to the umbrella header.

16 Answers

Leave a Comment