iOS/tvOS SDK installation

3 minute read

Control feature rollout for certain user segments of your application with feature flags. To start using feature management in the platform, follow the instructions below to install the SDK and deploy a feature flag.

These same instructions are available in the platform UI. Select Installation from the left pane to use.

To install the SDK:

  1. Select Feature management  Installation.

  2. Select an Environment from the options, or create an environment by completing the following:

    1. Select CREATE ENVIRONMENT.

    2. Enter an Environment name.

    3. (Optional) Enter a Description.

    4. (Optional) Select Approvers if you want to have a manual approval required before deployment.

    5. (Optional) Enter any Properties you want to associate with the environment. For more information, refer to properties configuration and properties in an environment.

    6. Select SUBMIT.

  3. Select iOS or tvOS, as appropriate, from the language options.

  4. Select a type of platform from the options.

  5. Follow the instructions specific for your chosen platform to add the ROX package to your application:

    Add the ROX package with Carthage

    To add the ROX package with Carthage:

    1. Add the following to the cartfile:

      github "rollout/rox-spm"
    2. Run the following command in the terminal to install the Carthage dependencies:

      carthage update --use-xcframeworks
    3. Add the appropriate binaries from the Carthage/Bin directory to your project.

      • For Objective-C: ROXCore.xcframework

      • For Swift: ROXCore.xcframework and ROX.xcframework

    Add the ROX package with CocoaPods

    To add the ROX package with CocoaPods:

    1. Add the following to the podfile:

      pod 'ROX'
    2. Run the following command in the terminal to install the CocoaPods dependencies:

      pod install
    Add the ROX package with Swift Package Manager

    To add the ROX package with Swift Package Manager, use the appropriate repositories for your project:

    Add the ROX package with XCFramework (manual installation)

    To add the ROX package with XCFramework (manual installation):

    1. Download the latest version ROX.xcframework ZIP archive from https://github.com/rollout/rox-spm/releases.

    2. Extract the archive into a directory within your application.

    3. Add files in Xcode by adding the appropriate binaries for your project:

      • For Objective-C: ROXCore.xcframework

      • For Swift: ROXCore.xcframework and ROX.xcframework

  6. Add the following code, as appropriate for your project, to import the SDK and create flags in your application:

    Objective-C
    Swift
    #import <ROXCore/ROXCore.h> @interface flags : ROXBaseContainer @property (nonatomic) ROXFlag* enableTutorial; @property (nonatomic) ROXString* titleColors; @end #import "MyContainer.h" @implementation flags - (instancetype)init { self = [super init]; if (self) { self.enableTutorial = [[ROXFlag alloc] init]; self.titleColors = [[ROXString alloc] initWithDefault:@"White" variations:@[@"Blue", @"Green", @"Yellow"]]; } } return self; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Register the flag [ROX register:[[flags alloc] init]]; // Setup the environment key [ROX setupWithKey:@"<YOUR-SDK-KEY>"]; (1) return YES; } [flags.enableTutorial enabled:^{ // start the tutorial } disabled:^{ // skip the tutorial }]; if ([flags.titleColors.value isEqualToString:@"Blue"]) { NSLog(@"Title color is Blue"); } else if ([flags.titleColors.value isEqualToString:@"White"]) { NSLog(@"Title color is White"); } else if ([flags.titleColors.value isEqualToString:@"Green"]) { NSLog(@"Title color is Green"); } else if ([flags.titleColors.value isEqualToString:@"Yellow"]) { NSLog(@"Title color is Yellow"); } @end
    import ROX import ROXCore public class flags : RoxContainer { let enableTutorial = RoxFlag() let titleColors = RoxString(withDefault: "White", variations: ["White", "Blue", "Green", "Yellow"]) static let INSTANCE = flags() } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { //Register the flags instance ROX.register(container: flags.INSTANCE) // Setup the environment key ROX.setup(withKey: "<YOUR-SDK-KEY>") (1) return true } flags.INSTANCE.enableTutorial.enabled { } switch flags.titleColors!.value()! { case "White": print("Title color is White") case "Blue": print("Title color is Blue") case "Green": print("Title color is Green") case "Yellow": print("Title color is Yellow") default: print("Title color is default - White") }
    1 The platform provides the unique SDK key for your environment at the <YOUR-SDK-KEY> location within the Rox.setup call.
  7. Run your application and then select TEST INTEGRATION to confirm a successful connection.

After running the application, flags added in the code are automatically added to your feature flag list.

You have installed an SDK and created flags in your application.