       }
       logger.debug("created NIOTSEventLoopGroup for \(networkPreference) preference")
       return NIOTSEventLoopGroup(loopCount: loopCount)
-    #endif
+      #else
+      fatalError(".networkFramework is being used on an unsupported platform")
+      #endif
     case .posix:
       logger.debug("created MultiThreadedEventLoopGroup for \(networkPreference) preference")
       return MultiThreadedEventLoopGroup(numberOfThreads: loopCount)

  /// - `@available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *)`, or
  /// - `#available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *)`.
  public var implementation: NetworkImplementation {
    switch self {
    case .best:
      #if canImport(Network)
      guard #available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *) else {

import Logging

/// How a network implementation should be chosen.
public struct NetworkPreference: Hashable {
  private enum Wrapped: Hashable {
    case best
    case userDefined(NetworkImplementation)
  }

  private var wrapped: Wrapped
  private init(_ wrapped: Wrapped) {
    self.wrapped = wrapped
  }

  /// Use the best available, that is, Network.framework (and NIOTransportServices) when it is
  /// available on Darwin platforms (macOS 10.14+, iOS 12.0+, tvOS 12.0+, watchOS 6.0+), and
  /// falling back to the POSIX network model otherwise.
  public static let best = NetworkPreference(.best)

  /// Use the given implementation. Doing so may require additional availability checks depending
  /// on the implementation.
  public static func userDefined(_ implementation: NetworkImplementation) -> NetworkPreference {
    return NetworkPreference(.userDefined(implementation))
  }
}

/// The network implementation to use: POSIX sockets or Network.framework. This also determines
/// which variant of NIO to use; NIO or NIOTransportServices, respectively.
public struct NetworkImplementation: Hashable {
  fileprivate enum Wrapped: Hashable {
    case networkFramework
    case posix
  }

  fileprivate var wrapped: Wrapped
  private init(_ wrapped: Wrapped) {
    self.wrapped = wrapped
  }

  #if canImport(Network)
  /// Network.framework (NIOTransportServices).
  @available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *)
  public static let networkFramework = NetworkImplementation(.networkFramework)
  #endif

  /// POSIX (NIO).
  public static let posix = NetworkImplementation(.posix)
}

extension NetworkPreference {
