9

I'm trying to import the libjingle_peerconnection framework into my Xcode project, but for some reason I can't import the Objective-C header with import RTCICEServer in Swift source files. I have attempted to use header files, etc. What am I doing wrong?

# 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

enter image description here

SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
LeviXC
  • 1,075
  • 2
  • 15
  • 32
  • Yup I am. libjingle_peerconnection is Objective-C if that helps. – LeviXC Jan 02 '16 at 04:41
  • I have not; I had to put it down, work is crazy busy right now. I'll come back to it when I can. Likely going to fall back to Objective-C. – LeviXC Jan 13 '16 at 05:05

1 Answers1

10

Bridge

1. Create a xxx-Bridging-Header

Add a bridging header to your project using the method of your choice, the easiest one being creating a single .m file and answering Create Bridging Header to this dialog:

Create Bridging Header

2. Reference your Pod in the bridging header

Include your files as so:

//
//  Use this file to import your target's public headers that
// you would like to expose to Swift.

#import "RTCICEServer.h"

3. Objective-C exposed to Swift

Once in the bridging header, you need not import the Obj-C classes in Swift. Use these directly:

let uri = URL(fileURLWithPath: "")
let rtc:RTCICEServer = RTCICEServer(uri: uri, username: "", password: "")
print(rtc)

Another example is described here.


► Find this solution on GitHub and additional details on Swift Recipes.

Community
  • 1
  • 1
SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
  • but the correct way is to import the module name (import xxxx) of the pod inside the swift file without having to create a bridging header as long as the pod file has the use_frameworks enabled, I believe there is something wrong with libjingle_peerconnection pod – JAHelia Jan 31 '18 at 06:11