Skip to content

Commit

Permalink
Fixes for previews in SwiftUI
Browse files Browse the repository at this point in the history
  • Loading branch information
sroebert committed Aug 12, 2022
1 parent ea79659 commit 9b1d4aa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Sources/MQTTNIO/Handlers/MQTTErrorHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ final class MQTTErrorHandler: ChannelInboundHandler {
}

func errorCaught(context: ChannelHandlerContext, error: Error) {
#if canImport(NIOSSL)
// This should use `canImport(NIOSSL)`, will change when it works with SwiftUI previews.
#if os(macOS) || os(Linux)
// We ignore unclean shutdowns, which could be caused by servers not sending `close_notify`
if let sslError = error as? NIOSSLError, case .uncleanShutdown = sslError {
return
Expand Down
3 changes: 2 additions & 1 deletion Sources/MQTTNIO/MQTTConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,8 @@ extension MQTTConfiguration {
}
}

#if canImport(NIOSSL)
// This should use `canImport(NIOSSL)`, will change when it works with SwiftUI previews.
#if os(macOS) || os(Linux)
extension MQTTConfiguration {
/// Creates an `MQTTConfiguration`.
/// - Parameters:
Expand Down
3 changes: 2 additions & 1 deletion Tests/MQTTNIOTests/Core/MQTTNIOTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class MQTTNIOTestCase: XCTestCase {
), eventLoopGroupProvider: .shared(tlsGroup))
}

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

0 comments on commit 9b1d4aa

Please sign in to comment.