Use this example application to integrate with CloudBees platform and test feature management. After integrating, observe changes in the application UI as you update flag values in CloudBees platform.
This Swift example application includes the ROX SDK and sample feature flags already implemented in code
Get started with this project
To get started with the swift-fm-example
project, follow these steps:
-
Using Git, clone the swift-fm-example to your local machine:
git@github.com:cloudbees-io/swift-fm-example.git
-
Install the ROX dependency using the
podInstall
CocoaPods command. Refer to CocoaPods Getting Started.In your terminal, change the directory to the root directory of the cloned repository and run the install command:
cd root-directory-of-cloned-repository pod install
-
Open the Project file:
.xcworkspace
in Xcode for use in a later step. -
Locate and copy the SDK key from CloudBees platform:
-
Navigate to
. -
Select an application.
-
Select
next to the SDK key on the page.
If no SDK key is available:
-
Navigate to
. -
Select
in the upper-right corner.
-
Follow the installation instructions to complete the installation.
-
The SDK key appears once an application is linked to an environment.
-
Close the installation instructions, and copy the SDK Key.
-
-
-
In Xcode, open ConfigurationManager.swift and replace the
<Your CloudBees SDK Key>
placeholder with your SDK key. For example:ROX.setup(withKey: "<Your Cloudbees Environment API Key>", options: options)
-
Use Xcode to run the
swift-fm-example
application by choosing one of the following:-
Select Product > Run.
-
Press
Cmd + R
.
-
View the flags in action
Now that your application is running, observe your application display changes in response to updates you make to flag values in CloudBees platform.
-
In (PRODUCT}, select Feature management.
-
Select your example application to display the available flags as shown in the table below.
Flag name | Flag type | Description |
---|---|---|
|
Boolean |
Displays or hides the message. |
|
String |
Sets the message text. |
|
Number |
Sets the message font size in pixels.
The flag value has the following variations: |
|
String |
Sets the message font color. The flag value has the following variations: |
If no flags are displayed, check that the environment-specific SDK key is correctly added to the example application. Refer to Locate and copy the SDK key. |
Apply changes to flags in the UI
To update flag values in the platform UI:
-
Select Feature management.
-
Select
next to the flag you want to configure.
-
Select Configure.
-
Select the same Environment you used when you copied the SDK key.
-
Update a flag value and save your changes.
-
Toggle the Configuration status to On.
-
The updated flag value is soon reflected in the display of the application.
For more information about setting flag values, refer to Configure feature flags.
Use the application with multiple SDK keys
Run multiple instances of the SDK in a single application, each with its own SDK key and environment. Each instance is fully isolated. Use this to read or compare flags across environments without redeploying, to support multi-tenant routing, or to combine server-side and client-side evaluations in one application.
To use multiple SDK keys in the example Swift iOS application:
-
Retrieve the SDK key for the environments you want to use.
-
Initialize a separate SDK instance for each key.
-
Decide how to route requests to instances (for example, by tenant, region, or environment selector).
-
Perform registration, fetch, and streaming setup for each instance (enable streaming if supported by your SDK).
-
Evaluate flags using the selected instance. Pass a consistent user/context object for accurate targeting.
-
Tag logs or metrics by instance, and shut down instances you no longer need.
For more information about using multiple SDK keys, refer to Manage multiple SDK keys in your application.
Documentation reference
Refer to Install the SDK for more information