Swiftpack.co -  chojnac/Shunter as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
chojnac/Shunter
Shunter is a small framework enabling feature flags in your project.
.package(url: "https://github.com/chojnac/Shunter.git", from: "0.1.0")

Shunter

GitHub license

Shunter is a small framework enabling feature flags in your project.

Motivation

A feature flag is a very simple but yet powerful concept. It enables developers to merge code earlier, demonstrate "unfinished" features or ships alternative code paths. Also with companion remote server - it gives a way to disable "problematic" new feature in the production builds.

All this helps to increase the speed of development and validating new ideas.

The goal of this library is to provide a very simple solution to quickly plugin feature flags in your project.

Features

  • Simple and small
  • Define features default state (on/off)
  • UI for overriding settings in the development/test environment.

Requirements

  • iOS 11.0+ / macOS 10.12+
  • Xcode 10.2+
  • Swift 5+

Installation

CocoaPods

Add the pod to your Podfile:

pod 'Shunter'

And then run:

pod install

After installing the cocoapod into your project import library with

import Shuter

Usage

A feature is a type containing an identifier and a comment.

The best way to group all features in one place is to create static properties in an extension on the Feature type. For example:

import Shunter

extension Feature {
    public static let feature01Feature = Feature("ios_feature01", comment: "Example feature #01")
    public static let feature02Feature = Feature("ios_feature02", comment: "Example feature #02")
}

The recommended place to initialize the FeatureManager for the iOS application is the AppDelegate. The example below shows the manager set up with disabled shake action for the Release build.

#if DEBUG
let showOverrideScreenOnShake = true
#else
let showOverrideScreenOnShake = false
#endif
FeatureManager.setup(
    configuration: .defaultConfiguration(showOverrideScreenOnShake: showOverrideScreenOnShake),
    features: [
        .feature01Feature: false,
        .feature02Feature: true
    ])

The example of how to check feature status in your code:

if FeatureManager.shared.isEnabled(.feature02Feature) {
    // enable your feature 
} else {
    // the feature is disabled
}

or shorter version:

if FeatureManager.shared[.feature02Feature] {
// enable your feature 
} else {
// the feature is disabled
}

You will find more code examples in the Demo application.

Author

Wojciech Chojnacki

License

This project is licensed under the MIT License - see the LICENSE.md file for details

GitHub

link
Stars: 0
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API