Where can I get CommonCrypto / CommonCrypto file from?
No additional files are required. You need a bridging header first of all, which you already have but for those who don't the easiest way to achieve this is to add an Objective-C file to your project and to accept when it offers to create a bridging header. You can then either import the whole of CommonCrypto (thanks @zaph - see comments) to the bridging header:
#import <CommonCrypto/CommonCrypto.h>
Or the constituent parts:
#import <CommonCrypto/CommonCryptor.h>
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonHMAC.h>
#import <CommonCrypto/CommonKeyDerivation.h>
#import <CommonCrypto/CommonSymmetricKeywrap.h>
You can now use CommonCrypto in Swift. For example code see here.
Edit
In Xcode 10 a bridging header is no longer required to import CommonCrypto in Swift. You can simply use:
import CommonCrypto
kimpro
Updated on June 09, 2022Comments
-
kimpro almost 2 years
I have a problem with importing
CommonCrypto/CommonCrypto
orCommonCrypto/CommonDigest
. I need a SHA256 for mySwift
code.I found
CommonCrypto
github site in Cocoapods.https://github.com/AlanQuatermain/aqtoolkit
So I have downloaded the file from above. But I'm getting errors about
ARC
(I have added Bridging-Header like other tutorials do.)
The header file's name isNSData+CommonCrypto.h
andNSData+CommonCrypto.m
.
It's not aCommonCrypto/CommonCrypto
orCommonCrypto/CommonDigest
Where can I download and get the exact fileCommonCrypto
for SHA256? -
m_katsifarakis over 5 yearsThis won't work for a framework target. The error returned is: "Include of non-modular header inside framework module '<your_module>'".
-
sketchyTech over 5 years@m_katsifarakis I don't know whether this helps but Xcode 10 makes CommonCrypto available for import in Swift without the need for a bridging header.
-
m_katsifarakis over 5 yearsYup, that's how I've done it too, but not all of my team can use it just yet.