Unable to import CommonCrypto in mixed language environment

I am creating a mixed language structure. I mainly have Swift files and several Objective-C.

One of the Objective-C files is a cryptoclass that uses CommonCrypto.

It seems like I cannot import it for any reason, although I can import it into the Objective-C framework.

Can someone explain to me why this is?

All the other solutions that I have found talk about how to use CommonCrypto in Swift, when I need to use it in Objective-C in a Swift environment.

PS:

  • I tried adding import to the umbrella header file as follows: #import <CommonCrypto/CommonCrypto.h> error:Include of non-modular header inside framework module 'name of header'

  • This answer did not fix the problem: answer

+4
source share
1 answer

I myself ran into this problem. Here's how you resolve it:

  • Create a module map file ( here is my file ).
  • Copy the last title CommonCrypto.h.
  • Create a directory CommonCryptofor both of these files.
  • Copy the directory (via drag and drop) into your project.
  • Add the directory path to SWIFT_INCLUDE_PATHS for the target environment.

This should allow you to use it import CommonCryptowherever you want ( for Swift , not Objective-C).

: , . CommonCrypto Objective-C, Swift. : #import CommonCrypto , . , CommonCrypto, Swift .

+3

All Articles