我正在构建一个混合语言框架。我主要有Swift文件和一些Objective-C文件。
其中一个Objective-C文件是使用CommonCrypto的加密类。
似乎我出于某种原因无法导入它,即使我可以在Objective-C框架中导入它。
有人能解释一下为什么会这样吗?
当我需要在Swift框架中的Objective-C中使用它时,我发现的所有其他解决方案都讨论了如何在Swift中使用CommonCrypto。
P.S:
我尝试在伞头文件中添加导入,如下所示:
#import <CommonCrypto/CommonCrypto.h>
错误:Include of non-modular header inside framework module 'name of header'
此答案无法解决问题:answer
答案 0 :(得分:3)
我自己也遇到过这个问题。以下是解决问题的方法:
null
标题。object CustomProtocol {
val gen0 = cachedImplicit[LabelledGeneric[Color]]
implicit val colorLabel: LabelledGeneric.Aux[Color, gen0.Repr] = gen0
}
。这应该允许您在任何地方使用CommonCrypto.h
(用于Swift ,而非Objective-C)。
编辑:似乎我最初误读了这个问题。您想在Objective-C中使用CommonCrypto,然后使用Swift中的CommonCrypto。这里有一些建议:不要在公共标题中CommonCrypto
CommonCrypto,而是在内部。包装所有的加密结构,以便CommonCrypto没有任何公共依赖,然后通过默认的桥接过程从Swift中使用它。