2

In Xcode, when I try to add the Objective C library Common Crypto via a bridging header file in a Swift framework (using #import <CommonCrypto/CommonCrypto.h>), I get an error saying that bridging headers aren't allowed when target is framework.

When I add it to the umbrella header file, I get this error: "Include of non-modular header inside framework module"

This link seems to the about the same problem: Importing CommonCrypto in a Swift framework

But the solutions there are very complex and seem to be too much for just including an Objective C library into a framework. Also there are some comments about the solution not working after some updates to Xcode and iOS. What is the best way to solve the issue? (The website would not let me comment on the above-mentioned link; so I had to post it as a separate question here.)

Community
  • 1
  • 1
user3664254
  • 163
  • 1
  • 7
  • I'm going to close this as a duplicate, but I have added an answer that is a bit simpler to implement. There is no simple answer to this question. It's a trade-off between robustness and simplicity. There won't be a good answer until Apple fixes the headers. http://stackoverflow.com/a/40362910/97337 – Rob Napier Nov 01 '16 at 15:11

1 Answers1

1
#import <CommonCrypto/CommonDigest.h>

In bridging header worked for me.

Juri Noga
  • 4,363
  • 7
  • 38
  • 51
  • Swift frameworks don't support bridging headers. Are you sure you tested this for a framework and not an app? – Rob Napier Nov 01 '16 at 14:52
  • Doing this you'll get the following error: `:0: error: using bridging headers with framework targets is unsupported` – j_gonfer May 09 '17 at 09:06