我在导入CommonCrypto/CommonCrypto或CommonCrypto/CommonDigest时遇到问题。我的Swift代码需要一个SHA256。
我在Cocoapods中找到了CommonCrypto github站点。
https://github.com/AlanQuatermain/aqtoolkit
所以我已经从上面下载了这个文件。但是我得到了关于ARC的错误(我像其他教程一样添加了桥头)。
头文件的名称是NSData+CommonCrypto.h和NSData+CommonCrypto.m。
它不是CommonCrypto/CommonCrypto或CommonCrypto/CommonDigest,我可以从哪里下载并获得SHA256的确切文件CommonCrypto?
发布于 2016-07-26 19:19:26
不需要额外的文件。你首先需要一个bridging header,你已经有了,但是对于那些不需要的人来说,最简单的方法是向你的项目添加一个Objective-C文件,并在它提供创建桥接头的时候接受它。然后,您可以将整个CommonCrypto (感谢@zaph -请参阅注释)导入到桥接头:
#import <CommonCrypto/CommonCrypto.h>或组成部分:
#import <CommonCrypto/CommonCryptor.h>
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonHMAC.h>
#import <CommonCrypto/CommonKeyDerivation.h>
#import <CommonCrypto/CommonSymmetricKeywrap.h>您现在可以在Swift中使用CommonCrypto。例如代码see here。
编辑
在Xcode10中,在Swift中导入CommonCrypto不再需要桥接头。您可以简单地使用:
import CommonCrypto发布于 2018-05-03 16:51:34
实际上,您不需要使用CommonCrypto编译任何文件,只需将其导入到您的项目中。
或者在Swift中使用一些包装器,就像https://github.com/soffes/Crypto一样
让我们回到CommonCrypto文件,苹果已经用https://opensource.apple.com/source/发布了它的源代码
https://stackoverflow.com/questions/38584416
复制相似问题