diff --git a/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift b/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift index 7aedfb17b0..0b32aa2c92 100644 --- a/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift +++ b/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift @@ -12,9 +12,14 @@ // //===----------------------------------------------------------------------===// -import Foundation import NIOCore +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif + /// Errors that may be thrown by ByteBuffer methods that call into Foundation. public enum ByteBufferFoundationError: Error { /// Attempting to encode the given string failed. diff --git a/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift b/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift index 0f61ad0ae1..1edd07d007 100644 --- a/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift +++ b/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift @@ -12,9 +12,14 @@ // //===----------------------------------------------------------------------===// -import Foundation import NIOCore +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif + extension ByteBuffer { /// Attempts to decode the `length` bytes from `index` using the `JSONDecoder` `decoder` as `T`. /// diff --git a/Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift b/Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift index d8f00438ca..da97f7f1c9 100644 --- a/Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift +++ b/Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift @@ -12,9 +12,14 @@ // //===----------------------------------------------------------------------===// -import Foundation import NIOCore +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif + extension JSONSerialization { /// Attempts to derive a Foundation object from a ByteBuffer and return it as `T`.