Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. MQTT
  3. CocoaMQTT

CocoaMQTT

NOASSERTIONSwift2.3.0

A native Swift library for MQTT 5.0 and 3.1.1 communication on iOS, macOS, and tvOS.

Visit WebsiteGitHubGitHub
1.7k stars473 forks0 contributors

What is CocoaMQTT?

CocoaMQTT is an MQTT client library written in Swift for iOS, macOS, and tvOS applications. It enables devices and apps to publish and subscribe to messages using the lightweight MQTT protocol, which is commonly used in IoT, real-time messaging, and mobile connectivity scenarios. The library supports both MQTT 5.0 and 3.1.1 specifications, providing a native solution for Apple ecosystem developers.

Target Audience

iOS, macOS, and tvOS developers building applications that require lightweight messaging, IoT device communication, or real-time data sync with MQTT brokers.

Value Proposition

Developers choose CocoaMQTT for its native Swift implementation, support for the latest MQTT 5.0 features, and seamless integration with Apple's platforms, including SSL security and WebSocket transport options.

Overview

MQTT 5.0 client library for iOS and macOS written in Swift

Use Cases

Best For

  • Building iOS apps that connect to IoT devices or sensors
  • Implementing real-time messaging features in macOS applications
  • Creating tvOS apps for smart home dashboards or controls
  • Developing cross-platform Apple apps that use MQTT for data sync
  • Adding secure, bidirectional communication to mobile projects
  • Connecting to MQTT brokers over WebSocket in Swift projects

Not Ideal For

  • Projects targeting non-Apple platforms like Android, web, or watchOS
  • Applications with strict dependency minimization to reduce bundle size or avoid third-party risks
  • Teams preferring reactive programming patterns like Combine or RxSwift without additional wrapper layers
  • Environments requiring out-of-the-box server-side rendering or non-Swift language integration

Pros & Cons

Pros

Dual Protocol Support

Supports both MQTT 5.0 and 3.1.1 specifications, with separate CocoaMQTT5 and CocoaMQTT classes in the usage examples, ensuring compatibility with modern and legacy brokers.

Secure SSL/TLS Options

Provides one-way and two-way certificate authentication, including code snippets for allowing untrusted CA certificates and generating .p12 files with OpenSSL.

WebSocket Transport

Enables MQTT over WebSocket and WSS with the CocoaMQTTWebSocket class and Starscream dependency, allowing custom headers and secure connections as shown in the setup steps.

Modern Swift API

Written in Swift 5 with support for delegate patterns and closure-based callbacks, making it idiomatic and easy to integrate into Apple platform codebases.

Cons

Dependency on External Libraries

Relies on third-party sockets like MqttCocoaAsyncSocket and Starscream for WebSocket, which can introduce version conflicts, maintenance overhead, and increased project complexity.

Complex SSL Configuration

Two-way SSL requires manual generation of .p12 files with specific OpenSSL versions (e.g., 1.1), adding error-prone setup steps not needed in simpler clients.

Limited Platform Support

Only compatible with iOS, macOS, and tvOS, excluding watchOS and non-Apple platforms, which restricts its use in cross-platform or hybrid app scenarios.

WebSocket Overhead

Enabling WebSocket support necessitates additional imports and configurations, such as importing CocoaMQTTWebSocket and Starscream, unlike streamlined TCP-based MQTT setups.

Frequently Asked Questions

Quick Stats

Stars1,749
Forks473
Contributors0
Open Issues128
Last commit17 hours ago
CreatedSince 2014

Tags

#iot#ios#mqtt#macosx#mqtt-client#websocket#tvos#messaging#mobile-development#cocoapods#swift#real-time#macos

Built With

S
Starscream
S
Swift

Links & Resources

Website

Included in

Swift26.0kMQTT2.3k
Auto-fetched 17 hours ago

Related Projects

MoscapsuleMoscapsule

MQTT Client for iOS written in Swift

Stars274
Forks69
Last commit5 years ago
Perfect-NotificationsPerfect-Notifications

Apple Push Notifications (APNs) Server-Side library.

Stars118
Forks29
Last commit6 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub