As we continue to push forward on completing swift-corelibs-foundation, I would like to propose a structural change to help us meet our goals: move
URLSession and related types into a new library.
Some of the feedback we've received from the SwiftNIO team is that Foundation's dependency on
libcurl brings in too many other libraries, some of which conflict with the ones that SwiftNIO needs to use. Additionally, we think it might be interesting to explore implementation of Foundation networking on top of SwiftNIO itself.
Therefore, I propose a moving the networking types (except
URLComponents) into another library, with a working name of
swift-corelibs-foundation-networking. This library could still be part of the same git repository on GitHub or we could create a new one.
This change means that there would be a clear dependency graph for the 3 projects:
swift-corelibs-foundation-networking | SwiftNIO | swift-corelibs-foundation
- SwiftNIO would be able to use core Foundation types. We are separately exploring improvements to types like
Datawith feedback from the SwiftNIO team.
swift-corelibs-foundation-networkingcould use SwiftPM to build itself. This is currently not possible for Foundation itself for a variety of dependency-related reasons.
- Other projects that wish to maintain a minimum set of dependencies and do not need networking support can reduce their footprint.
- A new
importstatement would be needed for source code which uses
URLSession. For example,
import FoundationNetworking. We would need to decide if it is acceptable to deviate from the Darwin platform here, or if we need to introduce some kind of compatibility shim there as well. On Darwin Foundation must continue to include
URLSessionfor source compatibility.
- Due to the above, moving
URLSessionmay introduce a source break for Linux clients.
- Restructuring the projects will involve work for build scripts and infrastructure changes to CI.
What are your thoughts?