ExperimentKit simplify A/B testing and working with Remote Config, freeing you up to focus on the more important things.
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 = settingsremoteConfig.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()
}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
}
}let remoteString = remoteConfig["some_key"].stringValue
label.text = remoteStringlabel.addExperiment(forKey: "some_key", as: String.self) { object, remoteString in
DispatchQueue.main.async {
self.label.text = remoteString
}
}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)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)
}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"
}- Clone this repo inside your project folder.
- Add
target "Change Me!" do
pod "'ExperimentKit'", ::git => 'https://github.com/iOSerler/ExperimentKit', :branch => 'master'
end- Run
pod installpod update- import framework & configure it (Firebase example) inside AppDelegate's didFinishLaunchingWithOptions method.
FirebaseApp.configure()
let configuration = FirebaseConfigurationProvider()
ExperimentManager.shared.configure(configurationProvider: configuration)-
add GoogleService-Info.plist from console.firebase.google.com and create RemoteConfigDefaults.plist file.
-
Start working