This section describes how to set up and install the iOS SDK and how to deploy a feature flag.
Step 1 - Setting up the iOS SDK
To setup iOS SDK, follow these steps:
-
Create a CloudBees Feature Management account. See Signup Page to create an account.
-
Get your environment key. Copy your environment key from App settings > Environments > Key.
Step 2 - Installing the iOS SDK
For instructions on initializing the iOS package to your application., select your installation method:
CocoaPods
To install the iOS package, follow these steps:
-
In the podfile, add the following:
pod 'ROX'
-
To install the Cocoapods dependencies, run the following command in the terminal:
pod install
Carthage (SDK5)
SDK5 only. |
To install the iOS package, follow these steps:
-
In the cartfile, add the following:
github "rollout/rox-spm"
-
To install the Carthage dependencies, run the following command in the terminal:
carthage update --use-xcframeworks
-
Add the downloaded binaries to your project. The binaries can be found in
Carthage/Bin
directory.-
For Objective-C add
ROXCore.xcframework
. -
For Swift add both
ROXCore.xcframework
andROX.xcframework
.
-
Carthage (SDK4)
SDK4 only. |
To install the iOS package, follow these steps:
-
In the cartfile, add the following:
github "rollout/rox-ios"
-
To install the Carthage dependencies, run the following command in the terminal:
carthage update --platform iOS
Swift Package Manager
SDK5 only. |
To add ROX to an Objective-C project use this repository: https://github.com/rollout/rox-core-spm/.
To add ROX to Swift code, use this repo URL: https://github.com/rollout/rox-spm/.
Manual installation (XCFramework)
SDK5 only. |
To install the iOS package, follow these steps:
-
Select and download the latest
ROX.xcframework.zip
archive version from the GitHub repository. -
Extract the archive into the directory under your application.
-
Add files to your project in Xcode by selecting the downloaded
ROXCore.xcframework
andROX.xcframework
.-
For Objective-C project add
ROXCore.xcframework
. -
For Swift add both
ROXCore.xcframework
andROX.xcframework
.
-
Manual installation
SDK4 only. |
To install the iOS package, follow these steps:
-
If you are already in the manual step screen on the dashboard, click download.
-
If for some reason you left the installation screen you can go back by clicking on Dashboard > Install Instructions.
-
Download the zip file and open it. Place the ROX directory under your application.
-
Add files to your project in Xcode by selecting
ROXCore.framework
andRoxSdk.xcodeproj
. -
Remove
ROXCore.framework
from Linked Frameworks and Libraries. -
Click the plus sign (
+
) under Embedded Binaries and select bothROXCore.framework
andROX.framework
.
Add the following lines of code to your application
import ROX
import ROXCore
public class flags : RoxContainer {
// Define the feature flags
let enableTutorial = RoxFlag()
// Using a simple singleton pattern
// a single instance should be used and injected to using classes and unit tests
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: <ROLLOUT_ENV_KEY>)
return true
}
flags.INSTANCE.enableTutorial.enabled {
// TODO: Put your code here that needs to be gated
}
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")
}
#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:@<ROLLOUT_ENV_KEY>];
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