Add a "list" TweakType
bryanjclark opened this issue · 8 comments
Sometimes, you want to have a feature flag that has multiple options - for example, you might have 3 environments to point against (e.g. test, stage, production) and want to switch between them.
A couple of ideas for implementing this:
- A protocol,
TweakableEnum
, that can be used in a tweak easily. The protocol would probably require astatic var caseNames: [String]
to list out the options in the Tweaks UI. We'd also probably want a failable-init that returns the correctenum case
for a givenString
(so that the enum can "look up" a persisted stringly-typed value.) This might depend on us building #14 first (adding String as a TweakableType). - Use a tweak template to support lists.
- Make a tweak that simply holds a
[String]
and optionally has a default value (asserting if the default value doesn't exist in the array, and if no default given, uses the first value in the array). Leave it to the implementer to switch on the current value of the string - they can always build a string-based enum and init withrawValue:
to get away from stringly-based stuff.
Anyhow, I've not yet tried building this out yet, so I dunno what will be easy-to-understand-and-implemented here. One goal for SwiftTweaks is to keep tweak libraries simple and straightforward - so while I'm inclined to do the "most precise and Swifty thing", it's even more important that SwiftTweaks remains easy-to-use for new folks, so that'll be a big criteria in evaluating which one of these will work!
This would be an awesome facility - really state-of-the-art!
@bryanjclark Any update on adding support for this ?
@Priyatham51 @DanielAsher it's now in there! Check out StringOption
, courtesy of @jaredly
hi, im using pod 'SwiftTweaks' and there are no tweak type StringOption
. I check in branch 'master' there is available StringOption
. Should i specify the pods to get from branch 'master'?
@hendyevan we need to update the official podspec to include these commits by making a new release! In the meantime, you can specify which commit you want Cocoapods to use in your Podfile
any update for this?
@billionssg this shipped two years ago... can you be more descriptive? What’s missing?
I only can find StringOption
from master
branch, can you merge it on version > 4?