How to get CommonCrypto working with your own Xcode 8 / Swift 3.0 framework

  1. Prepare “CommonCrypto” folder containing modulemap files, CommonCrypto.xcconfig and Info.plist. You can grab it from here or create your own.
  2. Create a new Xcode project (cross-platform).
  3. Add targets for each platform you need.
  4. Under project settings Info tab set configuration for each target to CommonCrypto.xcconfig (for both Debug and Release).
  5. Under General tab for each target, you might want to check “Allow app extension API only” which will make sure that you can use the framework even in app extensions safely.
  6. Delete not needed folders in the project such as “CommonCrypto-iOS”, “CommonCrypto-watchOS”, “CommonCrypto-macOS” and “CommonCrypto-tvOS”. Also delete those folders from your filesystem under project directory. Everything you need is just “CommonCrypto” folder containing Info.plist, CommonCrypto.xcconfig and modulemap files.
  7. For each target, under Build settings search for “Product name” and replace what you see there with “CommonCrypto” (instead of “CommonCrypto-watchOS”, for example).
  8. For each target, under Build settings search for “Product Bundle identifier” and replace it to have the same bundle id for all targets. In my case, I replace (and so on) with
  9. For each target, under Build settings search for “Info.plist File” (for watchOS target you’ll have something like “CommonCrypto-watchOS/Info.plist” there), so replace it with “CommonCrypto/Info.plist”.
  10. Now, there are two possible ways to use it:

a) Add this CommonCrypto project as subproject into your parent swift framework;

b) Build binary for each target which produces CommonCrypto.framework for each platform, then copy those *.framework files with their parent folders into your parent project via dropping them to Xcode and applying “Copy items if needed” checkbox (unselect any target membership though). If you drop them without folders Xcode will not allow to do that because their names are equivalent.

Now, just use import CommonCrypto statement in your target swift classes, the underlying CommonCrypto C API is available now.

Note: no other settings in Xcode were adjusted, only the ones listed above.

Screenshots for reference

Create cross-platform project
Name it “CommonCrypto”
Here is how it looks like in the beginning (no targets, no folders)
Prepare “CommonCrypto” folder containing modulemap files, CommonCrypto.xcconfig and info.plist
Added CommonCrypto folder that was prepared previously
Adding watchOS target
Adding watchOS target


One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.