FlagGen lets you define feature flags once in code, and get:
- A screen in the iOS Settings app so QA/Debug builds can flip flags without a rebuild.
- A single, typed Swift API (
FeatureFlags.default.myFlag) the rest of your app reads from.
Two packages are involved, and it's easy to mix them up:
FlagGen(this repository) — a library of property wrappers (@FeatureFlagToggle,@FeatureFlagEnum, …) plus a small code generator.FeatureFlags— a small package you create in your own project. Declare your app's flags using FlagGen's property wrappers, and FlagGen's generator turns that into a.plistyour app embeds in its Settings bundle.
A complete, working example of both lives in Example/ — a little pet-shop app. The integration guide below references it directly.
Flags are properties on your FeatureFlags struct, declared with a property wrapper. The simplest is a toggle:
@FeatureFlagToggle(defaultValue: true, key: "name_of_key_enabled", title: "Name displayed in Settings App (optional)")
public var exampleToggleEnabled: BoolFlagGen has more property wrappers beyond @FeatureFlagToggle — enums, radio groups, sliders, read-only info rows, section headers, and nested settings screens. See Defining Feature Flags for more detail.
In the app, import your generated FeatureFlags package, then simply:
import FeatureFlags
if FeatureFlags.default.exampleToggleEnabled {
doThing()
}To react live to a flag changing while the app is running (e.g. right after the user flips it in Settings), use the publisher each property wrapper exposes via its projected value, e.g. $exampleToggleEnabled.publisher (backed by LocalProvider.publisher(for:)).
See the Integration doc for a full step-by-step walkthrough — adding the package, creating your own FeatureFlags package, generating the .plist, wiring up the Settings Bundle build phase, and the Xcode settings (like User Script Sandboxing) it depends on. Every step is cross-referenced against Example/.
LocalProvider (UserDefaults-backed) is the only provider FlagGen ships, but ProviderType is open for extension so you can register your own — see Custom Providers for worked LaunchDarkly and Firebase Remote Config examples.
