Swiftpack.co - Package - launchdarkly/ios-client-sdk

LaunchDarkly SDK for iOS

CircleCI CocoaPods Compatible Carthage compatible Platform

LaunchDarkly overview

LaunchDarkly is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. Get started using LaunchDarkly today!

Twitter Follow

Supported iOS versions

This version of the LaunchDarkly SDK has been tested with iOS 12 and across mobile, desktop, watch, and tv devices.

Getting started

LaunchDarkly supports multiple methods for installing the library in a project. Once installed, head over to the SDK documentation for complete instructions on getting started with using the SDK.

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C and Swift, which automates and simplifies the process of using 3rd-party libraries like LaunchDarkly in your projects. You can install it with the following command:

$ gem install cocoapods
  1. To integrate LaunchDarkly into your Xcode project using CocoaPods, specify it in your Podfile:
use_frameworks!
target 'YourTargetName' do
  pod 'LaunchDarkly', '4.4.0'
end
  1. Then, run the following command from the project directory that contains the podfile:
$ pod install
  1. Import the LaunchDarkly client into your project:

Objective-C

@import LaunchDarkly;

Swift

import LaunchDarkly

Installation with Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate LaunchDarkly into your Xcode project using Carthage, specify it in your Cartfile:

github "launchdarkly/ios-client-sdk" "4.4.0"

Run carthage update to build the framework. Optionally, specify the --platform to build only the frameworks that support your platform(s). Drag the built Darkly.framework from your platform's Carthage/Build folder into your Xcode project under Embedded Binaries. For non-iOS frameworks the framework includes the platform, e.g. Darkly_tvOS.framework Follow the instructions at Getting Started to finish the setup. Your app may not build until you add the run script phase to copy-frameworks to your target(s).

Installation without a package manager

  1. On the root folder of the project, git clone the following two repositiories.
  • git clone https://github.com/launchdarkly/ios-client-sdk
  • git clone https://github.com/launchdarkly/ios-eventsource

Remove CocoaPods

  1. Go to the ios-eventsource folder.
  • If CocoaPods is installed on your system, do the following:
    • run pod deintegrate.
    • Open LDEventSource.workspace.
    • Delete Pods.xcodeproj in the Project Navigator.
    • Close LDEventSource.workspace.
    • Delete Podfile and Podfile.lock from the ios-eventsource folder.
  • If CocoaPods is not installed on your system, do the following:
    • Delete DarklyEventSource.podspec, Podfile, Podfile.lock and the entire Pods folder.
    • Open LDEventSource.xcodeproj.
    • Delete the Pods group in the Project Navigator.
    • Open the Frameworks group in the Project Navigator.
    • Remove any Pods frameworks or static libraries from the group.
    • Select DarklyEventSource in the Project Navigator.
    • Select DarklyEventSource-iOS in the Targets pane.
    • Select the General tab.
    • Remove any Pods framework from Linked Frameworks and Libraries.
    • Repeat for each target, including DarklyEventSourceTests.
    • Select the Build Phases tab.
    • Remove [CP] Check Pods Manifest.lock.
    • Repeat for each target.
    • Close LDEventSource.xcodeproj.
  1. Go to the ios-client-sdk folder.
  • If CocoaPods is installed on your system, do the following:
    • run pod deintegrate.
    • Open LaunchDarkly.workspace.
    • Delete Pods.xcodeproj in the Project Navigator.
    • Close LaunchDarkly.workspace.
    • Delete Podfile and Podfile.lock from the ios-client-sdk folder.
  • If CocoaPods is not installed, do the following:
    • Delete LaunchDarkly.podspec, Podfile, Podfile.lock and the entire Pods folder.
    • Open LaunchDarkly.xcodeproj.
    • Delete the Pods group in the Project Navigator.
    • Open the Frameworks group in the Project Navigator.
    • Remove any Pods frameworks or static libraries from the group.
    • Select LaunchDarkly in the Project Navigator.
    • Select LaunchDarkly_iOS in the Targets pane.
    • Select the General tab.
    • Remove any Pods framework from Linked Frameworks and Libraries.
    • Repeat for each target.
    • Select the Build Phases tab.
    • Remove [CP] Check Pods Manifest.lock.
    • Repeat for each target, including LaunchDarklyTests.
    • Still in Build Phases tab,remove the Run Script build phase, and repeat for each target as well.

