- FRemocon can get the FirebaseRemoteConfig value type-safely by using Key Path Member Lookup
- This repository is inspired by sunshinejr/SwiftyUserDefaults, sgr-ksmt/Lobster
- Xcode 12.4 or greater
- Swift 5.3 or greator
Add the following code in Package.swift.
dependencies: [
.package(url: "https://github.com/funzin/FRemocon.git", from: "0.1.0"),
]Add the following code in Podfile.
pod 'FRemocon'
- Add the key set in Firebase RemoteConfig as
ConfigKey
extension ConfigKeys {
var text: ConfigKey<String> { .init(key: "text", defaultValue: "defaultValue") }
var flag: ConfigKey<Bool> { .init(key: "flag", defaultValue: false) }
var intNumber: ConfigKey<Int> { .init(key: "intNumber", defaultValue: 1) }
}- The value will be accessible through
ConfigKey
let remoteConfig = FRemocon.shared
remoteConfig.fetch() { (status, error) -> Void in
if status == .success {
print("Config fetched!")
remoteConfig.activate() { (changed, error) in
// Value obtained by RemoteConfig
let text: String = remoteConfig.text
print(text: \(text))
}
} else {
print("Config not fetched")
print("Error: \(error?.localizedDescription ?? "No error available.")")
}
self.displayWelcome()
}Currently support the following types
| Name |
|---|
| Int |
| Float |
| Double |
| String |
| Coudable |
| RawRepresentable |
Can get / set the FirebaseRemoteConfig value by using Key Path Member Lookup.
// before
let lastFetchStatus = RemoteConfig.remoteConfig().lastFetchStatus
// after
let lastFetchStatus = FRemocon.shared.lastFetchStatus// before
RemoteConfig.remoteConfig().configSettings = RemoteConfigSettings()
// after
FRemocon.shared.configSettings(RemoteConfigSettings())Use GoogleService-Info similar to mock-GoogleService-Info
git clone https://github.com/funzin/FRemoconopen FRemocon.xcodeproj
If you discover problem or have some opinions, please let me know through Github issues💁♂️
funzin
- mail: [email protected]
Rimuru is available under the MIT license. See the LICENSE file for more info.
