Replace import Foundation with FoundationEssentials#897
Replace import Foundation with FoundationEssentials#897madsodgaard wants to merge 14 commits intoswift-server:mainfrom
import Foundation with FoundationEssentials#897Conversation
|
One option could be to vendor / copy the percent encoding from |
|
@t089 Yeah, that is similar to what I did for |
|
Feels like we should create a swift-percent-encoding nano package ... if only there was a package that could host such foundational essentials ... |
Package.swift
Outdated
| .product(name: "NIOHTTPCompression", package: "swift-nio-extras"), | ||
| .product(name: "NIOSOCKS", package: "swift-nio-extras"), | ||
| .product(name: "NIOTransportServices", package: "swift-nio-transport-services"), | ||
| .product(name: "NIOTransportServices", package: "swift-nio-transport-services", condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .macCatalyst, .visionOS])), |
There was a problem hiding this comment.
I think this is a breaking change, weirdly. The transitive import is safe on all platforms: NIOTS should completely become empty on all non-Apple platforms. If it doesn't, we should fix that.
There was a problem hiding this comment.
The issue is that even though I have guarded the "import NIOTransportServices" behind #canImport(Network), I am still seeing symbols from Foundation being linked. Which is because NIOTransportServices depend on NIOFoundationCompat
root@53b151c5ecbb:/workspace/Tests/LinkageTest/.build/aarch64-unknown-linux-gnu/debug# nm -u linkageTest | swift demangle | grep "Foundation"
U static Foundation.JSONSerialization.jsonObject(with: FoundationEssentials.Data, options: Foundation.JSONSerialization.ReadingOptions) throws -> Any
U type metadata for Foundation.JSONSerialization.ReadingOptions
U protocol conformance descriptor for Foundation.JSONSerialization.ReadingOptions : Swift.SetAlgebra in Foundation
U type metadata accessor for Foundation.JSONSerialization
U Foundation.RunLoop.run(mode: Foundation.RunLoop.Mode, before: FoundationEssentials.Date) -> Swift.Bool
U Foundation.RunLoop.Mode.default.unsafeMutableAddressor : Foundation.RunLoop.Mode
U static Foundation.RunLoop.current.getter : Foundation.RunLoop
U type metadata accessor for Foundation.RunLoop
There was a problem hiding this comment.
I think then we should fix NIOTS first, shouldn't we?
There was a problem hiding this comment.
Is there any un-guarded import of NIOFoundationCompat there? If there is we should fix that.
There was a problem hiding this comment.
No, there does not seem to be.
There was a problem hiding this comment.
Ugh gross. Ok, this is probably acceptable.
There was a problem hiding this comment.
yeah, I don't quite understand why its leaking still...
|
Unfortunately the |
Replaces all the foundation imports.
One issue is that
HTTPClient.init?(httpsURLWithSocketPath socketPath: String, uri: String = "/")usesaddingPercentEncoding()from Foundation. So instead, we use a pure Swift impl. that does the same.We also need to disable default traits from
swift-configurationto prevent linking Foundation, because theJSONtrait does that.This also adds a linkage test to prevent regressions to CI.