Remove Carthage

  1. Go to the ios-client-sdk.
  2. Remove Cartfile, Cartfile.resolved, and the entire Carthage folder.
  3. Open LaunchDarkly.xcodeproj if needed.
  4. Remove CarthageFrameworks in the Project Navigator.
  5. Open Frameworks in the Project Navigator.
  6. Remove all DarklyEventSource.framework references.
  7. Close LaunchDarkly.xcodeproj.

Install LaunchDarkly using frameworks

NOTE: If you want to install LaunchDarkly without using frameworks see Install LaunchDarkly without frameworks below. 11. Create a Frameworks folder at the root of your project. 12. For each supported platform, create a sub-folder with the platform title inside of Frameworks. 13. Build DarklyEventSource.framework

  • Open LDEventsource.xcodeproj.
  • Select the scheme for your app's platform.
  • Select the target device.
  • Build.
  • Open Products in the Project Navigator.
  • Ctrl-Click the DarklyEventSource.framework file just built.
  • Select Show in Finder.
  • Copy the DarklyEventSource.framework into the Frameworks sub-folder for the platform.
  • Repeat for each supported platform.
  • Close LDEventsource.xcodeproj.
  1. Build LaunchDarkly.framework
  • Open LaunchDarkly.xcodeproj.
  • Select LaunchDarkly project in the Project Navigator.
  • Select the target for your app's platform.
  • Select the General tab.
  • From the Frameworks folder created previously, drag the DarklyEventSource.framework for the matching platform into Linked Frameworks and Libraries.
  • Open the Build Settings tab.
  • Open Framework Search Paths.
  • Add the path to the Frameworks sub-folder for the selected platform.
  • Build.
  • Open Products in the Project Navigator.
  • Ctrl-Click the LaunchDarkly.framework file just built. For non-iOS platforms be sure to select the framework containing the platform name.
  • Select Show in Finder.
  • Copy the LaunchDarkly.framework or LaunchDarkly_<platform> into the Frameworks sub-folder for the platform.
  • Repeat for each supported platform.
  • Close LaunchDarkly.xcodeproj.
  1. Add the frameworks to your project
  • Open your project.
  • Select your project in the Project Navigator.
  • Select the target for your app's platform.
  • Select the General tab.
  • From the Frameworks folder created at step 11, drag the DarklyEventSource.framework and LaunchDarkly.framework or LaunchDarkly_<platform>.framework for the matching platform into Linked Frameworks and Libraries.
  • Remove the frameworks just added from Linked Frameworks and Libraries. The frameworks should remain visible in the Frameworks group in the Project Navigator.
  • Add the frameworks to the Embedded Binaries.
  • Repeat for each target that uses LaunchDarkly.
  • Close your project.
  1. Go to Final setup instructions below.

Install LaunchDarkly without frameworks

  1. Open your app's .xcodeproj or .xcworkspace in XCode, whichever you normally use.
  2. Add 2 sub-projects to your project for LaunchDarkly and DarklyEventSource. These should be added hierarchically, with your project as the outermost project, LaunchDarkly nested inside your project, and DarklyEventSource nested inside of LaunchDarkly. Before you begin, make sure Xcode does not have LaunchDarkly or DarklyEventSource open in any window.
  • Ctrl-click your project in the Project Navigator.
  • Select Add Files to "<yourProjectName>"....
  • Navigate to the ios-client-sdk folder.
  • Select LaunchDarkly.xcodeproj. Make sure it is the project file, not the workspace file. You should now see LaunchDarkly.xcodeproj nested inside your project.
  • Ctrl-click LaunchDarkly.xcodeproj in the Project Navigator.
  • Select Add Files to "LaunchDarkly.xcodeproj"....
  • Navigate to the ios-eventsource folder.
  • Select LDEventSource.xcodeproj. Make sure it is the project file, not the workspace file. You should now see LDEventSource.xcodeproj nested inside the Darkly project.
  1. Add LaunchDarkly to your project.
  • Select your project in the Project Navigator
  • Select your target in the Targets pane.
  • Select the Build Phases tab.
  • Open Target Dependencies.
  • Add the platform specific LaunchDarkly_<platform> from the LaunchDarkly project.
  • Repeat for each target that uses LaunchDarkly.
  1. Add DarklyEventSource to the LaunchDarkly project.
  • Select the LaunchDarkly project in the Project Navigator
  • Select your platform's target in the Targets pane.
  • Select the Build Phases tab.
  • Open Target Dependencies.
  • Add the platform specific DarklyEventSource_<platform> from the DarklyEventSource project.
  • Repeat for each platform target that uses LaunchDarkly.
  1. Go to Final setup instructions below.

