As Apple introduced Swift, their new programming language, I wonder how you can integrate it with existing Objective-C libraries that are available via CocoaPods?
It seems that the process is similar to the one described in Mix and Match section of Using Swift with Cocoa and Objective-C documentation.
pod install
.Example-Bridging-Header.h
, and add it to the project.Objective-C Bridging Header
for your target:Now you can use your library, in that case, MKUnits, in your Swift file:
let kilograms = NSNumber.mass_kilogram(2)()
let pounds = NSNumber.mass_pound(10)()
let result = kilograms.add(pounds)
println(result)
More here: Integrating Cocoapods with a Swift project