[swift-users] How to bridge between CoreFoundation and SwiftFoundation on Linux?

Bouke Haarsma bouke at haarsma.eu
Tue Sep 20 23:38:54 CDT 2016


Hi all,

When working with CoreFoundation objects (e.g. CFReadStream, 
CFWriteStream) it isn't immediately obvious to me how to bridge them to 
SwiftFoundation counterparts (InputStream / OutputStream).

The following works on OSX, but doesn't work on Linux;

    let readStream: CFReadStream = ...
    readStream as InputStream
    // error: cannot convert value of type 'CFReadStream' to expected 
argument type 'InputStream'

In some other places I need to bridge a String to a CFString, the 
following works on OSX, but doesn't work on Linux;

    let string: String = ...
    string as CFString
    // error: error: 'String' is not convertible to 'CFString'; did you 
mean to use 'as!' to force downcast?

Thanks.

-- 
-Bouke




More information about the swift-users mailing list