apple / swift-http-types

Version-independent HTTP currency types for Swift
Apache License 2.0
894 stars 47 forks source link

Fix package not building for WASI #41

Closed MaxDesiatov closed 9 months ago

MaxDesiatov commented 9 months ago

This package currently doesn't build for WASI, as it refers to platform-specific types like URLSession, URLRequest, and URLResponse types not guarded by OS checks. With these new checks the package builds for wasm32-unknown-wasi triple successfully.

guoye-zhang commented 9 months ago

@swift-ci test

guoye-zhang commented 9 months ago

Can we make HTTPTypesFoundation module completely unavailable on WASI?

MaxDesiatov commented 9 months ago

Even though URLSession is not available on WASI, HTTPRequest is. One would be able to pass that type to some other HTTP client that's not URLSession. Hence there's still value in keeping that extension on HTTPRequest available.

Additionally, there's no clean way to exclude a single platform from a given package graph in SwiftPM. Until something like https://github.com/apple/swift-package-manager/pull/7084 is merged, we can't reliably enumerate all platforms and exclude WASI from that list. You'd have to update Package.swift every time a new supported platform is added to SwiftPM.

MaxDesiatov commented 8 months ago

@guoye-zhang would it be possible to tag a new patch release with this change? Thank you!

guoye-zhang commented 8 months ago

Sure, just waiting for one more change

MaxDesiatov commented 8 months ago

Thank you, much appreciated!