How to use CommonCrypto in iOS

Issue #480

Use modulemap

modulemap approach

I use modulemap in my wrapper around CommonCrypto https://github.com/onmyway133/arcane, https://github.com/onmyway133/Reindeer

For those getting header not found, please take a look https://github.com/onmyway133/Arcane/issues/4 or run xcode-select --install

  • Make a folder CCommonCrypto containing module.modulemap

        module CCommonCrypto {
          header "/usr/include/CommonCrypto/CommonCrypto.h"
          export *
        }
    
  • Go to Built Settings -> Import Paths

        ${SRCROOT}/Sources/CCommonCrypto
    

Cocoapods with modulemap approach

public header approach

Cocoapods with public header approach

text
          s.libraries        = "xml2"
          s.xcconfig         = { 'HEADER_SEARCH_PATHS' =>           '$(SDKROOT)/usr/include/libxml2', 'OTHER_LDFLAGS' => '-lxml2' }

šŸ Interesting related posts

CommonCrypto from Xcode 10

From Xcode 10, we can just

swift
import CommonCrypto

Code

Written by

I’m open source contributor, writer, speaker and product maker.

Start the conversation