Declarative @Settings models, batched secret hygiene, and configuration provenance for Swift 6.
Rigging is the application-level settings and secret-management layer for Swift CLIs, macOS developer & automation tools, and Swift Server services (with full Apple-platform, SwiftUI @Rigged, and macOS MDM support).
Declare one typed Swift struct and get an 8-layer CLI → env → .env → config cascade, exhaustive fail-all-at-once startup validation, single-prompt 1Password & Keychain secret resolution, per-field $field provenance, and turnkey config show / doctor / schema / init commands—bringing pydantic-settings ergonomics and defense-in-depth secret hygiene natively to Swift 6.
- Typed
@SettingsModels & Exhaustive Startup Validation — Compile-timeswift-syntaxmacros synthesize loading, schema export, and$fieldprovenance with zero runtimeMirrorreflection inRiggingCore. Instead of halting on the first missing key, Rigging collects every missing, invalid, unknown-key, secret-safety, and cross-field error in one pass with deterministic CLI exit codes (2,4,6). - Production Secret Hygiene by Construction — Resolve
op://,keychain://,bws://,bw://,pass://,sops://,file://, andenv://references in deduplicated batches (1 biometric unlock per account), wrap payloads in leak-proofSecret<T>, block plaintext secrets in repo-committed config files, enforce0600file permissions, and materialize zero-wiped ephemeral.p8/PEM files viawithEphemeralFile. - Built-In Operability & Provenance — Inspect exactly where every value came from (
settings.$keyId.source) and what it shadowed (settings.$keyId.overriddenSources), or mountConfigSubcommand<MySettings>to give usersconfig show,config doctor,config schema, andconfig initin one line.
Swift already has two great foundational packages:
swift-argument-parserparses command-line flags and subcommands.apple/swift-configurationprovides a standardConfigReader/ConfigProviderabstraction with typed reads, file/env/CLI providers, secret markers, access reporting, and hot reloading—ideal for decoupling libraries from where configuration lives.
Rigging complements both as the opinionated application & CLI settings layer on top—and bridges cleanly with them in both directions:
| Capability | apple/swift-configuration |
Rigging |
|---|---|---|
| Primary role | Library & runtime ConfigReader provider abstraction |
Declarative application/CLI settings schema, validation & secret hygiene |
| Configuration model | Imperative key-by-key typed reads (reader.string(forKey:)) |
Compile-time @Settings / @Rigged Swift structs with defaults & nesting |
| Startup validation | Evaluated at individual read call sites | Exhaustive single-pass validation (field + cross-field + unknown keys, exit 2/4/6) |
| Project & CLI layering | Provider ordering (CommandLineArgumentsProvider, FileProvider, etc.) |
Non-clobbering ParsableArguments bridge (nil flags never shadow env), .env line tracking, upward .git discovery & profiles |
| Secret manager resolution | SecretsSpecifier + AccessReporter redaction; custom providers |
Built-in batched op:// (1 unlock), in-process keychain://, bws:///bw://, pass://, sops://, 0600 checks, repo-plaintext guard & withEphemeralFile |
| Provenance & CLI ops | AccessReporter access tracing |
Per-field $field.source + overriddenSources and turnkey config show / doctor / schema / init |
| Schema & template export | Manual | Generated Draft 2020-12 JSON Schema, .env.example, and Markdown docs from Swift types & /// comments |
First-class bridges:
RiggingArgumentParserbindsParsableArgumentsinto the cascade without unset defaults clobbering env/files, and mountsConfigSubcommand<MySettings>.RiggingSwiftConfigurationbridges bidirectionally: consume any upstreamConfigProviderviaSwiftConfigurationSource, or export validated, secret-resolved settings as a standardConfigReader(settings.asConfigReader()) withisSecret: truepreserved on every@SecretSetting.
Add Rigging to your Package.swift (Swift 6.2+, macOS 15+ / iOS 18+ / tvOS 18+ / watchOS 11+ / visionOS 2+ / Linux / Windows / Android / WASI):
dependencies: [
.package(url: "https://github.com/SamPetherbridge/Rigging.git", from: "0.4.1"),
],
targets: [
.executableTarget(
name: "my-cli",
dependencies: [
.product(name: "Rigging", package: "Rigging"),
.product(name: "RiggingOnePassword", package: "Rigging"),
.product(name: "RiggingKeychain", package: "Rigging"),
.product(name: "RiggingArgumentParser", package: "Rigging"),
]
),
.testTarget(
name: "MyCLITests",
dependencies: [
"my-cli",
.product(name: "RiggingTesting", package: "Rigging"),
]
),
]Link only the products your binary needs—RiggingCore and RiggingTOML have zero external link/runtime dependencies (Foundation only):
| Product | Target Dependencies | Purpose |
|---|---|---|
Rigging |
RiggingCore + swift-syntax (macro plugin) |
@Settings, @Rigged, @Setting, @SecretSetting, @NestedSettings |
RiggingCore |
None (Foundation only) |
Cascade engine, .env / JSON / plist / MDM / secrets-dir sources, Secret<T>, validators, JSON Schema & .env exporters |
RiggingOnePassword |
RiggingCore only |
Batched op:// resolution (op inject pipe & 1Password Connect REST API) |
RiggingKeychain |
RiggingCore + Security.framework |
Direct in-process keychain:// lookups with zero subprocesses |
RiggingBitwarden |
RiggingCore only |
bws:// (Secrets Manager) & bw:// (Vault CLI) secret resolution |
RiggingUnixPass |
RiggingCore only |
pass:// (~/.password-store) & sops:// (RFC 6901 JSON Pointer) resolution |
RiggingTOML |
RiggingCore only |
Pure-Swift TOML v1.0 parser & TOMLProjectConfigSource / TOMLUserConfigSource |
RiggingYAML |
RiggingCore + Yams |
YAML project/user config sources with profiles & << merge-key support |
RiggingArgumentParser |
RiggingCore + swift-argument-parser |
Non-clobbering ParsableArguments bridge & turnkey ConfigSubcommand |
RiggingSwiftConfiguration |
RiggingCore + apple/swift-configuration |
Bidirectional ConfigProvider / ConfigReader adapter |
RiggingTesting |
RiggingCore only |
Hermetic SettingsContext.inMemory, InMemoryFileSystem, and mock providers |
Platform notes: All targets compile across Apple platforms, Linux (
Glibc&Musl), Windows, Android, and WebAssembly (WASI). Platform-specific features degrade cleanly:KeychainProviderrequires AppleSecurity.framework,ManagedPreferencesSourcerequires macOSCFPreferences,RiggingYAMLomits itsYamsdependency on WASI and throwsConfigFileParseErrorif invoked there, CLI subprocess providers (op,bws,bw,pass,sops) execute on macOS/Linux/Windows, and 1Password Connect REST requiresDarwinorFoundationNetworking.
Note on SwiftPM resolution: Because all integration products live in one package manifest, SwiftPM fetches the package-level dependencies (
swift-syntax,swift-argument-parser,swift-configuration,Yams, andswift-docc-plugin) during dependency resolution, while your targets only compile and link the products you explicitly depend on.
import Foundation
import Rigging
import RiggingKeychain
import RiggingOnePassword
@Settings
public struct SigningSettings: Sendable, Equatable {
/// Apple Developer Team ID
@Setting(validate: .nonEmpty, examples: ["ABCDE12345"])
public var teamId: String?
/// Enable automatic code signing
@Setting
public var automaticSigning: Bool = true
}
@Settings(
envPrefix: "ASC_",
envNestedDelimiter: "__",
dotEnvFiles: [".env", ".env.local"],
projectConfigFiles: [".asc.json"],
xdgAppName: "asc",
extraKeys: .forbid
)
public struct ASCSettings: Sendable, Equatable {
/// 10-character App Store Connect Key ID
@Setting(
aliases: [.env("APP_STORE_CONNECT_KEY_ID"), .configPath(["auth", "keyId"])],
validate: .regex(#"^[A-Z0-9]{10}$"#, message: "Must be a 10-character alphanumeric Key ID")
)
public var keyId: String
/// App Store Connect Issuer UUID
@Setting(aliases: [.configPath(["auth", "issuerId"])])
public var issuerId: UUID
/// PKCS#8 (.p8) private key or secret URI (op://, keychain://, @~/.keys/AuthKey.p8)
@SecretSetting(
transforms: [
.expandFileReference(requirePermissions: 0o600),
.decodeBase64IfPrefixed,
.normalizePEM,
]
)
public var privateKey: Secret<String>
/// Enforce read-only API operations
@Setting
public var readOnly: Bool = false
/// HTTP request timeout (`"30s"`, `"500ms"`, `"2m"`)
@Setting
public var timeout: Duration = .seconds(30)
/// Nested signing configuration (`ASC_SIGNING__TEAM_ID` or `signing.teamId`)
@NestedSettings
public var signing: SigningSettings = .init()
/// Register default secret providers once for `load()`, `load(cliArguments:)`, and `ConfigSubcommand`
public static var defaultSecretProviders: [any SecretProvider] {
[.file(), .env(), .onePassword(), .keychain()]
}
public static func validate(_ settings: Self) -> [ValidationIssue] {
if !settings.readOnly && settings.signing.teamId == nil {
return [
ValidationIssue(
path: ["signing", "teamId"],
message: "signing.teamId is required when readOnly is false."
),
]
}
return []
}
}SwiftUI & Apple Apps: When importing
RiggingalongsideSwiftUI, annotate models with@Rigged(...)instead of@Settings(...)to avoid colliding withSwiftUI.Settings.
Load settings asynchronously with deduplicated, single-batch secret resolution:
// Uses ASCSettings.defaultSecretProviders automatically:
let settings = try await ASCSettings.load()
// Or override providers per call (include `.file()` / `.env()` if using file:// or env:// URIs):
let customSettings = try await ASCSettings.load(
secretProviders: [.file(), .env(), .onePassword(), .keychain()]
)By default, Rigging merges configuration layers from highest to lowest priority (customizable per model via static func customizeSources(_ defaults: DefaultSources) -> [any SettingsSource]):
- CLI & Programmatic Overrides (
InitSource/ArgumentParserSource) — Unsetniloptional flags are omitted so they never clobber lower layers. - Environment Variables (
EnvironmentSource) — HonorsenvPrefix,envNestedDelimiter(ASC_SIGNING__TEAM_ID),envIgnoreEmpty,envNullStrings(null,none,~),.env(...)aliases, andEnvCollectionStrategy(.jsonOrCommaSeparated,.jsonOnly,.separator,.noDecode). - Dotenv Files (
DotEnvSource) — Supportsexport, single/double/unquoted strings, multiline PEM blocks,#comments,${VAR:-default}interpolation, and.env→.env.locallayering with exact 1-based line numbers. - Secrets Directory (
SecretsDirSource) — Docker / Kubernetes/run/secretsmounts (secretsNestedSubdir, dotfile skipping, trailing newline trimming). - Project Config (
ProjectConfigSource,TOMLProjectConfigSource,YAMLProjectConfigSource) — Walks upward fromworkingDirectory, stopping inclusively at.gitor$HOME, overlaying"profiles": { "<active>": { ... } }(--profileor<PREFIX>PROFILE), and stripping"$schema"and"profiles"forextraKeys: .forbid. - User Config (
UserConfigSource,TOMLUserConfigSource,YAMLUserConfigSource) — Reads$XDG_CONFIG_HOME/<app>/config.{json,toml,yaml,yml}(~/.config/<app>/...) with macOS~/Library/Application Support/<app>/fallback. - Managed Preferences (
ManagedPreferencesSource) — macOSCFPreferences/ enterprise MDM policy domains (e.g.,com.example.asc). - Swift Property Defaults — Declared inline on struct properties.
Unlike Codable (which halts on the first DecodingError), Rigging evaluates every field, nested struct, secret safety rule, and cross-field validate(_:) check in one pass, throwing a SettingsValidationError (LocalizedError) with deterministic CLI exit codes:
2— Missing required setting, type/validator mismatch, unknown key (extraKeys: .forbid), or cross-field failure4— Unsafe secret storage (0644key file, world-writable binary, or literal secret committed in a project config file)6— External secret provider failure (missing Keychain item, expired 1Password session, rate limit, or unreachable Connect server)
Any @SecretSetting (or @Setting(resolveSecrets: true)) transparently dereferences secret URIs across all registered providers, grouping by (scheme, accountHint) so 1Password prompts for biometric unlock at most once:
| Reference URI | Provider | Mechanism |
|---|---|---|
op://Vault/Item/[Section/]field |
OnePasswordProvider (.onePassword()) |
Single batched op inject over in-memory pipes or Connect REST API |
keychain://service/account |
KeychainProvider (.keychain()) |
In-process SecItemCopyMatching (generic & internet passwords) |
bws://<uuid> / bw://<id>/field |
BitwardenProvider (.bitwarden()) |
Bitwarden Secrets Manager (bws) or Vault (bw) CLI |
pass://team/prod/api-key[#key] |
UnixPassProvider (.unixPass()) |
pass show (~/.password-store line, #full, #line:N, or #key) |
sops://secrets.enc.json#/db/pass |
SOPSProvider (.sops()) |
sops --decrypt + in-memory RFC 6901 JSON Pointer |
file:///abs/path or @~/.keys/Auth.p8 |
FileSecretProvider (.file(), built-in) |
Enforces 0600 POSIX permissions prior to reading |
env://PROD_API_KEY |
IndirectEnvProvider (.env(), built-in) |
Safe config-file indirection to environment variables |
// Explicit extraction (easy to grep in security review):
let rawPEM: String = settings.privateKey.expose()
// Scoped UTF-8 byte buffer access:
let jwt = try settings.privateKey.withExposedUTF8 { pemBytes in
try signAppStoreJWT(pemBytes: pemBytes)
}
// Atomic 0700 directory + 0600 file materialization for legacy CLIs (xcodebuild, openssl, ssh):
// Guaranteed to overwrite bytes with zeros, fsync, unlink, and rmdir on return or throw!
try await settings.privateKey.withEphemeralFile(prefix: "authkey-", suffix: ".p8") { keyURL in
try await runXcodebuild(authenticationKeyPath: keyURL.path(percentEncoded: false))
}
// Scrub subprocess stderr before logging so resolved secrets never leak to CI logs:
let safeStderr = settings.redactor.scrub(rawProcessStderr)Every @Setting and @SecretSetting synthesizes a $field projected SettingMetadata<Value>:
print(settings.$keyId.source)
// environment ASC_KEY_ID
print(settings.$keyId.overriddenSources)
// [project config /repo/.asc.json → keyId]
print(settings.$privateKey.valueSummary)
// **********
print(settings.provenanceReport().formattedTable())Bind swift-argument-parser options directly to @Settings and mount a turnkey config subcommand group. Both load(cliArguments:) and ConfigSubcommand automatically honor ASCSettings.defaultSecretProviders:
import ArgumentParser
import Rigging
import RiggingArgumentParser
struct GlobalCLIOptions: RiggingCLIOptions {
@Option(name: .long) var keyId: String?
@Option(name: .long) var profile: String?
@Flag(name: .long, inversion: .prefixedNo) var readOnly: Bool? // nil when omitted -> never clobbers env!
}
@main
struct MyCLI: AsyncParsableCommand {
static let configuration = CommandConfiguration(
commandName: "asc",
subcommands: [
StatusCommand.self,
ConfigSubcommand<ASCSettings>.self,
]
)
}
struct StatusCommand: AsyncParsableCommand {
@OptionGroup var globals: GlobalCLIOptions
mutating func run() async throws {
let settings = try await ASCSettings.load(cliArguments: globals)
print("Key ID: \(settings.keyId), read-only: \(settings.readOnly)")
}
}Mounting ConfigSubcommand<ASCSettings>.self adds four operational subcommands out of the box:
asc config show [--json] [--profile <name>]— Displays effective values (**********for secrets) with winning and shadowedSettingOrigins.asc config doctor [--json] [--profile <name>]— Audits config syntax,0600file permissions, secret provider reachability, and unknown/deprecated keys (0,2,4,6).asc config schema [--compact]— Exports Draft 2020-12 JSON Schema for editor$schemaautocomplete.asc config init [--dotenv | --json]— Scaffolds a commented.envtemplate or git-safe starter JSON config.
Bridge Rigging bidirectionally with apple/swift-configuration (1.0+):
import Configuration
import Rigging
import RiggingSwiftConfiguration
// Direction B: Vend validated, secret-resolved Rigging settings as a standard Apple ConfigReader.
// Every @SecretSetting is marked `isSecret: true` so AccessReporter automatically redacts secrets!
let settings = try await ASCSettings.load()
let reader: ConfigReader = settings.asConfigReader()
let teamId = reader.scoped(to: "signing").string(forKey: "team-id")
// Direction A: Consume any upstream ConfigProvider inside `customizeSources(_:)`:
// SwiftConfigurationSource(provider: upstreamProvider, for: Self.self)Write fast, deterministic, parallel Swift Testing suites with zero filesystem, Keychain, or subprocess side effects:
import Rigging
import RiggingTesting
import Testing
@Test func cliReadOnlyBeatsEnvironment() async throws {
let mockOP = MockOnePasswordProvider(secrets: [
"op://Personal/ASC/key": TestFixtures.sampleP8PEM,
])
let context = SettingsContext.inMemory(
cli: ["readOnly": true],
environment: [
"ASC_KEY_ID": "ABC1234567",
"ASC_ISSUER_ID": "00000000-0000-0000-0000-000000000001",
"ASC_READ_ONLY": "false",
],
files: [
"/repo/.asc.json": #"{"privateKey": "op://Personal/ASC/key"}"#,
],
directories: ["/repo/.git"],
secretProviders: [mockOP]
)
let settings = try await ASCSettings.load(context: context)
#expect(settings.readOnly == true)
#expect(settings.$readOnly.source == .cliArgument(flag: "--read-only"))
#expect(await mockOP.invocationCount == 1)
}Full multi-module Apple DocC reference documentation and conceptual guides (Getting Started with Rigging, Secrets and Security Hygiene, Provenance and Operational Debugging, and Migrating from Python pydantic-settings) are included across all 11 library targets:
- Online (Swift Package Index): Browse hosted multi-module DocC at swiftpackageindex.com/SamPetherbridge/Rigging/documentation.
- In Xcode: Open
Package.swiftand choose Product → Build Documentation (⌃⇧⌘D). - From the CLI: Run
swift package generate-documentation --target Rigging(configured for multi-target Swift Package Index hosting via.spi.yml). - Architecture & Threat Model: See
docs/SPECIFICATION.mdandSECURITY.md.
- Run
./scripts/install-hooks.shafter cloning to enable the local.githooks/pre-pushverification gate (zero-warning Swift 6 build, parallelSwift Testingsuite, and multi-module DocC--warnings-as-errorscheck), and readCONTRIBUTING.mdfor module dependency boundaries and extension guides. - To report a security vulnerability privately, see
SECURITY.md. - Please review our
CODE_OF_CONDUCT.md.
Released under the MIT License. Copyright © 2026 Peth Pty Ltd.