Repository navigation
0.1.0
Initial release of SwiftCommons — a lightweight, dependency-free Swift package of Foundation extensions and utilities for Apple-platform apps.
- Platforms: macOS 13+, iOS 16+, Mac Catalyst 16+
- Toolchain: Swift 6 language mode (
swift-tools-version: 6.2), no external runtime dependencies - Full DocC documentation, Swift Testing coverage, and a 90% line-coverage gate in CI
What's included
Collections & optionals
- Safe and defaulted
Arraysubscripts:[safe:],[_, default:], andRange/ClosedRangevariants (@inlinable) Optional.ifNil(_:)for defaulting optionals
Numbers
FixedWidthInteger.digits— base-10 digit decomposition (safe across the full range, includingInt.min)- Locale-aware, thread-cached
NumberFormatterhelpers:formatYear(_:locale:),formatDay(_:locale:)
Dates & calendars
Calendardate math: start of week/month, weekday of first-of-month, days-in-month, month symbols, and day-preserving month/year arithmetic, with typedCalendarError- Thread-safe
DateFormatter.formatter(_:locale:timeZone:)cache keyed per format/locale/time zone
Localization
Language(ISO 639-1) andCountry(ISO 3166-1 alpha-2) enums with display names —Codable,CaseIterable,SendableLocale.identifier(language:country:), theLocale.Identifiersconstants,Locale(calendarIdentifier:), andwithNumberingSystemIdentifier(_:)
Logging
Logger.forType(subsystem:_:)/forCaller(subsystem:)factories with auto-derived categories- Privacy-aware helpers (
infoPublic/errorPrivate/…),error(_:error:context:)with file/line context, andtraceEntry/traceExit - SwiftCommons subsystem conveniences
State, configuration & concurrency
LoadingState<Value>+LoadingError— a generic async-fetch state machineConfigValue— a type-safe config value with lenient cross-type coercionAsyncLock— a FIFO async mutual-exclusion lock that serializes work acrossawaitpoints
Formatting
DurationFormatter— compactm:ss/h:mm:ssduration strings
URLs
URLconforms toExpressibleByStringLiteral(via@retroactive) for compile-time URL literals