On Linux, I get a swift compiler error when passing a ByteBuffer variable (body
in the below snippet) as a function’s Data parameter; however, this builds successfully on macOS.
error: cannot convert value of type 'ByteBuffer' to expected argument type 'Data'
let decodedResponse = try decoder.decode(MyResponseType.self, from: body)
After further reading on the swift forum, it seems there is cross-platform issues with the Foundation library on macOS and Linux, so swift-nio is kept independent from Foundation. There is a library within swift-nio called NIOFoundationCompat that extends ByteBuffer with the capability to convert to the Data type.
So, I am now able to build my Linux code successfully, but I would still like to understand why my macOS code builds correctly without importing NIOFoundationCompat.