Re:Introducing Swift
by seanalltogether on Monday June 02, 2014 @03:05PM
(#7835271)
He mentioned the desire to drop the "C" from objective-c, but I'm curious what this means for using c/c++ libraries now. Do they need to be wrapped by objective-c before being visible in swift?
[ Parent
| on HN ]
Swift uses a special "bridging header" to expose Objective-C code to Swift. This header will presumably be processed by the Swift compiler.
In the other direction, XCode will automatically generate an Objective-C header to expose your Swift code to Objective-C.
Re:Introducing Swift
by outworlder on Monday June 02, 2014 @04:18PM
(#7836039)
The ibooks guide references a "Using Swift with Cocoa and Objective-C" document. Is that where you got your information?
Re:Introducing Swift
by eevilspock on Monday June 02, 2014 @08:35PM
(#7837461)
Re:Introducing Swift
by FreezerburnV on Monday June 02, 2014 @03:08PM
(#7835317)
It seemed like it could interoperate with C just fine based on the slide talking about all three. Also because it uses the Objective-C runtime and compiles to native, it might just see C functions as normal functions. Though what little I've looked at the free book hasn't given me any hints about that yet.
"You cannot import C++ code directly into Swift. Instead, create an Objective-C or C wrapper for C++ code."
I suspect that as long as it compiles to LLVM, anything goes.