尝试在 Swift 中使用 ObjectiveC 代码时构建失败
Build fail when trying to use ObjectiveC code in Swift
我正在尝试使用来自另一个目标的 Objective-C 类之一,在我的扩展目标内的 Swift 类中。
我创建了<Project-Name>-Bridging-Header.h
并包含了那个 objective-c 文件,但由于 "Cryptor.h"
和 <CommonCrypto/CommonDigest.h>
中的构建错误,构建无法编译。我相信这与CommonCrypto框架有关。这是我的Bridging-Header.h的样子:
#import <UIKit/UIKit.h>
#import <FacebookSDK/FacebookSDK.h>
#import <GooglePlus/GooglePlus.h>
#import <Security/Security.h>
#import <CommonCrypto/CommonCrypto.h>
#import <CommonCrypto/CommonDigest.h>
我想这是由于通用加密库。有没有人遇到过同样的问题并解决了它?
编辑:具体来说,我收到构建错误 - CommonDigest.h 中的"缺少@end",并且因为 CommonDigest.h 没有获得构建,因此 Cryptor.h 中出现错误。
我不知道它是否能解决您的问题,但桥头有时有点问题。至少对我来说是这样。
尝试编辑标题并像这样导入文件:
#import "FacebookSDK.h"
#import "GooglePlus.h"
#import "Security.h"
#import "CommonCrypto.h"
#import "CommonDigest.h"
我已经删除了 UIKit-header,因为你并不真正需要它,因为 swift 有自己的 UIKit。
相关文章:
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 代码在main()中运行,但在函数中出现错误
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 编译包含字符串的代码时遇到问题
- 我在c++代码中生成了一个运行时#3异常
- 如何在linux终端中同时编译和运行c++代码
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 在Linux for Windows上编译C++代码时出错
- 我的字符计数代码计算错误.为什么
- 孤立代码块在结构中引发异常
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 此代码是否违反一个定义规则
- 为什么我的代码在输出中增加了93天
- 我的简单if-else语句是如何无法访问的代码
- 使用动态分配的数组会导致代码分析发出虚假的C6386缓冲区溢出警告
- 为什么在这个代码结束循环中没有得到结束
- 尝试在 Swift 中使用 ObjectiveC 代码时构建失败
- Qt转换为ObjectiveC代码