This example utilizes the Azure SDK for C encapsulated within a Swift library available here. The Swift library enables users to select their preferred MQTT library and provides APIs that simplify the implementation of Azure IoT concepts.
D2C messages
C2D messages
Device Twin
Direct Methods
IoT Plug & Play
Device Provisioning
Swift MQTT
Swift NIO-SSL
Swift NIO
IoT Hub client
DPS client (Device Provisioning Service)
X.509 certificate authentication
Telemetry messages (D2C - Device to Cloud)
Commands (C2D - D2C)
Swift development environment installed
Azure Account
Device previously created in your IoT Hub or DPS Enrollment.
WebSocket Support: Swift MQTT, used in this sample, lacks support for WebSockets. Consider CocoaMQTT as an alternative, leveraging StarScream. MQTT-nio could also serve as an alternative.
This sample utilizes Swift NIO for network operations and Swift NIO-SSL for TLS, both supported by Apple. However, it's important to note that the Swift MQTT client is a third-party library and is neither created nor supported by Apple.
SAS Token Utilization: The sample does not implement the use of SAS Tokens.
Reconnection and Retries: The sample does not include implementation for reconnection or retries. Client applications should handle these functionalities.
The Swift sample is an open-source solution and is not officially supported by Microsoft. For any bugs or issues with the codebase, please log them in the repository's issue tracker.
The diagram depicted below illustrates the Swift sample relying on the Embedded C SDK, furnishing libraries for accessing various Azure IoT functionalities.
This SDK adopts the BYO (bring your own) network stack approach, granting device builders the flexibility to select the MQTT client, TLS, and TCP stack that best suits their target platform.
In this particular instance, the sample utilizes Swift MQTT, Swift NIO-SSL, and Swift NIO.