Swiftpack.co - Package - launchdarkly/swift-eventsource
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.


CircleCI CocoaPods Carthage compatible SwiftPM compatible Platform

LDSwiftEventSource is a cross platform implementation of the EventSource specification written in Swift. It was developed for use in the LaunchDarkly iOS SDK.


  • iOS 10.0+ / watchOS 3.0+ / tvOS 10.0+ / macOS 10.12+
  • Swift 5.0+



To use the CocoaPods dependency manager to integrate LDSwiftEventSource into your Xcode project, specify it in your Podfile:

pod 'LDSwiftEventSource', '~> 1.2'


To use the Carthage dependency manager to integrate LDSwiftEventSource into your Xcode project, specify it in your Cartfile:

github "LaunchDarkly/swift-eventsource" ~> 1.2

Swift Package Manager

The Swift Package Manager is a dependency manager integrated into the swift compiler and Xcode. Note that the LDSwiftEventSource Swift package provides both a LDSwiftEventSource product, which is explicitly dynamic, and a LDSwiftEventSourceStatic product which is explicitly static.

To integrate LDSwiftEventSource into an Xcode project, go to the project editor, and select Swift Packages. From here hit the + button and follow the prompts using https://github.com/LaunchDarkly/swift-eventsource.git as the URL.

To include LDSwiftEventSource in a Swift package, simply add it to the dependencies section of your Package.swift file. And add the desired product as a dependency for your targets.

dependencies: [
    .package(url: "https://github.com/LaunchDarkly/swift-eventsource.git", .upToNextMajor(from: "1.2.0"))


We encourage pull requests and other contributions from the community. Check out our contributing guidelines for instructions on how to contribute to this SDK.

About LaunchDarkly

  • LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
    • Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
    • Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
    • Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
    • Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
  • LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out our documentation for a complete list.
  • Explore LaunchDarkly


Stars: 4


[1.2.0] - 2020-10-21 - 2020-10-21T16:33:58


  • Added headerTransform closure to LDConfig to allow dynamic http header configuration.

[1.1.0] - 2020-07-20 - 2020-07-20T18:49:16


  • Support arm64e on appletvos, iphoneos, and macosx SDKs by extending valid architectures.
  • Support for building LDSwiftEventSource on Linux. Currently this library will not generate log messages on Linux, and may not behave correctly on Linux due to Foundation being incomplete.

[1.0.0] - 2020-07-16 - 2020-07-16T17:48:59

This is the first public release of the LDSwiftEventSource library. The following notes are what changed since the previous pre-release version.


  • Renamed EventHandler.onMessage parameter event to eventType.
  • The EventSource class no longer extends NSObject or URLSessionDataDelegate to not expose urlSession functions.

[0.5.0] - 2020-07-14 - 2020-07-15T13:57:53


  • Default LDSwiftEventSource product defined for the SwiftPM package is now explicitly a dynamic product. An explicitly static product is now available as LDSwiftEventSourceStatic.

[0.4.0] - 2020-07-13 - 2020-07-13T14:39:05


  • Converted build system to use a single target to produce a universal framework, rather than separate targets for each platform that share a product name. This is to prevent issues with xcodebuild resolving the build scheme to an incorrect platform when building dependent packages with 'Find Implicit Dependencies' enabled. This is due to a bug in xcodebuild, for more information see http://www.openradar.me/20490378 and http://www.openradar.me/22008701.

[0.3.0] - 2020-06-02 - 2020-06-02T09:59:13


  • Added stop() method to shutdown the EventSource connection.


  • Logging subsystem renamed from com.launchdarkly.swift-event-source to com.launchdarkly.swift-eventsource

[0.2.0] - 2020-05-21 - 2020-05-21T09:22:05


  • Public constructors for UnsuccessfulResponseError and MessageEvent to allow consumers of the library to use them for unit tests.

[0.1.0] - 2020-05-09 - 2020-05-09T08:58:11


  • Initial implementation for internal alpha testing.