Import Objective-C Framework (CocoaPod) into Swift?
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:
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.