Bare-bones remote configs for iOS. Check out the basic-remote-configs project repo for more context.
🚧 Under active development 🚧
Either add it via File -> Add Package
or in your Package.swift
file:
https://github.com/BradPatras/brc-ios
The usage is pretty straightforward:
- Create an instance of BasicRemoteConfigs
- Call
.fetchConfigs()
. (This is anasync
function so you'll need to call it with await) - Access your configs.
let configUrl = URL(string: "https://github.com/BradPatras/basic-remote-configs/raw/main/examples/simple.json")!
// #1
let brc = BasicRemoteConfigs(configURL: configUrl)
// ...
try await brc.fetchConfigs() // #2
let someFlag = brc.values["someFlag"] as? Bool // #3
Configs are stored locally in the app's private storage once they've been fetched from the network. Calling .fetchConfigs()
will fetch the locally cached version of configs if either of the following are true:
- The cache exists and is not expired (cache expires after one day)
- The call to fetch configs from the network failed for any reason.
If you'd like to bypass the cached version and fetch the latest configs from the network, there's an optional param available.
brc.fetchConfigs(ignoreCache: Bool)
The call to .fetchConfigs()
may make a network request and do some deserialization, so it's bound to fail at some point. It won't do any handling or masking of the exceptions so you need to wrap it in a do/catch and handle it yourself.
do {
try await brc.fetchConfigs()
} catch {
// What happens here is up to you
}