Swift Obj-C 的桥接头
Swift Bridging Header for Obj-C
我已经通过 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.
我已经通过 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.