[swift-corelibs-dev] NSURLSession & libcurl

Philippe Hausler phausler at apple.com
Wed Mar 23 08:44:19 CDT 2016

The swift-corelibs-foundation version of CF is a static library that is being built into the Foundation product dynamic library so the linkage for libxml2 and anything else should be on that.

The layout of how linking works for the Darwin version is different because of how we split the layers. NSXMLParser is based on libxml2 in objc. It just does not need a CF abstraction/thunks to convert types.

Sent from my iPhone

> On Mar 23, 2016, at 4:07 AM, Daniel Eggert via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
>> 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?
> /Daniel
> _______________________________________________
> swift-corelibs-dev mailing list
> swift-corelibs-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

More information about the swift-corelibs-dev mailing list