Mobile iOS Feature Flags

Feature flag / toggle management built for Swift and Objective C mobile apps

Feature flags are a software development best practice of gating functionality. Functionality can be deployed “off”, then turned on via the feature flag, separate from deployment. With feature flags, you can manage the entire lifecycle of a feature.

LaunchDarkly's Mobile iOS SDK lets you create and maintain Swift and Objective C feature flags across your entire mobile application. You can centrally manage all of your feature flags, perform granular rollouts, and kill bad features without redeploying. All flag values are evaluated in-memory, so there is no latency for your users. New flag settings are streamed to the SDKs in real-time, so any changes to your flag rules will take effect almost immediately.

With LaunchDarkly, you can toggle your features from our dashboard - that means you can roll out and roll back features without having to release a new version to the app store.

LaunchDarkly Dashboard & Feature Flag Manager
Click Image to Enlarge

Here are some product benefits of LaunchDarkly's Mobile iOS Feature Flag SDK:

  • Avoid "zero star" reviews by turning off broken features.
  • Optimize user flows and measure performance.
  • Real-time rollbacks to minimize downtime.
  • Real-time feature flags via a streaming API
  • In-memory flag evaluation with near zero latency
  • No external HTTP calls for flag values
  • Boolean & multivariate feature flags
  • Custom percentage rollouts and targeting rules
  • A/B testing
Click Image to Enlarge

Flag management benefits:

  • Audit log
  • Custom roles
  • Custom webhooks
  • Integrations for Slack and HipChat

Mobile iOS Feature Flags

Let's create a mobile iOS feature flag for a "One Click Checkout"

1.Use CocoaPods to install the LaunchDarkly SDK:

Check out our open source mobile iOS SDK on GitHub or read through the reference documentation.

               
       target 'hello-ios' do
         pod 'LaunchDarkly'
       end
                
              

2.Import the LaunchDarkly library

               
         #import "LDClient.h"
                
              

3.Add a user property

               
          @interface ViewController ()
          @property LDUserModel *user;
          @end

          @implementation ViewController
          @synthesize user;
                
              

4.Create a new user

You can pass us any data about users for targeting and segmentation.

               
          LDUserBuilder *builder = [[LDUserBuilder alloc] init];
          builder = [builder withKey:@"bob@example.com"];
          builder = [builder withFirstName:@"Bob"];
          builder = [builder withLastName:@"Loblaw"];

          user = [builder build];

          NSArray *groups = @[@"beta_testers"];
          builder = [builder withCustomArray:@"groups" value:groups];
                
              

5.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

6.Wrap your code with a feature flag

Create a new LDClient and call 'boolVariation' to check the flag value for the user.

               
            LDConfigBuilder *config = [[LDConfigBuilder alloc] init];
            [config withMobileKey:@"mob-9925194d-c7f1-4266-946f-805f3cc29656"];

            [[LDClient sharedInstance] start:config userBuilder:builder];

          -(void) checkFeatureValue {
            BOOL showFeature = [[LDClient sharedInstance] boolVariation:@"one_click_checkout" default:NO];

            if (showFeature) {
              NSLog(@"showing One Click Checkout feature for %@", user.key);
            } else {
              NSLog(@"not showing One Click Checkout for %@", user.key);
            }
          }
                
              

7.Manage your flag

Use LaunchDarkly to determine which users see the feature.
You can roll out to a percentage of your users or target individual users/groups.


Create your own iOS feature flags in minutes.
How It Works