-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e594b1
commit 0ad5d7f
Showing
9 changed files
with
169 additions
and
59 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# file options | ||
|
||
--exclude Tests/XCTestManifests.swift,DerivedData | ||
|
||
# format options | ||
|
||
--allman false | ||
--binarygrouping 4,8 | ||
--commas always | ||
--comments indent | ||
--decimalgrouping 3,6 | ||
--elseposition same-line | ||
--empty void | ||
--exponentcase lowercase | ||
--exponentgrouping disabled | ||
--fractiongrouping disabled | ||
--header strip | ||
--hexgrouping 4,8 | ||
--hexliteralcase uppercase | ||
--ifdef indent | ||
--indent 4 | ||
--indentcase false | ||
--importgrouping testable-bottom | ||
--linebreaks lf | ||
--maxwidth none | ||
--octalgrouping 4,8 | ||
--operatorfunc spaced | ||
--patternlet hoist | ||
--ranges spaced | ||
--self remove | ||
--semicolons inline | ||
--stripunusedargs always | ||
--swiftversion 5.5 | ||
--trimwhitespace always | ||
--wraparguments preserve | ||
--wrapcollections preserve | ||
|
||
# rules | ||
|
||
--enable isEmpty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,76 @@ | ||
# FeatureFlag | ||
<h1 align="center">🛠Configs</h1> | ||
<p align="center">A quick, easy and elegant solution for your remote and dev configuration.</p> | ||
<p align="center"> | ||
<a href="https://codecov.io/gh/michaelhenry/XConfigs"><img alt="codecov" src="https://codecov.io/gh/michaelhenry/XConfigs/branch/main/graph/badge.svg?token=WLH8VVA19I"/></a> | ||
<a href="https://github.com/michaelhenry/XConfigs/actions"><img alt="test" src="https://github.com/michaelhenry/XConfigs/workflows/test/badge.svg"></a> | ||
<a href="https://github.com/michaelhenry/XConfigs/releases/latest"><img alt="release" src="https://img.shields.io/github/v/release/michaelhenry/XConfigs.svg"/></a> | ||
<a href="https://developer.apple.com/swift"><img alt="Swift5" src="https://img.shields.io/badge/language-Swift5-orange.svg"></a> | ||
<a href="https://developer.apple.com"><img alt="Platform" src="https://img.shields.io/badge/platform-iOS-green.svg"></a> | ||
<a href="LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-black.svg"></a> | ||
</p> | ||
|
||
A description of this package. | ||
--- | ||
|
||
- [Introduction](#introduction) | ||
- [Getting Started](#getting-started) | ||
- [Example](#example) | ||
- [Other Related](#other-related) | ||
- [License](#license) | ||
|
||
--- | ||
|
||
## Introduction | ||
|
||
As part of software development process, we always need to see how our app will react depending on the different scenarios or configurations especially during testing. At the same time, it would be better if we can control some of app configurations on the fly, especially if there are unexpected things happened in our production environment, we can immediately enable or disable certain app functionality. | ||
|
||
## Getting Started | ||
|
||
Install using SPM | ||
|
||
```swift | ||
.package(url: "https://github.com/michaelhenry/XConfigs", .upToNextMinor(from: "1.0.0")), | ||
``` | ||
|
||
## Example | ||
|
||
Similar with logger tool such as [swift-log](https://github.com/apple/swift-log), You can simply create a single global variable or just a singleton, as long as the it conforms to [XConfigSpec](Sources/XConfigs/Protocols/XConfigsSpec.swift) and then use the `@XConfig` property wrapper inside it. | ||
|
||
If you have some custom datatype, you can simply conform them to `RawStringValueRepresentable`. | ||
|
||
```swift | ||
struct MockConfigs: XConfigSpec { | ||
|
||
@XConfig(key: "isOnboardingEnabled", defaultValue: false) | ||
var isOnboardingEnabled: Bool | ||
|
||
@XConfig(key: "apiURL", defaultValue: URL(string: "https://google.com")!) | ||
var apiURL: URL | ||
|
||
@XConfig(key: "region", defaultValue: .north) | ||
var region: Region | ||
|
||
@XConfig(key: "maxRetry", defaultValue: 10) | ||
var maxRetry: Int | ||
|
||
@XConfig(key: "threshold", defaultValue: 1) | ||
var threshold: Int | ||
|
||
@XConfig(key: "rate", defaultValue: 2.5) | ||
var rate: Double | ||
} | ||
|
||
enum Region: String, CaseIterable, RawStringValueRepresentable { | ||
case north | ||
case south | ||
case east | ||
case west | ||
} | ||
``` | ||
|
||
## Other Related | ||
|
||
- [Firebase Remote Config](https://firebase.google.com/docs/remote-config), you can simply backed [XConfigs](https://github.com/michaelhenry/XConfigs) by FirebaseRemoteConfig by simply implmenting [KeyValueProvider](Sources/XConfigs/Protocols/KeyValueProvider.swift) protocol. | ||
|
||
## LICENSE | ||
|
||
MIT |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
brew install swiftformat && \ | ||
npm install --global git-format-staged && \ | ||
echo '#!/bin/bash\ngit-format-staged --formatter "swiftformat stdin --stdinpath \x27{}\x27" "*.swift"' > '.git/hooks/pre-commit' && \ | ||
chmod +x .git/hooks/pre-commit && \ | ||
git config --global core.hooksPath '~/.githooks' |