Skip to content

iOSerler/ExperimentKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExperimentKit

ExperimentKit simplify A/B testing and working with Remote Config, freeing you up to focus on the more important things.


Firebase example

Setting up without ExperimentKit

import Firebase 

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        window = UIWindow(frame: UIScreen.main.bounds)
        guard let window = window else { return false }
        FirebaseApp.configure()
        ...
        return true
    }
}
remoteConfig = RemoteConfig.remoteConfig()
let settings = RemoteConfigSettings()
settings.minimumFetchInterval = 0
remoteConfig.configSettings = settings
remoteConfig.fetch { (status, error) -> Void in
  if status == .success {
    print("Config fetched!")
    self.remoteConfig.activate { changed, error in
      // ...
    }
  } else {
    print("Config not fetched")
    print("Error: \(error?.localizedDescription ?? "No error available.")")
  }
  self.displayWelcome()
}

Setting up with ExperimentKit

import ExperimentKit 

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        window = UIWindow(frame: UIScreen.main.bounds)
        guard let window = window else { return false }
        let configuration = FirebaseConfigurationProvider()
        ExperimentManager.shared.configure(configurationProvider: configuration)
        ...
        return true
    }
}

Running experiment without ExperimentKit

let remoteString = remoteConfig["some_key"].stringValue
label.text = remoteString

Running experiment with ExperimentKit

label.addExperiment(forKey: "some_key", as: String.self) { object, remoteString in
    DispatchQueue.main.async {
       self.label.text = remoteString
    }
}

Running experiment without ExperimentKit

struct Person: Decodable {
    var name: String
    var age: Int
    var city: String
}

let remoteData = remoteConfig["some_key"].dataValue
let decoded = try? JSONDecoder().decode(Person.self, from: remoteData)
print(decoded.name)

Running experiment with ExperimentKit

struct Person: Decodable {
    var name: String
    var age: Int
    var city: String
}

self.addExperiment(forKey: "json_key", as: Person.self) { object, decoded in
    print(decoded.name)
}

Other Examples

If "some_exp" does not exist remotely anymore, code in closure will be not executed.

label.text = "Hello"
self.addExperiment(forKey: "some_exp", as: String.self) { object, value in
    label.text = "Goodbye"
}

Installation

In your project root

  1. Clone this repo inside your project folder.

In your [Podfile]:

  1. Add
target "Change Me!" do
  pod "'ExperimentKit'", ::git => 'https://github.com/iOSerler/ExperimentKit', :branch => 'master'
end
  1. Run
pod install
pod update

In Xcode project

  1. import framework & configure it (Firebase example) inside AppDelegate's didFinishLaunchingWithOptions method.
FirebaseApp.configure()
let configuration = FirebaseConfigurationProvider()
ExperimentManager.shared.configure(configurationProvider: configuration)
  1. add GoogleService-Info.plist from console.firebase.google.com and create RemoteConfigDefaults.plist file.

  2. Start working

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •