What problem does it solve?
It solves the problem of producing inconsistent, locale-incorrect, or hard-to-maintain formatted strings by replacing legacy Formatter-based code with Swift’s type-safe FormatStyle APIs.
Core Features & Use Cases
- Numbers, currency, and percentages: Format integers, floating-point values, monetary amounts, and percent values with precision, rounding, grouping, and locale-aware behavior.
- Date and duration rendering: Display dates, date ranges, relative dates, and Duration values using the correct FormatStyle for iOS 15+ / iOS 16+ targets.
- SwiftUI-friendly formatting: Use Text(_:format:) so values re-render correctly, stay accessible, and avoid view-model string-precomputation.
- Custom FormatStyle creation: Define domain-specific formatting by conforming to FormatStyle (and ParseableFormatStyle when parsing is needed).
Quick Start
Use swift-formatstyle to format a value directly in SwiftUI with Text(yourValue, format: yourStyle).