Skip to content

Commit 9b1d4aa

Browse files
committed
Fixes for previews in SwiftUI
1 parent ea79659 commit 9b1d4aa

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Sources/MQTTNIO/Handlers/MQTTErrorHandler.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ final class MQTTErrorHandler: ChannelInboundHandler {
2020
}
2121

2222
func errorCaught(context: ChannelHandlerContext, error: Error) {
23-
#if canImport(NIOSSL)
23+
// This should use `canImport(NIOSSL)`, will change when it works with SwiftUI previews.
24+
#if os(macOS) || os(Linux)
2425
// We ignore unclean shutdowns, which could be caused by servers not sending `close_notify`
2526
if let sslError = error as? NIOSSLError, case .uncleanShutdown = sslError {
2627
return

Sources/MQTTNIO/MQTTConfiguration.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,8 @@ extension MQTTConfiguration {
541541
}
542542
}
543543

544-
#if canImport(NIOSSL)
544+
// This should use `canImport(NIOSSL)`, will change when it works with SwiftUI previews.
545+
#if os(macOS) || os(Linux)
545546
extension MQTTConfiguration {
546547
/// Creates an `MQTTConfiguration`.
547548
/// - Parameters:

Tests/MQTTNIOTests/Core/MQTTNIOTestCase.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ class MQTTNIOTestCase: XCTestCase {
117117
), eventLoopGroupProvider: .shared(tlsGroup))
118118
}
119119

120-
#if canImport(NIOSSL)
120+
// This should use `canImport(NIOSSL)`, will change when it works with SwiftUI previews.
121+
#if os(macOS) || os(Linux)
121122
var nioSSLTLSClient: MQTTClient {
122123
get throws {
123124
let rootDir = URL(fileURLWithPath: #file)

0 commit comments

Comments
 (0)