Skip to content

Commit

Permalink
Initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
johankool committed Feb 6, 2024
0 parents commit e832725
Show file tree
Hide file tree
Showing 13 changed files with 958 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# Accio dependency management
Dependencies/
.accio/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Egeniq

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 32 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"pins" : [
{
"identity" : "app-remote-config",
"kind" : "remoteSourceControl",
"location" : "https://github.com/egeniq/app-remote-config",
"state" : {
"revision" : "57b8c68082d4e3ec52fe68387229064f846485d8",
"version" : "0.0.2"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
"version" : "1.3.0"
}
},
{
"identity" : "yams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams.git",
"state" : {
"revision" : "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3",
"version" : "5.0.6"
}
}
],
"version" : 2
}
29 changes: 29 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version: 5.9

import PackageDescription

let package = Package(
name: "care",
defaultLocalization: "en",
platforms: [.iOS(.v15), .macOS(.v12), .tvOS(.v15), .watchOS(.v8), .macCatalyst(.v15)],
products: [
.executable(
name: "care",
targets: ["care"]
)
],
dependencies: [
.package(url: "https://github.com/egeniq/app-remote-config", from: "0.0.2"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.6")
],
targets: [
.executableTarget(
name: "care",
dependencies: [
.product(name: "AppRemoteConfig", package: "app-remote-config"),
.product(name: "Yams", package: "Yams"),
.product(name: "ArgumentParser", package: "swift-argument-parser")
]),
]
)
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# AppRemoteConfig

Configure apps remotely: A simple but effective way to manage apps remotely.

Create a simple configuration file that is easy to maintain and host, yet provides important flexibility to specify settings based on your needs.

## Schema

The JSON/YAML schema is defined [here](https://raw.githubusercontent.com/egeniq/app-remote-config/main/Schema/appremoteconfig.schema.json).

## CLI Utility

Use the `care` CLI utility to initialize, verify, resolve and prepare configuration files.

To install use:

brew install egeniq/app-utilities/care

## Multiplatform

### Swift

Import the package in your `Package.swift` file:

.package(url: "https://github.com/egeniq/app-remote-config", from: "0.0.2"),

Then a good approach is to create your own `AppRemoteConfigClient`.

// App Remote Config
.target(
name: "AppRemoteConfigClient",
dependencies: [
.product(name: "AppRemoteConfigMacros", package: "app-remote-config"),
.product(name: "AppRemoteConfigService", package: "app-remote-config"),
.product(name: "Dependencies", package: "swift-dependencies"),
.product(name: "DependenciesAdditions", package: "swift-dependencies-additions"),
.product(name: "DependenciesMacros", package: "swift-dependencies"),
.product(name: "Perception", package: "swift-perception")
]
)
Using these dependencies:

.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swift-perception", from: "1.0.0"),
.package(url: "https://github.com/tgrapperon/swift-dependencies-additions", from: "1.0.0")
Then your `AppRemoteConfigClient.swift` is something like this:

import AppRemoteConfigService
import AppRemoteConfigMacros
import Dependencies
import DependenciesMacros
import Foundation
import Perception

@AppRemoteConfigValues @Perceptible
public class Values {
public private(set) var updateRecommended: Bool = false
public private(set) var updateRequired: Bool = false
}

@DependencyClient
public struct AppRemoteConfigClient {
public var values: () -> Values = { Values() }
}

extension DependencyValues {
public var configClient: AppRemoteConfigClient {
get { self[AppRemoteConfigClient.self] }
set { self[AppRemoteConfigClient.self] = newValue }
}
}

extension AppRemoteConfigClient: TestDependencyKey {
public static let testValue = Self()
}

extension AppRemoteConfigClient: DependencyKey {
public static let liveValue = {
let url = URL(string: "https://www.example.com/config.json")!
let values = Values()
let service = AppRemoteConfigService(url: url, apply: values.apply(settings:))
return Self(values: { values })
}()
}

### Android

Support for Android can be found [here](https://github.com/egeniq/app-remote-config-android).
21 changes: 21 additions & 0 deletions Sources/care/ANSIEffect.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Foundation

enum ANSIEffect: String {
case bold = "\u{001B}[0;1m"
case faint = "\u{001B}[0;2m"
case black = "\u{001B}[0;30m"
case red = "\u{001B}[0;31m"
case green = "\u{001B}[0;32m"
case yellow = "\u{001B}[0;33m"
case blue = "\u{001B}[0;34m"
case magenta = "\u{001B}[0;35m"
case cyan = "\u{001B}[0;36m"
case white = "\u{001B}[0;37m"
case `default` = "\u{001B}[0;0m"
}

extension DefaultStringInterpolation {
mutating func appendInterpolation<T: CustomStringConvertible>(_ value: T, effect: ANSIEffect) {
appendInterpolation("\(effect.rawValue)\(value)\(ANSIEffect.default.rawValue)")
}
}
6 changes: 6 additions & 0 deletions Sources/care/Error.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

enum CareError: Error {
case unexpectedData
case invalidDate
}
Loading

0 comments on commit e832725

Please sign in to comment.