我正在尝试将libjingle_peerconnection
框架导入到我的Xcode项目中,但出于某种原因,我无法在Swift源文件中导入带有import RTCICEServer
的Objective-C标头。我试图使用头文件等。我做错了什么?
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'VideoRTCTest' do
pod "libjingle_peerconnection"
end
target 'VideoRTCTestTests' do
end
target 'VideoRTCTestUITests' do
end
答案 0 :(得分:9)
<强> 1。创建xxx-Bridging-Header
使用您选择的方法为项目添加桥接标头,最简单的方法是创建单个<img/>
文件并在此对话框中回答创建桥接标题:
<强> 2。在桥接标题中引用您的Pod
包含您的文件:
.m
第3。 Objective-C暴露于Swift
一旦进入桥接头,就不需要在Swift中导入Obj-C类。直接使用这些:
//
// Use this file to import your target's public headers that
// you would like to expose to Swift.
#import "RTCICEServer.h"
另一个例子是here。
►在GitHub上找到此解决方案,并在Swift Recipes上找到其他详细信息。