{"id":31309309,"url":"https://github.com/apple/swift-configuration","last_synced_at":"2025-09-30T12:07:20.242Z","repository":{"id":316327091,"uuid":"1062815729","full_name":"apple/swift-configuration","owner":"apple","description":"API package for reading configuration.","archived":false,"fork":false,"pushed_at":"2025-09-23T23:20:19.000Z","size":226,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-24T01:18:11.187Z","etag":null,"topics":["configuration","server","swift"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/apple/swift-configuration/documentation","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apple.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE.txt","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T19:11:56.000Z","updated_at":"2025-09-23T23:42:10.000Z","dependencies_parsed_at":"2025-09-24T01:28:21.592Z","dependency_job_id":null,"html_url":"https://github.com/apple/swift-configuration","commit_stats":null,"previous_names":["apple/swift-configuration"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/apple/swift-configuration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-configuration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-configuration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-configuration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-configuration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apple","download_url":"https://codeload.github.com/apple/swift-configuration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-configuration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276872072,"owners_count":25719727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-25T02:00:09.612Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","server","swift"],"created_at":"2025-09-25T06:20:00.521Z","updated_at":"2025-09-26T07:06:04.225Z","avatar_url":"https://github.com/apple.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# Swift Configuration\n\n[![](https://img.shields.io/badge/docc-read_documentation-blue)](https://swiftpackageindex.com/apple/swift-configuration/documentation)\n[![](https://img.shields.io/github/v/release/apple/swift-configuration)](https://github.com/apple/swift-configuration/releases)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fapple%2Fswift-configuration%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/apple/swift-configuration)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fapple%2Fswift-configuration%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/apple/swift-configuration)\n\nA Swift library for reading configuration in applications and libraries.\n\n- 📚 **Documentation** is available on the [Swift Package Index](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration).\n- 💻 **Examples** are available [just below](#Examples), in the [Examples](Examples/) directory, and on the [Example use cases](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/example-use-cases) page.\n- 🚀 **Contributions** are welcome, please see [CONTRIBUTING.md](CONTRIBUTING.md).\n- 🪪 **License** is Apache 2.0, repeated in [LICENSE](LICENSE.txt).\n- 🔒 **Security** issues should be reported via the process in [SECURITY.md](SECURITY.md).\n\n## Overview\n\nSwift Configuration defines an abstraction layer between configuration [readers](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/configreader) and [providers](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/configprovider).\n\nApplications and libraries _read_ configuration through a consistent API, while the actual _provider_ is set up once at the application's entry point.\n\n## Examples\n\nSwift Configuration allows you to combine multiple providers in a hierarchy, where values from higher-priority sources override those from lower-priority ones.\n\nFor example, if you have a default configuration in JSON:\n```json\n{\n  \"http\": {\n    \"timeout\": 30\n  }\n}\n```\nAnd want to be able to provide an override for that using an environment variable:\n\n```env\n# Environment variables:\nHTTP_TIMEOUT=15\n```\n\nThe example code below creates the two relevant providers, and resolves them in the order you list:\n\n```swift\nlet config = ConfigReader(providers: [\n    EnvironmentVariablesProvider(),\n    try await JSONProvider(filePath: \"/etc/config.json\")\n])\nlet httpTimeout = config.int(forKey: \"http.timeout\", default: 60)\nprint(httpTimeout) // prints 15\n```\n\nThe resolved configuration value is `15` from the environment variable. Without the environment variable, it would use `30` from the JSON file.\nIf both sources are unavailable, the fallback default of `60` is returned.\n\n\u003e Tip: More example use cases are described in [example use cases](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/example-use-cases), and complete working examples are available in the [Examples](Examples/) directory.\n\n## Quick start\n\n\u003e Important: While this library's API is still in development, use the `.upToNextMinor(from: \"...\")` dependency constraint to avoid unexpected build breakages. Before we reach 1.0, API-breaking changes may occur between minor `0.x` versions.\n\nAdd the dependency to your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/apple/swift-configuration\", .upToNextMinor(from: \"0.1.0\"))\n```\n\nAdd the library dependency to your target:\n\n```swift\n.product(name: \"Configuration\", package: \"swift-configuration\")\n```\n\nImport and use in your code:\n\n```swift\nimport Configuration\n\nlet config = ConfigReader(provider: EnvironmentVariablesProvider())\nlet httpTimeout = config.int(forKey: \"http.timeout\", default: 60)\nprint(\"The HTTP timeout is: \\(httpTimeout)\")\n```\n\n## Getting started guides\n- [Configuring applications](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/configuring-applications)\n- [Configuring libraries](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/configuring-libraries)\n\nFor more, check out the full [documentation](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration).\n\n## Package traits\n\nThis package offers additional integrations you can enable using [package traits](https://docs.swift.org/swiftpm/documentation/packagemanagerdocs/addingdependencies#Packages-with-Traits).\nTo enable an additional trait on the package, update the package dependency:\n\n```diff\n.package(\n    url: \"https://github.com/apple/swift-configuration\",\n    .upToNextMinor(from: \"0.1.0\"),\n+   traits: [.defaults, \"OtherFeatureSupport\"]\n)\n```\n\nAvailable traits:\n- **`JSONSupport`** (default): Adds support for `JSONProvider`, a `ConfigProvider` for reading JSON files.\n- **`LoggingSupport`** (opt-in): Adds support for `AccessLogger`, a way to emit access events into a `SwiftLog.Logger`.\n- **`ReloadingSupport`** (opt-in): Adds support for auto-reloading variants of file providers, such as `ReloadingJSONProvider` (when `JSONSupport` is enabled) and `ReloadingYAMLProvider` (when `YAMLSupport` is enabled).\n- **`CommandLineArgumentsSupport`** (opt-in): Adds support for `CommandLineArgumentsProvider` for parsing command line arguments.\n- **`YAMLSupport`** (opt-in): Adds support for `YAMLProvider`, a `ConfigProvider` for reading YAML files.\n\n## Supported platforms and minimum versions\n\nThe library is supported on macOS, Linux, and Windows.\n\n| Component     | macOS  | Linux, Windows | iOS    | tvOS   | watchOS | visionOS |\n| ------------- | -----  | -------------- | ---    | ----   | ------- | -------- |\n| Configuration | ✅ 15+ | ✅              | ✅ 18+ | ✅ 18+ | ✅ 11+   | ✅ 2+    |\n\n## Configuration providers\n\nThe library includes comprehensive built-in provider support:\n\n- Environment variables: [`EnvironmentVariablesProvider`](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/environmentvariablesprovider)\n- Command-line arguments: [`CommandLineArgumentsProvider`](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/commandlineargumentsprovider)\n- JSON file: [`JSONProvider`](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/jsonprovider) and [`ReloadingJSONProvider`](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/reloadingjsonprovider)\n- YAML file: [`YAMLProvider`](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/yamlprovider) and [`ReloadingYAMLProvider`](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/reloadingyamlprovider)\n- Directory of files: [`DirectoryFilesProvider`](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/directoryfilesprovider)\n- In-memory: [`InMemoryProvider`](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/inmemoryprovider) and [`MutableInMemoryProvider`](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/mutableinmemoryprovider)\n- Key transforming: [`KeyMappingProvider`](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/keymappingprovider)\n\nYou can also implement a custom [`ConfigProvider`](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/configprovider) for specialized configuration formats and sources.\n\n## Key features\n- [3 access patterns: synchronous, asynchronous, and watching](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration#Three-access-patterns)\n- [Provider hierarchy](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration#Provider-hierarchy)\n- [Hot reloading/watching value updates](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration#Hot-reloading)\n- [Namespacing and scoped readers](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration#Namespacing-and-scoped-readers)\n- [Debugging and troubleshooting](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration#Debugging-and-troubleshooting)\n- [Redaction of secrets](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/handling-secrets-correctly)\n- [Consistent snapshots](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration#Consistent-snapshots)\n- [Custom key syntax](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration#Custom-key-syntax)\n\n## Documentation\n\nComprehensive documentation is hosted on the [Swift Package Index](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapple%2Fswift-configuration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapple%2Fswift-configuration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapple%2Fswift-configuration/lists"}