[swift-corelibs-dev] NSURLSession & libcurl

Daniel Eggert danieleggert at me.com
Wed Mar 23 06:07:46 CDT 2016

> On 14 Mar 2016, at 18:29, Robert Stephen Thompson <robert.thompson at willowtreeapps.com> wrote:
> Just a couple of tips based on my experience wrapping libxml2 for NSXMLDocument:
> 1. You’ll need to actually import and link libcurl with CoreFoundation instead of trying to make a libcurl module.modulemap and importing it directly. This is because if you do it that way, you’ll have to add libcurl as a dependency _throughout_ the Swift build process, and it would all be pretty disruptive (and difficult to do).
> 2. As a consequence of 1., you’ll need to wrap every function you call from libcurl in a new CoreFoundation API. See CFXMLInterface.h and CFXMLInterface.c for what I mean. Of course, this also gives you the opportunity to add nullability annotations, wrap things in CFString, CFError, CFArray, etc, so it’s not just busy-work for getting around the build system, heh. Just depends on how much C you want to write, you could just straight wrap the libcurl functions and do everything in Swift, but at the very least nullability annotations are a win here.

I just looked at this, and libxml2 is being linked against by SwiftFoundation, and NOT by CoreFoundation -- on Darwin.

Is the correct approach to do what's been done with libxml2, or should I instead have CoreFoundation link against libcurl?


More information about the swift-corelibs-dev mailing list