Latest 0.1.0
Homepage https://github.com/recruit-mp/ABKit
License MIT
Platforms ios 8.0, requires ARC
Authors

Build Status

Split Testing for Swift.

ABKit is a library for implementing a simple Split Test that:

  • Doesn’t require an HTTP client
  • written in Pure Swift

Installation

CocoaPods

To integrate ABKit into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'ABKit'

Then, run the following command:

$ pod install

Usage

A/B Test

let defaultVersion = Version(name: "A") { version in print("Pattern (version.name)") }
let test = SplitTest(name: "Sample A/B test", defaultVersion: defaultVersion)

let b = Version(name: "B") { version in print("Pattern (version.name)") }
test.addVersion(b, weight: 0.5)

test.run() // A(Default Version) = 50%, B = 50%

Split Test with Weighted Probabilities

let defaultVersion = Version(name: "A") { version in print("Pattern (version.name)") }
let test = SplitTest(name: "Sample split test", defaultVersion: defaultVersion)

let b = Version(name: "B") { version in print("Pattern (version.name)") }
test.addVersion(b, weight: 0.2)

let c = Version(name: "C") { version in print("Pattern (version.name)") }
test.addVersion(c, weight: 0.3)

test.run() // A(Default Version) = 50%, B = 20%, C = 30%

Conditional Test

let defaultVersion = Version(name: "A") { version in print("Pattern (version.name)") }
let test = ConditionalTest<User>(name: "Sample conditional test", defaultVersion: defaultVersion)

let b = Version(name: "B") { version in print("Pattern (version.name)" }
test.addVersion(b) { user in user.age < 20 }

let user = User(name: "naoty", age: 28)
test.run(user) // If user.age < 20 is true, B will be run otherwise A will be run.

Pro Tips

  • ABKit selects one of the versions using a random number, which is saved in RandomNumberRepository. By default, ABKit uses NSUserDefault as RandomNumberRepository. You can save it in any storage by implementing RandomNumberRepository protocol.
  • You can specify an arbitrary number as the random number using -setRandomNumber(_:) and reset a random number using -deleteRandomNumber() for SplitTest.

License

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

Latest podspec

{
    "name": "ABKit",
    "version": "0.1.0",
    "summary": "AB testing framework for iOS",
    "description": "ABKit is a library for implementing a simple Split Test that:n* Doesn't require an HTTP clientn* written in Pure Swift",
    "homepage": "https://github.com/recruit-mp/ABKit",
    "license": "MIT",
    "authors": {
        "Naoto Kaneko": "[email protected]"
    },
    "source": {
        "git": "https://github.com/recruit-mp/ABKit.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "ABKit/**/*.{h,swift}"
}

Pin It on Pinterest

Share This