Vexil
Vexil copied to clipboard
Documentation on how to setup the `FlagValueSource` as a shared `UserDefaults` from the "Settings" app
In the documentation it is stated that we recommend that the view/Vexillographer be contained in its own app. This requires the user to setup an App Group, and then set the source in both the seperate app/target and in the app to be the shared UserDefaults file. While not super tricky to implement, I feel like it'd be nice to provide documentation on how to do that.
Happy to do it myself but wanted to flag (heh) the idea here first in case there's a reason why we shouldn't.
Hi @will-lumley - how are you mate? I am in a new app projec, where I am too keen to use Vexil with feature flags manager.
All docs working fine, understood the steps needed, and I managed to setup app-group to share UserDefaults between two app targets. But I ended up having the same issue that settings app does not let me change the flag values. And get stuck. You remembered how we managed that buggy issue in our plus app? Thanks mate, some tips (I just forgot how to) would really help me. 🙏🏽
cc- @bok-
Here is demo Gif below. It's all stuck . :( 😭
As first step, I managed to include the Vexilographer based SwiftUI view in the main app hidden in secret corner of the app. All worked perfectly then.
But as next next step, I tried to take that part out in a dedicated FiddleSettings app target using the same app-group.
eg. I have used static let sharedUserDefaults = UserDefaults(suiteName: "group.arinappy.my-life") as UserDefaults creation and shared the same like this below here and with the SwiftUI view that uses Vexilographer init()
static let sharedUserDefaults = UserDefaults(suiteName: "group.arinappy.next-to-go")!
public let flags = FlagPole(
hoist: AppFlags.self,
sources: [
Self.sharedUserDefaults,
// TODO: Add other sources (like the real one mapping from Remote system
// Refer to this documentation how to: https://vexil.unsignedapps.com/documentation/vexil/sources/
]
)
But got into this stuck situation.
I did a a few troubleshooting like (my app's min deployment iOS is 15)
- new simulators (old iOS and new iOS versions)
- reset simulator
- install main app first then install settings app next
- install settings app first and then install main app next
Actually, I have got it working now. 😀 Seems like I missed a step to attach the source precisely at one point.
Before: (not working :( )
private let flagPole = FlagPole(hoist: AppFlags.self)
...
Vexillographer(flagPole: flagPole, source: FlagService.sharedUserDefaults)
After: (working :) )
private let flagPole = FlagPole(hoist: AppFlags.self, sources: [FlagService.sharedUserDefaults])
...
Vexillographer(flagPole: flagPole, source: FlagService.sharedUserDefaults)
@arinjoy Glad you got it working. I am working on my own app on the side and ran into this exact issue - hence why this issue which I raised that advocates for clearer documentation.