iOS/tvOS SDK reference

3 minute readReference

The following information is for the latest SDK version (6.x). The CloudBees platform requires that your installed SDK version be at least 6.x. Please install the latest SDK by following the instructions in the platform UI or in the SDK installation documentation.

Any updates to version 6.x are noted in the platform changelog.

Once the SDK is installed and initialized, any feature flags declared in your code are automatically registered in the platform.

Class ROX

The ROX class provides the interface for managing feature flags in your iOS or tvOS application. It enables you to register containers, set up the SDK using an environment-specific key, and define custom properties for targeting users. Feature flags are evaluated at runtime based on platform configuration.

Setup

Initializes the SDK and connects to the CloudBees platform.

[ROX setupWithKey:@"<YOUR-SDK-KEY>"];
Parameter Type Description

sdkKey

NSString*

The SDK key provided in the platform UI for your environment.

This method does not return a value

Shutdown

Call the shutdown method to stop the SDK and clean up resources. If not explicitly shut down, the SDK remains active until the application exits.

Register

Register a container that defines your feature flags with the CloudBees Feature Management system.

[ROX register:[[Flags alloc] init]]; [ROX register:@"myNamespace" container:[[Flags alloc] init]];
Parameter Type Description

container

ROXBaseContainer*

A class that defines and contains your feature flags. Call register: only once for a given container class.

namespace

NSString* (optional)

A string that serves as a prefix for the feature flags inside the container. A namespace can only be registered once. Using the same namespace twice throws an exception.

  • The namespace parameter is optional. If you do not specify a namespace, feature flag names use the default naming convention.

  • Call register: only once per container class instance, either at setupWithKey: or when the app enters the foreground.

Define a container

Your container class must inherit from ROXBaseContainer. Define flags using supported flag types.

@interface Flags : ROXBaseContainer @property (nonatomic) ROXFlag* enableTutorial; @property (nonatomic) ROXString* titleColors; @end

Supported flag types

The SDK provides several classes for defining feature flags, depending on the data type you want to evaluate. Use these classes to declare flags in your code and access their values based on platform configuration and targeting rules.

Class ROXFlag

Represents a Boolean feature flag.

self.enableTutorial = [[ROXFlag alloc] init];

Methods

Method Description

enabled:

Executes a block when the flag is enabled.

disabled:

Executes a block when the flag is disabled.

isEnabled

Returns YES if the flag is enabled.

Class ROXString

Represents a feature flag that returns one of several string values.

self.titleColors = [[ROXString alloc] initWithDefault:@"White" variations:@[@"Blue", @"Green", @"Yellow"]];

Parameters

Parameter Type Description

default

NSString*

Default fallback value.

variations

NSArray<NSString*>*

List of available override values.

Properties

Property Type Description

value

NSString*

The current flag value after evaluation.

Custom properties

Use custom properties to support advanced targeting. You can define static or computed (dynamic) values.

setCustomBooleanProperty

Set a static Boolean custom property.

[ROX setCustomBooleanProperty:@"isTester" value:YES];
Parameter Type Description

name

NSString*

Name of the custom property.

value

BOOL

Static Boolean value.

setCustomComputedBooleanProperty

Set a computed Boolean custom property using a block.

[ROX setCustomComputedBooleanProperty:@"isTester" with:^BOOL(id context) { return [context[@"role"] isEqualToString:@"tester"]; }];
Parameter Type Description

name

NSString*

Name of the custom property.

value

Block

A block that returns a BOOL value.

setCustomStringProperty

Set a static String custom property.

[ROX setCustomStringProperty:@"userType" value:@"beta"];
Parameter Type Description

name

NSString*

Name of the custom property.

value

NSString*

Static String value.

setCustomComputedStringProperty

Set a computed String custom property using a block.

[ROX setCustomComputedStringProperty:@"userType" with:^NSString*(id context) { return context[@"userType"]; }];
Parameter Type Description

name

NSString*

Name of the custom property.

value

Block

A block that returns a NSString* value.

setCustomIntegerProperty

Set a static Integer custom property.

[ROX setCustomIntegerProperty:@"userAge" value:25];
Parameter Type Description

name

NSString*

Name of the custom property.

value

NSInteger

Static Integer value.

setCustomComputedIntegerProperty

Set a computed Integer custom property using a block.

[ROX setCustomComputedIntegerProperty:@"userAge" with:^NSInteger(id context) { return [context[@"age"] integerValue]; }];
Parameter Type Description

name

NSString*

Name of the custom property.

value

Block

A block that returns an NSInteger value.

setCustomDoubleProperty

Set a static Double custom property.

[ROX setCustomDoubleProperty:@"userScore" value:99.5];
Parameter Type Description

name

NSString*

Name of the custom property.

value

double

Static Double value.

setCustomComputedDoubleProperty

Set a computed Double custom property using a block.

[ROX setCustomComputedDoubleProperty:@"userScore" with:^double(id context) { return [context[@"score"] doubleValue]; }];
Parameter Type Description

name

NSString*

Name of the custom property.

value

Block

A block that returns a double value.

Real time updates (SSE)

The SDK supports real-time feature flag updates using Server-Sent Events (SSE) from the following endpoint:

https://sdk-notification-service.cloudbees.io/sse

This URL allows the SDK to receive real-time configuration updates. For example, when a flag state changes, the update is pushed instantly to the SDK rather than waiting for polling.

Ensure this URL is allowlisted in your network configuration.