From 992158a68bd162dbef08f21bd607f2f04671fc18 Mon Sep 17 00:00:00 2001 From: Benedek Kozma Date: Tue, 8 Oct 2024 21:25:24 +0200 Subject: [PATCH 1/2] Import FoundationEssentials instead of Foundation when available --- Sources/MQTTNIO/AsyncAwaitSupport/MQTTClient+async.swift | 5 +++++ Sources/MQTTNIO/AsyncAwaitSupport/MQTTClientV5+async.swift | 4 ++++ Sources/MQTTNIO/MQTTConnection.swift | 4 ++++ Sources/MQTTNIO/MQTTPacket.swift | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Sources/MQTTNIO/AsyncAwaitSupport/MQTTClient+async.swift b/Sources/MQTTNIO/AsyncAwaitSupport/MQTTClient+async.swift index 45f82f26..d9896cea 100644 --- a/Sources/MQTTNIO/AsyncAwaitSupport/MQTTClient+async.swift +++ b/Sources/MQTTNIO/AsyncAwaitSupport/MQTTClient+async.swift @@ -11,7 +11,12 @@ // //===----------------------------------------------------------------------===// +#if canImport(FoundationEssentials) +import FoundationEssentials +import Dispatch +#else import Foundation +#endif import NIOCore @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) diff --git a/Sources/MQTTNIO/AsyncAwaitSupport/MQTTClientV5+async.swift b/Sources/MQTTNIO/AsyncAwaitSupport/MQTTClientV5+async.swift index 059cc7c4..802d61d7 100644 --- a/Sources/MQTTNIO/AsyncAwaitSupport/MQTTClientV5+async.swift +++ b/Sources/MQTTNIO/AsyncAwaitSupport/MQTTClientV5+async.swift @@ -11,7 +11,11 @@ // //===----------------------------------------------------------------------===// +#if canImport(FoundationEssentials) +import FoundationEssentials +#else import Foundation +#endif import NIOCore @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) diff --git a/Sources/MQTTNIO/MQTTConnection.swift b/Sources/MQTTNIO/MQTTConnection.swift index 6d301009..d1e87fa8 100644 --- a/Sources/MQTTNIO/MQTTConnection.swift +++ b/Sources/MQTTNIO/MQTTConnection.swift @@ -11,7 +11,11 @@ // //===----------------------------------------------------------------------===// +#if canImport(FoundationEssentials) +import FoundationEssentials +#else import Foundation +#endif #if canImport(Network) import Network #endif diff --git a/Sources/MQTTNIO/MQTTPacket.swift b/Sources/MQTTNIO/MQTTPacket.swift index d0666dc3..c10a8e96 100644 --- a/Sources/MQTTNIO/MQTTPacket.swift +++ b/Sources/MQTTNIO/MQTTPacket.swift @@ -623,7 +623,7 @@ struct MQTTAuthPacket: MQTTPacket { /// MQTT incoming packet parameters. struct MQTTIncomingPacket: MQTTPacket { - var description: String { "Incoming Packet 0x\(String(format: "%x", self.type.rawValue))" } + var description: String { "Incoming Packet 0x\(String(self.type.rawValue, radix: 16))" } /// Type of incoming MQTT packet. let type: MQTTPacketType From e826c91a5624e58682f6e090bf9b973e2733d7d4 Mon Sep 17 00:00:00 2001 From: Benedek Kozma Date: Wed, 9 Oct 2024 08:18:23 +0200 Subject: [PATCH 2/2] Fix import order --- Sources/MQTTNIO/AsyncAwaitSupport/MQTTClient+async.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/MQTTNIO/AsyncAwaitSupport/MQTTClient+async.swift b/Sources/MQTTNIO/AsyncAwaitSupport/MQTTClient+async.swift index d9896cea..29f33c81 100644 --- a/Sources/MQTTNIO/AsyncAwaitSupport/MQTTClient+async.swift +++ b/Sources/MQTTNIO/AsyncAwaitSupport/MQTTClient+async.swift @@ -12,8 +12,8 @@ //===----------------------------------------------------------------------===// #if canImport(FoundationEssentials) -import FoundationEssentials import Dispatch +import FoundationEssentials #else import Foundation #endif