Skip to content

0.1.0

Choose a tag to compare

@github-actions github-actions released this 27 Jun 23:45
cc02ca3

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 Array subscripts: [safe:], [_, default:], and Range/ClosedRange variants (@inlinable)
  • Optional.ifNil(_:) for defaulting optionals

Numbers

  • FixedWidthInteger.digits — base-10 digit decomposition (safe across the full range, including Int.min)
  • Locale-aware, thread-cached NumberFormatter helpers: formatYear(_:locale:), formatDay(_:locale:)

Dates & calendars

  • Calendar date math: start of week/month, weekday of first-of-month, days-in-month, month symbols, and day-preserving month/year arithmetic, with typed CalendarError
  • Thread-safe DateFormatter.formatter(_:locale:timeZone:) cache keyed per format/locale/time zone

Localization

  • Language (ISO 639-1) and Country (ISO 3166-1 alpha-2) enums with display names — Codable, CaseIterable, Sendable
  • Locale.identifier(language:country:), the Locale.Identifiers constants, Locale(calendarIdentifier:), and withNumberingSystemIdentifier(_:)

Logging

  • Logger.forType(subsystem:_:) / forCaller(subsystem:) factories with auto-derived categories
  • Privacy-aware helpers (infoPublic/errorPrivate/…), error(_:error:context:) with file/line context, and traceEntry/traceExit
  • SwiftCommons subsystem conveniences

State, configuration & concurrency

  • LoadingState<Value> + LoadingError — a generic async-fetch state machine
  • ConfigValue — a type-safe config value with lenient cross-type coercion
  • AsyncLock — a FIFO async mutual-exclusion lock that serializes work across await points

Formatting

  • DurationFormatter — compact m:ss / h:mm:ss duration strings

URLs

  • URL conforms to ExpressibleByStringLiteral (via @retroactive) for compile-time URL literals