Thanks for starting this discussion - I think if we get this right it has the potential to improve things a lot.
I am in favour of exploring reimplementing
URLSession on top of SwiftNIO, to remove the dependency on
I also like the idea of building Foundation using SwiftPM and using that to decouple Foundation releases from Swift itself.
I am concerned about the suggestion of making
import Foundation not include URLSession on Linux, though. Some bits of Darwin Foundation are not present on Linux and never will be (for good reasons), but having to do
import FoundationNetworking on Linux does cause the Darwin and Linux APIs to diverge even further, in a source-breaking way, as others have commented.
Could the layering look like this instead?
Then, SwiftNIO could
import FoundationCore so it can start using core types like
curl getting pulled in. Users who
import Foundation would get everything, like today, except the implementation of URLSession could use SwiftNIO for its implementation (the SwiftNIO API would not be exposed out of Foundation).
As Tony mentioned that it might be possible to add
FoundationNetworking as a dummy module on Darwin, perhaps it might be possible to add
FoundationCore on Darwin, so Darwin users can choose between
FoundationCore as well.