Using Remote Config with Property Wrappers in Swift
Article Summary
Timotius Leonardo Lianoto from IDN Engineering just solved a problem most iOS teams don't even realize they have: Remote Config is quietly eating memory and creating testing nightmares.
After shipping his initial Remote Config helper, Timotius discovered critical issues: JSON parsing on every fetch consumed excessive memory, testing relied on fragile string literals, and manual dependency injection across hundreds of classes became unsustainable. His solution? A Swift property wrapper that caches values, enables real-time updates, and makes testing actually pleasant.
Key Takeaways
- Property wrapper caches parsed values, eliminating redundant JSON parsing per fetch
- Real-time Firebase updates work by clearing cache on config changes
- Testing uses type-safe models instead of brittle JSON strings
- Automatic value retrieval removes manual injection across classes
The @FirebaseConfig property wrapper transforms Remote Config from a memory-hungry, test-hostile pattern into a cached, type-safe, self-updating system.
About This Article
Timotius Leonardo Lianoto's Remote Config helper was allocating memory for JSON parsing every time data was retrieved. Larger JSON payloads used more memory, and injecting MockRemoteConfig() manually across 1,000+ classes became tedious and wasteful.
He built a @FirebaseConfig property wrapper that caches parsed values in a shared MediumRemoteConfig instance. This eliminated redundant JSON decoding and let him inject dependencies through a single RemoteConfigProtocol interface.
The property wrapper's wrappedValue logic now returns cached data on subsequent accesses without re-parsing. A setListenerToUpdatedConfig() function clears specific cache keys when Firebase sends updates, keeping everything in sync without wasting memory.