Skip to content

Commit 1553d74

Browse files
authored
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.
1 parent 00a8930 commit 1553d74

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

Sources/GRPC/GRPCChannel/GRPCChannelBuilder.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extension ClientConnection {
4242
///
4343
/// gRPC Swift offers two TLS 'backends'. The 'NIOSSL' backend is available on Darwin and Linux
4444
/// platforms and delegates to SwiftNIO SSL. On recent Darwin platforms (macOS 10.14+, iOS 12+,
45-
/// tvOS 12+, and watchOS 5+) the 'Network.framework' backend is available. The two backends have
45+
/// tvOS 12+, and watchOS 6+) the 'Network.framework' backend is available. The two backends have
4646
/// a number of incompatible configuration options and users are responsible for selecting the
4747
/// appropriate APIs. The TLS configuration options on the builder document which backends they
4848
/// support.
@@ -85,7 +85,7 @@ extension ClientConnection {
8585
///
8686
/// - Parameter group: The `EventLoopGroup` use for the connection.
8787
/// - Returns: A builder for a connection using the Network.framework TLS backend.
88-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
88+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
8989
public static func usingTLSBackedByNetworkFramework(
9090
on group: EventLoopGroup
9191
) -> ClientConnection.Builder.Secure {
@@ -365,7 +365,7 @@ extension ClientConnection.Builder.Secure {
365365
///
366366
/// - Note: May only be used with the 'Network.framework' TLS backend.
367367
@discardableResult
368-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
368+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
369369
public func withTLS(localIdentity: SecIdentity) -> Self {
370370
self.tls.updateNetworkLocalIdentity(to: localIdentity)
371371
return self
@@ -375,7 +375,7 @@ extension ClientConnection.Builder.Secure {
375375
///
376376
/// - Note: May only be used with the 'Network.framework' TLS backend.
377377
@discardableResult
378-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
378+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
379379
public func withTLSHandshakeVerificationCallback(
380380
on queue: DispatchQueue,
381381
verificationCallback callback: @escaping sec_protocol_verify_t

Sources/GRPC/GRPCTLSConfiguration.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public struct GRPCTLSConfiguration {
9393

9494
#if canImport(Network)
9595
case var .network(config):
96-
if #available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) {
96+
if #available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *) {
9797
if let hostnameOverride = newValue {
9898
config.updateHostnameOverride(to: hostnameOverride)
9999
} else {
@@ -403,7 +403,7 @@ extension GRPCTLSConfiguration {
403403
#if canImport(Network)
404404
extension GRPCTLSConfiguration {
405405
internal struct NetworkConfiguration {
406-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
406+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
407407
internal var options: NWProtocolTLS.Options {
408408
get {
409409
return self._options as! NWProtocolTLS.Options
@@ -424,13 +424,13 @@ extension GRPCTLSConfiguration {
424424
// guards to update the value in the underlying `sec_protocol_options`.
425425
internal private(set) var hostnameOverride: String?
426426

427-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
427+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
428428
init(options: NWProtocolTLS.Options, hostnameOverride: String?) {
429429
self._options = options
430430
self.hostnameOverride = hostnameOverride
431431
}
432432

433-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
433+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
434434
internal mutating func updateHostnameOverride(to hostnameOverride: String) {
435435
self.hostnameOverride = hostnameOverride
436436
sec_protocol_options_set_tls_server_name(
@@ -440,7 +440,7 @@ extension GRPCTLSConfiguration {
440440
}
441441
}
442442

443-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
443+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
444444
public static func makeClientConfigurationBackedByNetworkFramework(
445445
identity: SecIdentity? = nil,
446446
hostnameOverride: String? = nil,
@@ -489,7 +489,7 @@ extension GRPCTLSConfiguration {
489489
)
490490
}
491491

492-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
492+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
493493
public static func makeClientConfigurationBackedByNetworkFramework(
494494
options: NWProtocolTLS.Options,
495495
hostnameOverride: String? = nil
@@ -498,7 +498,7 @@ extension GRPCTLSConfiguration {
498498
return GRPCTLSConfiguration(backend: .network(network))
499499
}
500500

501-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
501+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
502502
public static func makeServerConfigurationBackedByNetworkFramework(
503503
identity: SecIdentity
504504
) -> GRPCTLSConfiguration {
@@ -525,15 +525,15 @@ extension GRPCTLSConfiguration {
525525
return GRPCTLSConfiguration.makeServerConfigurationBackedByNetworkFramework(options: options)
526526
}
527527

528-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
528+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
529529
public static func makeServerConfigurationBackedByNetworkFramework(
530530
options: NWProtocolTLS.Options
531531
) -> GRPCTLSConfiguration {
532532
let network = NetworkConfiguration(options: options, hostnameOverride: nil)
533533
return GRPCTLSConfiguration(backend: .network(network))
534534
}
535535

536-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
536+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
537537
internal mutating func updateNetworkLocalIdentity(to identity: SecIdentity) {
538538
self.modifyingNetworkConfiguration {
539539
sec_protocol_options_set_local_identity(
@@ -543,7 +543,7 @@ extension GRPCTLSConfiguration {
543543
}
544544
}
545545

546-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
546+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
547547
internal mutating func updateNetworkVerifyCallbackWithQueue(
548548
callback: @escaping sec_protocol_verify_t,
549549
queue: DispatchQueue
@@ -573,7 +573,7 @@ extension GRPCTLSConfiguration {
573573

574574
#if canImport(Network)
575575
extension GRPCTLSConfiguration {
576-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
576+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
577577
internal func applyNetworkTLSOptions(
578578
to bootstrap: NIOTSConnectionBootstrap
579579
) -> NIOTSConnectionBootstrap {
@@ -588,7 +588,7 @@ extension GRPCTLSConfiguration {
588588
}
589589
}
590590

591-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
591+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
592592
internal func applyNetworkTLSOptions(
593593
to bootstrap: NIOTSListenerBootstrap
594594
) -> NIOTSListenerBootstrap {
@@ -604,7 +604,7 @@ extension GRPCTLSConfiguration {
604604
}
605605
}
606606

607-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
607+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
608608
extension NIOTSConnectionBootstrap {
609609
internal func tlsOptions(
610610
from configuration: GRPCTLSConfiguration
@@ -613,7 +613,7 @@ extension NIOTSConnectionBootstrap {
613613
}
614614
}
615615

616-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
616+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
617617
extension NIOTSListenerBootstrap {
618618
internal func tlsOptions(
619619
from configuration: GRPCTLSConfiguration

Sources/GRPC/ServerBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ extension Server {
240240
/// Returns a `Server` builder configured with the 'Network.framework' TLS backend.
241241
///
242242
/// This builder must use a `NIOTSEventLoopGroup`.
243-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
243+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
244244
public static func usingTLSBackedByNetworkFramework(
245245
on group: EventLoopGroup,
246246
with identity: SecIdentity

Tests/GRPCTests/GRPCNetworkFrameworkTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import NIOTransportServices
2525
import Security
2626
import XCTest
2727

28-
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
28+
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
2929
final class GRPCNetworkFrameworkTests: GRPCTestCase {
3030
private var server: Server!
3131
private var client: ClientConnection!

docs/tls.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ gRPC Swift offers two TLS 'backends'. A 'NIOSSL' backend and a 'Network.framewor
44

55
The NIOSSL backend is available on Darwin and Linux and delegates to SwiftNIO SSL. The
66
Network.framework backend is available on recent Darwin platforms (macOS 10.14+, iOS 12+, tvOS 12+,
7-
and watchOS 5+) and uses the TLS implementation provided by Network.framework. Moreover, the
7+
and watchOS 6+) and uses the TLS implementation provided by Network.framework. Moreover, the
88
Network.framework backend is only compatible with clients and servers using the `EventLoopGroup`
99
provided by SwiftNIO Transport Services, `NIOTSEventLoopGroup`.
1010

1111
| | NIOSSL backend | Network.framework backend |
1212
|-----------------------------|------------------------------------------------------|---------------------------------------------|
13-
| Platform Availability | Darwin and Linux | macOS 10.14+, iOS 12+, tvOS 12+, watchOS 5+ |
13+
| Platform Availability | Darwin and Linux | macOS 10.14+, iOS 12+, tvOS 12+, watchOS 6+ |
1414
| Compatible `EventLoopGroup` | `MultiThreadedEventLoopGroup`, `NIOTSEventLoopGroup` | `NIOTSEventLoopGroup` |
1515

1616
Note that on supported Darwin platforms users should the prefer using `NIOTSEventLoopGroup` and the

0 commit comments

Comments
 (0)