我已经通过 CocoaPods
安装了 Card.IO
。我的工作区看起来设置正确,我看到了 Card.IO
Objective-C
头文件,但是,在我的主要 Swift
项目中,我尝试引用任何 Card.IO
类 - 我收到未解析的标识符错误。
编辑 我的理解是 Xcode
找不到桥接头:
#import "CardIO.h"
@import AudioToolbox;
@import AVFoundation;
@import CoreMedia;
@import CoreVideo;
@import MobileCoreServices;
文档说明
In Build Settings, in Swift Compiler - Code Generation, make sure the Objective-C Bridging Header build setting under has a path to the bridging header file. The path should be relative to your project, similar to the way your Info.plist path is specified in Build Settings. In most cases, you should not need to modify this setting.
这对我来说没有意义 - 所以不确定路径放在哪里?我已将以下内容添加到 Build Settings > Search Paths > Header Search Paths > Debug & Release
MyApp/MyApp-Bridging-Header.h
但这似乎是不正确的?
最佳答案
在这里找到答案
https://bohemianpolymorph.wordpress.com/2014/07/11/manually-adding-a-swift-bridging-header/
In your project build settings, find Swift Compiler – Code Generation, and next to Objective-C Bridging Header add the path to your bridging header file, from the project’s root folder. So it could by MyProject/MyProject-Bridging-Header.h or simply MyProject-Bridging-Header.h if the file lives in the project root folder.
关于Obj-C 的 Swift 桥接头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33862259/