Swiftpack.co -  kradalby/Config.swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
kradalby/Config.swift
Tiny structure for dealing with JSON configs in swift
.package(url: "https://github.com/kradalby/Config.swift.git", from: "0.0.3")

Config.swift

Tiny wrapper/functions for creating a configuration struct that can be read from file.

The structure of this might not be a good idea, currently testing/learning swift.

Idea

The following config.json:

{
  "name": "sample",
  "people": ["Kristoffer Andreas Dalby"],
  "resolutions": [1200, 1000, 800, 300],
  "jpegCompression": 0.2,
  "inputPath": "sample",
  "outputPath": "out",
  "fileExtentions": ["jpg", "jpeg", "JPG", "JPEG"]
}

Can be read into a struct in Swift:

import Config

public struct GalleryConfiguration: Configuration {
    var name: String
    var people: [String]
    var resolutions: [Int]
    var jpegCompression: Double
    var inputPath: String
    var outputPath: String
    var fileExtentions: [String]
}

let config = Config.readConfig(configFormat: GalleryConfiguration.self, atPath: "config.json")

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