Final setup instructions

  1. Import the SDK into your code:
  • Add @import LaunchDarkly; (Objective-c) or import LaunchDarkly (Swift) to the source file that references LD classes. For non-iOS platforms, include the platform name, e.g. import LaunchDarkly_watchOS
  1. In Build Settings for each target, set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to Yes.
  2. Delete derived data for your project, if necessary.
  3. Build your app for each target. If it fails, you may have skipped one of the steps above. Verify you have chosen the appropriate platform in each step.
  4. Run your app. If the app crashes, it is likely that either the incorrect platform was installed, or the LaunchDarkly or DarklyEventSource dependencies were incorrectly added, or that you may have to set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to Yes.

Learn more

Check out our documentation for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the complete reference guide for this SDK.

Testing

We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs, as well as test networking behavior in a long-running application. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly.

Contributing

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

Github

link
Stars: 25

Dependencies

Used By

Total: 0

Releases

[4.4.0] - 2019-12-19 - 2020-01-15 21:31:46

Added

  • Added startCompleteWhenFlagsReceived function which contains modified completion behavior. This new function's completion will only return after flag values are received. Previously the start completion returned when the SDK went online.
  • The SDK now specifies a uniquely identifiable request header when sending events to LaunchDarkly to ensure that events are only processed once, even if the SDK sends them two times due to a failed initial attempt.

[4.3.2] - 2019-12-19 - 2019-12-20 00:08:43

Fixed

  • Flag change listeners will now be called when a flag value changes but a variation number does not change. Previously, flag listeners were not called when a value assigned to a variation was manually edited in the dashboard or via the API.

[4.3.1] - 2019-12-12 - 2019-12-13 01:02:14

Changed

  • Updated to ios-eventsource version 4.1.0. This negates the need to use_frameworks! when using the React Native SDK. This change does not affect the iOS SDK.

[4.3.0] - 2019-12-3 - 2019-12-03 23:24:37

Added

  • Implemented variationDetail which returns an Evaluation Reason giving developers greater insight into why a value was returned.
  • Added support for the latest Experimentation features allowing increased value from A/B/n testing. The track method now supports an additional metricValue parameter.

[4.2.1] - 2019-11-15 - 2019-11-15 19:37:09

Changed

  • Updated to ios-eventsource version 4.0.3. This appends a platform name to bundle identifiers. (Thanks, cswelin!)

