-
Notifications
You must be signed in to change notification settings - Fork 255
[Blog] Swift Configuration 1.0 released #1264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
davelester
merged 13 commits into
swiftlang:main
from
czechboy0:hd-swift-configuration-1.0
Dec 11, 2025
+107
−1
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8ec1597
[Blog] Swift Configuration 1.0 blog post
czechboy0 252f0a8
More edits
czechboy0 d1113e8
Update _posts/2025-12-11-swift-configuration-1.0-released.md
davelester d505349
Update _posts/2025-12-11-swift-configuration-1.0-released.md
davelester e473097
Update _posts/2025-12-11-swift-configuration-1.0-released.md
davelester 5d403cc
Update _posts/2025-12-11-swift-configuration-1.0-released.md
davelester 092f390
PR feedback - _a_ common API vs _the_ common API
czechboy0 43e51df
PR feedback
czechboy0 884eace
PR feedback
czechboy0 3a6f238
PR feedback
czechboy0 43c0e31
More edits'
czechboy0 6ec99d3
Update _posts/2025-12-11-swift-configuration-1.0-released.md
davelester 0ec2607
Apply suggestions from code review
czechboy0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,106 @@ | ||
| --- | ||
| layout: new-layouts/post | ||
| published: true | ||
| date: 2025-12-11 10:00:00 | ||
| title: "Swift Configuration 1.0 released" | ||
| author: [honzadvorsky] | ||
| category: "Developer Tools" | ||
| --- | ||
|
|
||
| Every application has configuration: in environment variables, configuration files, values from remote services, command-line flags, or repositories for stored secrets like API keys. But until now, Swift developers have had to wire up each source individually, with scattered parsing logic and application code that is tightly coupled to specific configuration providers. | ||
|
|
||
| [**Swift Configuration**](https://github.com/apple/swift-configuration) brings a unified, type-safe approach to this problem for Swift applications and libraries. What makes this compelling isn’t just that it reads configuration files: plenty of libraries do that. It’s the clean abstraction that it introduces between _how_ your code accesses configuration and _where_ that configuration comes from. This separation unlocks something powerful: libraries can now accept configuration without dictating the source, making them genuinely composable across different deployment environments. | ||
|
|
||
| With the release of Swift Configuration 1.0, the library is production-ready to serve as a common API for reading configuration across the Swift ecosystem. Since the [initial release announcement](https://forums.swift.org/t/introducing-swift-configuration/82368) in October 2025 over **40 pull requests** have been merged, and its API stability provides a foundation to unlock community integrations. | ||
|
|
||
| ## Why it exists | ||
|
|
||
| Configuration management has long been a challenge across different sources and environments. Previously, configuration in Swift had to be manually stitched together from environment variables, command-line arguments, JSON files, and external systems. Swift Configuration creates a common interface for configuration, enabling you to: | ||
| - **Read configuration the same way across your codebase** using a single configuration reader API that's usable from both applications and libraries. | ||
| - **Quickly get started with a few lines of code** using simple built-in providers for environment variables, command-line arguments, JSON and YAML files. Later, when your configuration needs require a more sophisticated provider, swap it in easily, without refactoring your existing code. | ||
| - **Build and share custom configuration providers** using a public ConfigProvider protocol that anyone can implement and share. This allows domain experts to create integrations with external systems like secret stores and feature flagging services. | ||
|
|
||
| Swift Configuration excels in the Swift server ecosystem, where configuration is often read from multiple systems and tools. The library is equally useful in command-line tools, GUI applications, and libraries wherever flexible configuration management is needed. | ||
|
|
||
| For a step-by-step evolution of an example service, from hardcoded values all the way to a flexible provider hierarchy, check out the [video of my talk](https://www.youtube.com/watch?v=I3lYW6OEyIs) from the [ServerSide.swift conference](https://www.serversideswift.info/) in London. | ||
|
|
||
| ## Getting started | ||
|
|
||
| After adding a package dependency to your project, reading configuration values requires just a couple of lines of code. For example: | ||
|
|
||
| ```swift | ||
| import Configuration | ||
|
|
||
| let config = ConfigReader(provider: EnvironmentVariablesProvider()) | ||
| let timeout = config.int(forKey: "http.timeout", default: 60) | ||
| ``` | ||
|
|
||
| However, Swift Configuration's core strength is its ability to combine _multiple_ configuration providers into a clear, predictable hierarchy, allowing you to establish sensible defaults while providing clean override mechanisms for different deployment scenarios. | ||
|
|
||
| For example, if you have default configuration in JSON: | ||
|
|
||
| ```json | ||
| { | ||
| "http": { | ||
| "timeout": 30 | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| And want to be able to provide an override using an environment variable: | ||
|
|
||
| ```bash | ||
| # Environment variables: | ||
| HTTP_TIMEOUT=15 | ||
| ``` | ||
|
|
||
| Then what we have are two Swift Configuration "providers", and we can layer them: | ||
|
|
||
| ```swift | ||
| let config = ConfigReader(providers: [ | ||
| EnvironmentVariablesProvider(), | ||
| try await FileProvider<JSONSnapshot>(filePath: "/etc/config.json") | ||
| ]) | ||
| let timeout = config.int(forKey: "http.timeout", default: 60) | ||
| print(timeout) // 15 | ||
| ``` | ||
|
|
||
| Providers are checked in the order you specify: earlier providers override later ones, followed by your fallback defaults. This removes ambiguity about which configuration source is actually being used. | ||
|
|
||
| ## Advanced capabilities | ||
|
|
||
| Beyond basic lookups, the library includes features for production environments: | ||
|
|
||
| * [Multiple access patterns](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration#Three-access-patterns) – choose between the synchronous, asynchronous, and watching patterns. | ||
| * [Hot reloading](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration#Hot-reloading) – apply configuration updates without restarting your service. | ||
| * [Namespacing and scoped readers](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration#Namespacing-and-scoped-readers) – organize configuration values through nesting. | ||
| * [Access logging](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration#Debugging-and-troubleshooting) – easily debug configuration issues through detailed observability. | ||
| * [Secret redaction](https://swiftpackageindex.com/apple/swift-configuration/documentation/configuration/handling-secrets-correctly) – avoid accidental exposure of sensitive configuration values. | ||
|
|
||
| The [documentation](https://swiftpackageindex.com/apple/swift-configuration/documentation) covers these features in detail. | ||
|
|
||
| ## Community adoption | ||
|
|
||
| With 1.0, the API is now stable. Projects can depend on Swift Configuration knowing only backward-compatible changes are expected going forward. API stability allows libraries and tools to rely on Swift Configuration as a common integration point for reading configuration. | ||
|
|
||
| Prior to the 1.0 release, a number of ecosystem projects have begun experimenting with and adopting Swift Configuration. Here are some examples of efforts in progress: | ||
|
|
||
| * [**In libraries**](https://swiftpackageindex.com/apple/swift-configuration/main/documentation/configuration/configuring-libraries): Expose configuration entry points built on [`ConfigReader`](https://swiftpackageindex.com/apple/swift-configuration/main/documentation/configuration/configreader), making your library easier to integrate. Projects experimenting with Swift Configuration include: | ||
| * [Vapor](https://github.com/vapor/vapor/pull/3403) | ||
| * [Hummingbird](https://github.com/hummingbird-project/hummingbird/pull/743) | ||
| * [Swift Temporal SDK](https://github.com/apple/swift-temporal-sdk) | ||
| * [**In applications**](https://swiftpackageindex.com/apple/swift-configuration/main/documentation/configuration/configuring-applications): Instantiate a [`ConfigReader`](https://swiftpackageindex.com/apple/swift-configuration/main/documentation/configuration/configreader) and pass it to your dependencies. Use any combination of [`ConfigProvider`](https://swiftpackageindex.com/apple/swift-configuration/main/documentation/configuration/configprovider) types - JSON/YAML files, environment variables, or remote systems. | ||
| * [Peekaboo](https://github.com/steipete/Peekaboo) | ||
| * [swiftodon](https://github.com/JonPulfer/swiftodon) | ||
| * [**By implementing custom providers**](https://swiftpackageindex.com/apple/swift-configuration/main/documentation/configuration/configprovider): Extend the ecosystem with new formats or external sources by implementing a [`ConfigProvider`](https://swiftpackageindex.com/apple/swift-configuration/main/documentation/configuration/configprovider). Examples of experimental providers: | ||
| * [Swift Configuration TOML](https://github.com/finnvoor/swift-configuration-toml) | ||
| * [Vault Courier](https://github.com/vault-courier/vault-courier) | ||
| * [Swift Configuration AWS](https://github.com/SongShift/swift-configuration-aws) | ||
|
|
||
| ## Next steps | ||
|
|
||
| With a stable foundation in place, libraries and applications can begin finalizing their own integrations and releasing API-stable versions built on Swift Configuration. | ||
|
|
||
| Try integrating Swift Configuration into your applications, tools, and libraries, check out the project's [documentation](https://swiftpackageindex.com/apple/swift-configuration/documentation), and continue sharing feedback from your real-world experience on the [GitHub repository](https://github.com/apple/swift-configuration) through issues, pull requests, or [Swift Forums](https://forums.swift.org/c/related-projects/swift-configuration/123) discussions. | ||
|
|
||
| Happy configuring! ⚙️ | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.