3

How to import the Obj-C CommonCrypto library to an existing Swift Xcode Project (Swift 3, Xcode 8.3.3)?

I tried to create my own Objective-C bridging file and it wasn't working.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Alec
  • 666
  • 8
  • 23

1 Answers1

14

I know there are similar questions on stackoverflow about this but I looked at them and still had problems so I wanted to share my experiences.

Easiest way to import the Obj-C CommonCrypto library to an existing Swift XCode Project (Swift 3, Xcode 8.3.3):

  1. Add a new file of type "Objective-C file". It doesn't matter what you call it, you will delete it in a moment.
  2. After you add that file Xcode should prompt you if you want to create a bridging header. Check the appropriate targets for you project and allow Xcode to create the bridging header for you.
  3. Add #import < CommonCrypto/CommonCrypto.h > to the bridging header(s) it creates.
  4. Delete the Objective-C file you created in step 1.

I tried to create my own Objective-C bridging file and it wasn't working. I spent about an hour looking for solutions until I tried this. I wanted to share to hopefully spare other developers the issue I had.

Alec
  • 666
  • 8
  • 23