Feature flags allow software developers to experiment with new features or changes by hiding or exposing functionality while the software is in development. The document discusses implementing feature flags by using build configurations and conditional compilation to produce different versions from the same codebase. It provides examples of using feature flags for minor UI changes like changing colors or text, and major UI changes like using different views. Tests should test both the original code with feature flags disabled and new code with them enabled.
4. A set of constants
that hide or expose
functionality while
it is on development
5. It is all
about
features
Feature: a characteristic of your
product (has/is)
User Story: a feature from the
perspective of the end-user
Display list of items
Receive notifications about data changes
Add a new item to the list
Persist data locally
New look and feel
Sync with other devices
Animations and eye-candy
…
9. It is all
about
branching
Git Flow:
• Main, develop, feature, release, hot-fix…
• Long-lived branches
• Feature code reviews
GitHub Flow:
• Main & feature branches
• Long-lived branches still possible
• Feature code reviews
(Scaled) Trunk-Based Development:
• Trunk/main, releases
• Daily/very frequent
• Smaller code reviews (WIP)
10. Why not JUST Coding?
Features need time and most likely several steps to complete adding the required code
Fixes might be needed while developing the feature
Some features get discarded after being implemented
Even if they get accepted, they may require
• Some process and
• Waiting for the next version
You need to address your different target audiences: your tests, QA, beta tester production
16. Requirements for the Flag Variables
• Produce different builds for the different audiences from the same codebase
• A feature starts being developed in alpha and it is disabled for any other build
• It is enabled for the next stage when the previous stage is completed
17. Building with Xcode
List of files (code &
resources) to generate a
product
Target
A set of settings
applied to targets
Build Configurations
Defines actions
combining target and
configuration
Scheme
SWIFT_ACTIVE_COMPILATION_CONDITIONS
18. Evolution of a Feature Flag
Release
Beta
QA
Alpha
Release
Debug
❌
✅ ❌ ❌
Development
Clean up ➖
Internal test ✅ ❌ ❌
✅
External test ✅ ❌
✅ ✅
Release ✅ ✅ ✅ ✅
➖ ➖ ➖
19. Xcode
Trickery
Don’t use targets to have different files
for the flags
Use build configurations for each
development stage
Use xcconfig files for each stage, to
enable the flags and use include for
other settings
Configurations can be tuned exposing
$(CONFIGURATION) in Info.plist
Use Product Bundle Identifier if you
want more than one version running on
the same device
21. Static vs
Dynamic
Static
• Removes unused code
• Fully controlled by development
• Defined in the project
Dynamic
• All code paths are in the binary
• Behavior can be changed without
rebuilding
• Controlled from elsewhere
23. Three Common Scenarios
Change some logic or how
a layer is implemented
Logic or layer impl.
Change color, text,
position, but keep the
“same” UI structure
Minor View Change
Increase or reduce the
number of views used to
interact with the user
Mayor View Change
31. Summary
Feature flags allow to be agile
• Evolve your code without causing disruptions
• Change priorities on the fly
• Tune up deployment
Implementation is easy
• Build configurations
• xcconfig for each of the configuration
• If expression to choose between old and new implementation
Use feature flags not just for domain logic, but alternative implementations, and different UIs