Example Swift iOS application for CloudBees Unify feature management

2 minute read

Use this example application to integrate with CloudBees Unify and test feature management. After integrating, observe changes in the application UI as you update flag values in CloudBees Unify.

This Swift example application includes the ROX SDK and sample feature flags already implemented in the code.

Get started with this project

To get started with the swift-fm-example project, follow these steps:

  1. Using Git, clone the swift-fm-example to your local machine:

    git@github.com:cloudbees-io/swift-fm-example.git
  2. 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
  3. Open the Project file: .xcworkspace in Xcode for use in a later step.

  4. Locate and copy the SDK key from CloudBees Unify:

    1. Navigate to Feature management  Flags.

    2. Select an application.

    3. Select copy next to the SDK key on the page.

      If no SDK key is available:

      • Navigate to Feature management  Flags.

      • Select Example app flags 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.

  5. 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)
  6. 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 Unify.

  1. In (PRODUCT}, select Feature management.

  2. Select your example application to display the available flags as shown in the table below.

Table 1. Feature flags in the example application.
Flag name Flag type Description

ShowMessage

Boolean

Displays or hides the message.

Message

String

Sets the message text.

FontSize

Number

Sets the message font size in pixels. The flag value has the following variations: 12, 16, or 24.

FontColor

String

Sets the message font color. The flag value has the following variations: red, green, or blue.

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 CloudBees Unify UI:

  1. Select Feature management.

  2. Select Vertical ellipsis next to the flag you want to configure.

  3. Select Configure.

  4. Select the same Environment you used when you copied the SDK key.

  5. Update a flag value and save your changes.

  6. Toggle the Configuration status to On.

  7. 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.

Documentation reference

Refer to Install the SDK for more information