Latest 0.4.0
License MIT
Platforms ios 8.0, requires ARC

A Swift A/B testing framework for iOS

Build Status
Code Climate

A/B testing (also known as split testing) is a good practice to test new concepts. Gollum is a A/B testing framework easy to use and inspired on some best practices in Swift, like:

  • Value Types (structs and enums)
  • Error Handling (ErrorType and throws)
  • Compile time feedback

Instalation (Cocoapods)

Add to your Podfile:

pod 'Gollum'

Then run the command below:

$ pod install


Create a enum with Version type for your A/B test. Pass on each case a string with version name (e.g. a) and its probability (e.g. 0.5), both separated by :.

enum MyABTest: Version {
    case a = "A:0.5"
    case b = "B:0.5"

Register the test’s cases in Gollum:

try Gollum.instance.registerVersions([MyABTest.a, MyABTest.b])

After registration, you can check which version was selected using getSelectedVersion:

switch try Gollum.instance.getSelectedVersion(MyABTest.self) {
case .a:
    view.backgroundColor =
case .b:
    view.backgroundColor =

Or using isVersionSelected:

if try Gollum.instance.isVersionSelected(MyABTest.a) {
    view.backgroundColor =
} else if try Gollum.instance.isVersionSelected(MyABTest.b) {
    view.backgroundColor =

Error Handling

To avoid unexpected scenarios during an A/B testing, it’s important treat errors. Gollum can throw these errors:

public enum GollumError: Error {
    case versionSyntaxError(String)
    case probabilitySumIncorrect(String)
    case emptyVersionArrayPassed(String)
    case selectedVersionNotFound(String)

If an A/B testing enum is created with wrong syntax, like missing version name or probability, the application will crash with error versionSyntaxError:

enum MyABTest: Version {
    case a = ":0.5"
    case b = "B:0.5"

Error message:

fatal error: 'try!' expression unexpectedly raised an error: Gollum.GollumError.versionSyntaxError("ABTest case expression must have name and probability values splitted by : (e.g. "MyTestCaseA:0.5")")

During an A/B test registration, the method registerVersions can throws emptyVersionArrayPassed, selectedVersionNotFound or probabilitySumIncorrect errors.

Also methods getSelectedVersion and isVersionSelected can throw selectedVersionNotFound error.


Because of some Swift’s features, Gollum doesn’t work in Objective-C.


Gollum is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "Gollum",
    "version": "0.4.0",
    "summary": "A Swift A/B Testing framework for iOS",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Eduardo Ferreira": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.4.0"
    "social_media_url": "",
    "source_files": "Gollum/**/*{.swift}",
    "requires_arc": true,
    "platforms": {
        "ios": "8.0"
    "pushed_with_swift_version": "echo "4.0" > .swift-version"

Pin It on Pinterest

Share This