Compile error without importing NIOFoundationCompat on Linux but not macOS

Hi All,

I am developing a simple HTTP client program for Linux using the async-http-client package from the server working group. I am able to build locally on macOS, but I was getting a compiler error in my CI pipeline build stage which uses the swift:5.10.1 Docker image.

I found a similar discussion here on the forum that mentioned needing NIOFoundationCompat, so I added an import for that and am now building successfully in the pipeline; although, some commenters in the linked post suggested this shouldn't be necessary. I was hoping someone here on the forum might help me understand why this occurred or direct me to some further reading.

Here is the now-resolved compiler error:

error: cannot convert value of type 'ByteBuffer' to expected argument type 'Data'
            let decodedResponse = try decoder.decode(MyResponseType.self, from: body)

Thanks!

Ok, I did further reading in the linked post and looked at swift-nio/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift which explains that NIO is kept independent from Foundation due to cross-platform issues between Linux and macOS.

I still don't understand why I am able to build on macOS without NIOFoundationCompat if this module is needed to convert ByteBuffer to Data.