Skip to content

Commit ca8af7a

Browse files
authored
Only use NIOSSL on macOS and Linux (#101) (#102)
1 parent 82f8380 commit ca8af7a

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

Sources/MQTTNIO/MQTTClient.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the MQTTNIO project
44
//
5-
// Copyright (c) 2020-2021 Adam Fowler
5+
// Copyright (c) 2020-2022 Adam Fowler
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -121,7 +121,8 @@ public final class MQTTClient {
121121
case .createNew:
122122
#if canImport(Network)
123123
switch configuration.tlsConfiguration {
124-
#if canImport(NIOSSL)
124+
// This should use canImport(NIOSSL), will change when it works with SwiftUI previews.
125+
#if os(macOS) || os(Linux)
125126
case .niossl:
126127
self.eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
127128
#endif

Sources/MQTTNIO/MQTTConfiguration.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the MQTTNIO project
44
//
5-
// Copyright (c) 2020-2021 Adam Fowler
5+
// Copyright (c) 2020-2022 Adam Fowler
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -28,7 +28,8 @@ extension MQTTClient {
2828
/// It is recommended on iOS you use NIO Transport Services.
2929
public enum TLSConfigurationType {
3030
/// NIOSSL TLS configuration
31-
#if canImport(NIOSSL)
31+
// This should use canImport(NIOSSL), will change when it works with SwiftUI previews.
32+
#if os(macOS) || os(Linux)
3233
case niossl(TLSConfiguration)
3334
#endif
3435
#if canImport(Network)

Sources/MQTTNIO/MQTTConnection.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the MQTTNIO project
44
//
5-
// Copyright (c) 2020-2021 Adam Fowler
5+
// Copyright (c) 2020-2022 Adam Fowler
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -96,7 +96,8 @@ final class MQTTConnection {
9696
switch client.configuration.tlsConfiguration {
9797
case .ts(let config):
9898
options = try config.getNWProtocolTLSOptions()
99-
#if canImport(NIOSSL)
99+
// This should use canImport(NIOSSL), will change when it works with SwiftUI previews.
100+
#if os(macOS) || os(Linux)
100101
case .niossl:
101102
throw MQTTError.wrongTLSConfig
102103
#endif
@@ -112,7 +113,8 @@ final class MQTTConnection {
112113
return bootstrap
113114
}
114115
#endif
115-
#if canImport(NIOSSL) // canImport(Network)
116+
// This should use canImport(NIOSSL), will change when it works with SwiftUI previews.
117+
#if os(macOS) || os(Linux) // canImport(Network)
116118
if let clientBootstrap = ClientBootstrap(validatingGroup: client.eventLoopGroup) {
117119
let tlsConfiguration: TLSConfiguration
118120
switch client.configuration.tlsConfiguration {

Sources/MQTTNIO/TSTLSConfiguration.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the MQTTNIO project
44
//
5-
// Copyright (c) 2020-2021 Adam Fowler
5+
// Copyright (c) 2020-2022 Adam Fowler
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -98,7 +98,8 @@ public struct TSTLSConfiguration {
9898
/// Create certificate array from already loaded SecCertificate array
9999
public static func certificates(_ secCertificates: [SecCertificate]) -> Self { .init(certificates: secCertificates) }
100100

101-
#if canImport(NIOSSL)
101+
// This should use canImport(NIOSSL), will change when it works with SwiftUI previews.
102+
#if os(macOS) || os(Linux)
102103
/// Create certificate array from PEM file
103104
public static func pem(_ filename: String) throws -> Self {
104105
let certificates = try NIOSSLCertificate.fromPEMFile(filename)

0 commit comments

Comments
 (0)