Fixed

  • Comparing two nil objects of type [String: Any]? no longer causes a crash. (#197)

[4.2.0] - 2019-10-25 - 2019-10-25 20:47:24

Added

  • The identify function allows a completion to be called after a user is updated.
  • The Connection Status API allows greater introspection into the current LaunchDarkly connection and the health of local flags. • This feature adds a new class called ConnectionInformation that contains properties that keep track of the current connection mode e.g. streaming or polling, when and how a connection failed, and the last time flags were updated. This class can be accessed from LDClient.shared.getConnectionInformation. • Additionally, a new observer function called observeCurrentConnectionMode allows your application to listen to changes in the SDK's connection to LaunchDarkly.

Changed

  • The user property is now deprecated in favor of the identify function.

[4.1.2] - 2019-07-11 - 2019-07-11 17:17:03

Fixed

  • WatchKit is now conditionally imported in WatchOS only to fix an error in Xcode 11.
  • Comparing two nil objects of type [String: Any]? no longer causes a crash.

[3.0.4] - 2019-07-09 - 2019-07-09 23:04:20

Changed

  • Updated to ios-eventsource version 4.0.2. This fixes a potential hang on LDClient start.

[4.1.1] - 2019-07-09 - 2019-07-09 23:03:02

Change

  • Updated to ios-eventsource version 4.0.2. This fixes a potential hang on LDClient start.

[4.1.0] - 2019-06-19 - 2019-06-19 23:18:02

Change

  • Installs new deviceModel into EnvironmentReporter and renames old deviceModel to deviceType.
  • Updated MacOS model detection to use CwSysCtl.

Fixed

  • Fixed a concurrency bug that caused crashes in FlagStore.swift. This bug could surface during rapid updates to local flags.

3.0.3 - 2019-05-31 00:02:03

[3.0.3] - 2019-05-30

Changed

  • Added nonnull to featureKey parameters on exposed variation methods.

Fixed

  • Added length check to flagConfigValueForKey to prevent dictionary access when key is nil.

3.0.2 - 2019-05-15 19:53:21

[3.0.2] - 2019-05-15

Changed

  • Moved the timer that limits how often a client app can set the SDK online onto the main run loop.

4.0.0 - 2019-05-10 18:16:54

[4.0.0] - 2019-04-18

This is the first non-beta release of the Swift SDK. It follows the beta.3 release from 2019-03-07. Unlike previous Swift SDK releases, this release does not have a 3.0.0 companion tag.

Changed

  • Changes Feature Flag caching so that cached feature flags are associated with a user key and mobile key.
  • Clears new warnings that appear with Xcode 10.2

Added

  • Implements URL caching for REPORT requests.
  • Installs the ability to read cached data in all cached data schemas from 2.3.3 through 3.0.1 and store the feature flags in the 4.0.0 cached data schema.
  • Retains prior cached data for 90 days following upgrade to 4.0.0. Does not keep older cached data up-to-date. Downgrading to a prior version within 90 days allows the downgraded app to read the last cached data from the downgraded version.

Fixed

  • Prevents a log message that incorrectly reported a network error on watchOS

3.0.1 - 2019-05-02 18:39:23

[3.0.1] - 2019-04-30

Changed

  • Deployed Carthage built DarklyEventSource frameworks as part of the Darkly project.

3.0.0 - 2019-04-18 12:11:07

[3.0.0] - 2019-04-17

Changed

  • Renamed the non-iOS Darkly frameworks to include the platform name. e.g. Darkly_watchOS. Because non-CocoaPods apps will need to update imports for the new modules, advanced to the next major version.
  • Removed DarklyEventSource as a CocoaPods dependency in the podfile. DarklyEventSource remains a dependency in the podspec.

2.14.4 - 2019-02-26 22:27:02

[2.14.4] - 2019-02-26

Changed

  • Changed the following to repair macOS builds:
    • Removed extraneous framework reference from Darkly_macOS target
    • Deselected Autocreate schemes in Darkly.xcworkspace

2.14.3 - 2019-02-26 18:41:44

[2.14.3] - 2019-02-25

Changed

  • Added support for integrating without a package manager
  • Updated to DarklyEventSource version 4.0.1, which adds platform specific targets to support integration without a package manager.

2.14.2 - 2019-01-25 03:15:14

[2.14.2] - 2019-01-24

Added

  • Added nullability specifiers to public SDK classes.

Changed

  • Updated to DarklyEventSource version 4.0.0, which eliminates a 1-second delay in SDK initialization.

2.14.1 - 2018-12-21 23:32:01

[2.14.1] - 2018-12-21

Changed

  • Added copy methods to several objects involved in creating a summary event.
  • Added additional synchronization to creating a summary event in order to potentially prevent some crash scenarios.

2.14.0 - 2018-12-06 00:49:22

[2.14.0] - 2018-12-05

Added

  • Added allFlags property to LDClient that provides a dictionary of feature flag keys and values. Accessing feature flags via allFlags does not record any analytics events.
  • Support for multiple LaunchDarkly projects or environments. Each set of feature flags associated with a mobile key is called an environment. • Added secondaryMobileKeys to LDConfig. LDConfig mobileKey refers to the primary environment, and must be present. All entries in secondaryMobileKeys refer to optional secondary environments. NOTE: See LDClient.h for the requirements to add secondaryMobileKeys. The SDK will throw an NSInvalidArgumentException if an attempt is made to set mobile keys that do not meet these requirements. • Installed LDClientInterface protocol used to access secondary environment feature flags. May also be used on the primary environment to provide normalized access to feature flags. • Adds environmentForMobileKeyNamed: to vend an environment (primary or secondary) object conforming to LDClientInterface. Use the vended object to access feature flags for the requested environment. • Adds new constant kLDPrimaryEnvironmentName used to vend the primary environment's LDClientInterface from environmentForMobileKeyNamed:.

Changed

  • LDUserBuilder build method no longer restores cached user attributes. The SDK sets into the LDUserModel object only the attributes in the LDUserBuilder at the time of the build message. On start, the SDK restores the last cached feature flags, which the SDK will use until the first feature flag update from the server.
  • Changed the format for caching feature flags to associate a set of feature flags with a mobile key. Downgrading to an earlier version will be able to store feature flags, but without the environment association. As a result, the SDK will not restore cached feature flags from 2.14.0 if the SDK is downgraded to a version before 2.14.0.
  • Installed a URL cache that does not use the [NSURLSession defaultSession] or the [NSURLCache sharedURLCache], precluding conflicts with custom client app URL caching.

Fixed

  • Fixed defect preventing SDK from calling userUpdated or featureFlagDidUpdate when deleting a feature flag under certain conditions.
  • Fixed defect preventing URL caching for feature flag requests using the REPORT verb.
  • Fixed defect causing the loss of some analytics events when changing users.

2.13.9 - 2018-11-06 01:00:59

[2.13.9] - 2018-11-05

Fixed

  • Fixed defect causing a crash when unknown data exists in a feature flag cache.
  • Renamed function parameters to avoid the use of Objective-C++ reserved words.

2.13.8 - 2018-10-24 05:03:26

[2.13.8] - 2018-10-23

Fixed

  • Fixed defect preventing feature flags cached prior to version 2.11.0 from restoring correctly and possibly crashing

2.13.7 - 2018-10-16 05:38:48

[2.13.7] - 2018-10-15

Changed

  • Initializing LDClient in polling mode no longer blocks the calling thread.

2.13.6 - 2018-10-06 00:51:00

[2.13.6] - 2018-10-05

Fixed

  • LDClient's updateUser did not attempt to retrieve the new user's cached flag values.
  • Fixed defect preventing a user's feature flags from being cached correctly under certain conditions.

2.13.5 - 2018-09-24 03:41:01

[2.13.5] - 2018-09-23

Changed

  • Repairs Carthage build errors caused by higher fidelity checks in Xcode 10's new build engine.
  • Removes CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS from the podspec, allowing Xcode 10's default setting to be used

2.13.4 - 2018-08-23 22:06:41

[2.13.4] - 2018-08-23

Changed

  • Update to DarklyEventSource 3.2.7

2.13.3 - 2018-08-15 18:47:29

[2.13.3] - 2018-08-15

Changed

  • Synchronized summary event creation to limit thread access and protect data integrity
  • Improved the robustness of the code creating summary events to better handle unexpected data

2.13.2 - 2018-07-28 04:46:05

[2.13.2] - 2018-07-27

Fixed

  • Updated DarklyEventSource in order to fix potential flag stream parsing issues.

2.13.1 - 2018-06-26 00:55:40

[2.13.1] - 2018-06-25

Changed

  • Removed early tests for reaching event capacity that caused benign Thread Sanitizer warnings
  • Changed pointer nil tests to clear Static Analyzer pointer comparison warnings

2.13.0 - 2018-06-01 23:40:21

[2.13.0] - 2018-06-01

Added

  • To reduce the network bandwidth used for analytics events, feature request events are now sent as counters rather than individual events, and user details are now sent only at intervals rather than in each event. These behaviors can be modified through the LaunchDarkly UI and with the new configuration option inlineUsersInEvents. For more details, see Analytics Data Stream Reference.
  • New property inlineUserInEvents in LDConfig. When YES includes the full user (excluding private attributes) in analytics feature and custom events. When NO includes only the userKey. Default: NO.
  • Calling start or updateUser (when started) on LDClient logs an analytics identify event. identify events contain the full user (excluding private attributes) regardless of inlineUserInEvents.
  • Adds analytics summary event used to track feature flag requests to the SDK.
  • Adds analytics debug event available to assist with debugging when requested from the new Debugger in the LaunchDarkly UI.

Fixed

  • Under some conditions, the SDK would not update flag values initially after connecting to the LaunchDarkly service.
  • The SDK was reporting incorrect dates in analytics events sent from watchOS.