Browse Source

Fix watchOS availability guard for Network.framework TLS (#1233)

Motivation:

In #1221 we added Network.framework as a provider for TLS. However in a
few places we incorrectly set the availability for watchOS as 5.0. It
should be 6.0 (as required by NIOTS).

If the watchOS deployment target was set to 5.0 then the build would
result in a number of errors (as the availability requirements for using
various NIOTS types would not be sufficient).

Modifications:

- Raise the availability version for various APIs which use Network.framework

Result:

No build errors for types which aren't availabile on watchOS 5.0.
George Barnett 4 years ago
parent
commit
1553d743fa

+ 4 - 4
Sources/GRPC/GRPCChannel/GRPCChannelBuilder.swift

@@ -42,7 +42,7 @@ extension ClientConnection {
   ///
   ///
   /// gRPC Swift offers two TLS 'backends'. The 'NIOSSL' backend is available on Darwin and Linux
   /// gRPC Swift offers two TLS 'backends'. The 'NIOSSL' backend is available on Darwin and Linux
   /// platforms and delegates to SwiftNIO SSL. On recent Darwin platforms (macOS 10.14+, iOS 12+,
   /// platforms and delegates to SwiftNIO SSL. On recent Darwin platforms (macOS 10.14+, iOS 12+,
-  /// tvOS 12+, and watchOS 5+) the 'Network.framework' backend is available. The two backends have
+  /// tvOS 12+, and watchOS 6+) the 'Network.framework' backend is available. The two backends have
   /// a number of incompatible configuration options and users are responsible for selecting the
   /// a number of incompatible configuration options and users are responsible for selecting the
   /// appropriate APIs. The TLS configuration options on the builder document which backends they
   /// appropriate APIs. The TLS configuration options on the builder document which backends they
   /// support.
   /// support.
@@ -85,7 +85,7 @@ extension ClientConnection {
   ///
   ///
   /// - Parameter group: The `EventLoopGroup` use for the connection.
   /// - Parameter group: The `EventLoopGroup` use for the connection.
   /// - Returns: A builder for a connection using the Network.framework TLS backend.
   /// - Returns: A builder for a connection using the Network.framework TLS backend.
-  @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+  @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
   public static func usingTLSBackedByNetworkFramework(
   public static func usingTLSBackedByNetworkFramework(
     on group: EventLoopGroup
     on group: EventLoopGroup
   ) -> ClientConnection.Builder.Secure {
   ) -> ClientConnection.Builder.Secure {
@@ -365,7 +365,7 @@ extension ClientConnection.Builder.Secure {
   ///
   ///
   /// - Note: May only be used with the 'Network.framework' TLS backend.
   /// - Note: May only be used with the 'Network.framework' TLS backend.
   @discardableResult
   @discardableResult
-  @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+  @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
   public func withTLS(localIdentity: SecIdentity) -> Self {
   public func withTLS(localIdentity: SecIdentity) -> Self {
     self.tls.updateNetworkLocalIdentity(to: localIdentity)
     self.tls.updateNetworkLocalIdentity(to: localIdentity)
     return self
     return self
@@ -375,7 +375,7 @@ extension ClientConnection.Builder.Secure {
   ///
   ///
   /// - Note: May only be used with the 'Network.framework' TLS backend.
   /// - Note: May only be used with the 'Network.framework' TLS backend.
   @discardableResult
   @discardableResult
-  @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+  @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
   public func withTLSHandshakeVerificationCallback(
   public func withTLSHandshakeVerificationCallback(
     on queue: DispatchQueue,
     on queue: DispatchQueue,
     verificationCallback callback: @escaping sec_protocol_verify_t
     verificationCallback callback: @escaping sec_protocol_verify_t

+ 14 - 14
Sources/GRPC/GRPCTLSConfiguration.swift

@@ -93,7 +93,7 @@ public struct GRPCTLSConfiguration {
 
 
       #if canImport(Network)
       #if canImport(Network)
       case var .network(config):
       case var .network(config):
-        if #available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) {
+        if #available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *) {
           if let hostnameOverride = newValue {
           if let hostnameOverride = newValue {
             config.updateHostnameOverride(to: hostnameOverride)
             config.updateHostnameOverride(to: hostnameOverride)
           } else {
           } else {
@@ -403,7 +403,7 @@ extension GRPCTLSConfiguration {
 #if canImport(Network)
 #if canImport(Network)
 extension GRPCTLSConfiguration {
 extension GRPCTLSConfiguration {
   internal struct NetworkConfiguration {
   internal struct NetworkConfiguration {
-    @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+    @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
     internal var options: NWProtocolTLS.Options {
     internal var options: NWProtocolTLS.Options {
       get {
       get {
         return self._options as! NWProtocolTLS.Options
         return self._options as! NWProtocolTLS.Options
@@ -424,13 +424,13 @@ extension GRPCTLSConfiguration {
     // guards to update the value in the underlying `sec_protocol_options`.
     // guards to update the value in the underlying `sec_protocol_options`.
     internal private(set) var hostnameOverride: String?
     internal private(set) var hostnameOverride: String?
 
 
-    @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+    @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
     init(options: NWProtocolTLS.Options, hostnameOverride: String?) {
     init(options: NWProtocolTLS.Options, hostnameOverride: String?) {
       self._options = options
       self._options = options
       self.hostnameOverride = hostnameOverride
       self.hostnameOverride = hostnameOverride
     }
     }
 
 
-    @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+    @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
     internal mutating func updateHostnameOverride(to hostnameOverride: String) {
     internal mutating func updateHostnameOverride(to hostnameOverride: String) {
       self.hostnameOverride = hostnameOverride
       self.hostnameOverride = hostnameOverride
       sec_protocol_options_set_tls_server_name(
       sec_protocol_options_set_tls_server_name(
@@ -440,7 +440,7 @@ extension GRPCTLSConfiguration {
     }
     }
   }
   }
 
 
-  @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+  @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
   public static func makeClientConfigurationBackedByNetworkFramework(
   public static func makeClientConfigurationBackedByNetworkFramework(
     identity: SecIdentity? = nil,
     identity: SecIdentity? = nil,
     hostnameOverride: String? = nil,
     hostnameOverride: String? = nil,
@@ -489,7 +489,7 @@ extension GRPCTLSConfiguration {
     )
     )
   }
   }
 
 
-  @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+  @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
   public static func makeClientConfigurationBackedByNetworkFramework(
   public static func makeClientConfigurationBackedByNetworkFramework(
     options: NWProtocolTLS.Options,
     options: NWProtocolTLS.Options,
     hostnameOverride: String? = nil
     hostnameOverride: String? = nil
@@ -498,7 +498,7 @@ extension GRPCTLSConfiguration {
     return GRPCTLSConfiguration(backend: .network(network))
     return GRPCTLSConfiguration(backend: .network(network))
   }
   }
 
 
-  @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+  @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
   public static func makeServerConfigurationBackedByNetworkFramework(
   public static func makeServerConfigurationBackedByNetworkFramework(
     identity: SecIdentity
     identity: SecIdentity
   ) -> GRPCTLSConfiguration {
   ) -> GRPCTLSConfiguration {
@@ -525,7 +525,7 @@ extension GRPCTLSConfiguration {
     return GRPCTLSConfiguration.makeServerConfigurationBackedByNetworkFramework(options: options)
     return GRPCTLSConfiguration.makeServerConfigurationBackedByNetworkFramework(options: options)
   }
   }
 
 
-  @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+  @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
   public static func makeServerConfigurationBackedByNetworkFramework(
   public static func makeServerConfigurationBackedByNetworkFramework(
     options: NWProtocolTLS.Options
     options: NWProtocolTLS.Options
   ) -> GRPCTLSConfiguration {
   ) -> GRPCTLSConfiguration {
@@ -533,7 +533,7 @@ extension GRPCTLSConfiguration {
     return GRPCTLSConfiguration(backend: .network(network))
     return GRPCTLSConfiguration(backend: .network(network))
   }
   }
 
 
-  @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+  @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
   internal mutating func updateNetworkLocalIdentity(to identity: SecIdentity) {
   internal mutating func updateNetworkLocalIdentity(to identity: SecIdentity) {
     self.modifyingNetworkConfiguration {
     self.modifyingNetworkConfiguration {
       sec_protocol_options_set_local_identity(
       sec_protocol_options_set_local_identity(
@@ -543,7 +543,7 @@ extension GRPCTLSConfiguration {
     }
     }
   }
   }
 
 
-  @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+  @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
   internal mutating func updateNetworkVerifyCallbackWithQueue(
   internal mutating func updateNetworkVerifyCallbackWithQueue(
     callback: @escaping sec_protocol_verify_t,
     callback: @escaping sec_protocol_verify_t,
     queue: DispatchQueue
     queue: DispatchQueue
@@ -573,7 +573,7 @@ extension GRPCTLSConfiguration {
 
 
 #if canImport(Network)
 #if canImport(Network)
 extension GRPCTLSConfiguration {
 extension GRPCTLSConfiguration {
-  @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+  @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
   internal func applyNetworkTLSOptions(
   internal func applyNetworkTLSOptions(
     to bootstrap: NIOTSConnectionBootstrap
     to bootstrap: NIOTSConnectionBootstrap
   ) -> NIOTSConnectionBootstrap {
   ) -> NIOTSConnectionBootstrap {
@@ -588,7 +588,7 @@ extension GRPCTLSConfiguration {
     }
     }
   }
   }
 
 
-  @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+  @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
   internal func applyNetworkTLSOptions(
   internal func applyNetworkTLSOptions(
     to bootstrap: NIOTSListenerBootstrap
     to bootstrap: NIOTSListenerBootstrap
   ) -> NIOTSListenerBootstrap {
   ) -> NIOTSListenerBootstrap {
@@ -604,7 +604,7 @@ extension GRPCTLSConfiguration {
   }
   }
 }
 }
 
 
-@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
 extension NIOTSConnectionBootstrap {
 extension NIOTSConnectionBootstrap {
   internal func tlsOptions(
   internal func tlsOptions(
     from configuration: GRPCTLSConfiguration
     from configuration: GRPCTLSConfiguration
@@ -613,7 +613,7 @@ extension NIOTSConnectionBootstrap {
   }
   }
 }
 }
 
 
-@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
 extension NIOTSListenerBootstrap {
 extension NIOTSListenerBootstrap {
   internal func tlsOptions(
   internal func tlsOptions(
     from configuration: GRPCTLSConfiguration
     from configuration: GRPCTLSConfiguration

+ 1 - 1
Sources/GRPC/ServerBuilder.swift

@@ -240,7 +240,7 @@ extension Server {
   /// Returns a `Server` builder configured with the 'Network.framework' TLS backend.
   /// Returns a `Server` builder configured with the 'Network.framework' TLS backend.
   ///
   ///
   /// This builder must use a `NIOTSEventLoopGroup`.
   /// This builder must use a `NIOTSEventLoopGroup`.
-  @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+  @available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
   public static func usingTLSBackedByNetworkFramework(
   public static func usingTLSBackedByNetworkFramework(
     on group: EventLoopGroup,
     on group: EventLoopGroup,
     with identity: SecIdentity
     with identity: SecIdentity

+ 1 - 1
Tests/GRPCTests/GRPCNetworkFrameworkTests.swift

@@ -25,7 +25,7 @@ import NIOTransportServices
 import Security
 import Security
 import XCTest
 import XCTest
 
 
-@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
+@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
 final class GRPCNetworkFrameworkTests: GRPCTestCase {
 final class GRPCNetworkFrameworkTests: GRPCTestCase {
   private var server: Server!
   private var server: Server!
   private var client: ClientConnection!
   private var client: ClientConnection!

+ 2 - 2
docs/tls.md

@@ -4,13 +4,13 @@ gRPC Swift offers two TLS 'backends'. A 'NIOSSL' backend and a 'Network.framewor
 
 
 The NIOSSL backend is available on Darwin and Linux and delegates to SwiftNIO SSL. The
 The NIOSSL backend is available on Darwin and Linux and delegates to SwiftNIO SSL. The
 Network.framework backend is available on recent Darwin platforms (macOS 10.14+, iOS 12+, tvOS 12+,
 Network.framework backend is available on recent Darwin platforms (macOS 10.14+, iOS 12+, tvOS 12+,
-and watchOS 5+) and uses the TLS implementation provided by Network.framework. Moreover, the
+and watchOS 6+) and uses the TLS implementation provided by Network.framework. Moreover, the
 Network.framework backend is only compatible with clients and servers using the `EventLoopGroup`
 Network.framework backend is only compatible with clients and servers using the `EventLoopGroup`
 provided by SwiftNIO Transport Services, `NIOTSEventLoopGroup`.
 provided by SwiftNIO Transport Services, `NIOTSEventLoopGroup`.
 
 
 |                             | NIOSSL backend                                       | Network.framework backend                   |
 |                             | NIOSSL backend                                       | Network.framework backend                   |
 |-----------------------------|------------------------------------------------------|---------------------------------------------|
 |-----------------------------|------------------------------------------------------|---------------------------------------------|
-| Platform Availability       | Darwin and Linux                                     | macOS 10.14+, iOS 12+, tvOS 12+, watchOS 5+ |
+| Platform Availability       | Darwin and Linux                                     | macOS 10.14+, iOS 12+, tvOS 12+, watchOS 6+ |
 | Compatible `EventLoopGroup` | `MultiThreadedEventLoopGroup`, `NIOTSEventLoopGroup` | `NIOTSEventLoopGroup`                       |
 | Compatible `EventLoopGroup` | `MultiThreadedEventLoopGroup`, `NIOTSEventLoopGroup` | `NIOTSEventLoopGroup`                       |
 
 
 Note that on supported Darwin platforms users should the prefer using `NIOTSEventLoopGroup` and the
 Note that on supported Darwin platforms users should the prefer using `NIOTSEventLoopGroup` and the