Formats and parses locale-aware numbers, decimals, currencies, percentages, dates, durations, measurements, names, lists, byte counts, and URLs with Foundation FormatStyle and ParseableFormatStyle. Use when replacing legacy Formatter subclasses, designing reusable format APIs, using SwiftUI Text(_:format:), correcting availability, or testing user-facing formatted output across locales.
swift-formatstyle is an engineering reference for using Foundation's type-safe FormatStyle and ParseableFormatStyle APIs to format and parse locale-aware values in Swift. It solves the common iOS problem of correctly displaying and round-tripping numbers, decimals, currencies, percentages, dates, durations, measurements, person names, lists, byte counts, and URLs across locales — replacing legacy Formatter subclasses like NumberFormatter and DateFormatter and error-prone manual string interpolation.
The skill provides a workflow (identify the value's semantic type, pick the narrowest built-in style, render against representative locales such as en_US, de_DE, ar_SA, and ja_JP, and check separators, numbering systems, calendars, currency/unit conventions, and text direction), plus a quick-reference table mapping each value type to its default style and key constraints. It documents availability gates (Duration and URL format styles require iOS 16+, Date.AnchoredRelativeFormatStyle requires iOS 18+), SwiftUI integration via Text(_:format:), parsing with ParseableFormatStyle, and building custom format styles. A bundled formatstyle-recipes.md reference gives concrete modifiers for precision, rounding, grouping, notation, currency codes, date intervals, relative dates, durations, measurements, names, lists, byte counts, and URL component controls; it also cautions that URL formatting is display formatting, not sanitization or a security boundary. Localization concerns like String Catalogs, plurals, and RTL layout are routed to a separate ios-localization skill.
It targets Swift and iOS developers modernizing formatting code, designing reusable format APIs, and testing user-facing output across locales.
It guides use of Foundation's FormatStyle/ParseableFormatStyle for locale-aware display and parsing, replacing legacy Formatter subclasses and manual interpolation for new iOS 15+ code.
Numbers, decimals, currencies, percentages, dates, durations, measurements, person names, lists, byte counts, and URLs, each with a default style and important constraints.
Yes. Duration format styles and URL.FormatStyle require iOS 16+, and Date.AnchoredRelativeFormatStyle requires iOS 18+; the skill flags these so you correct availability.
Only for an explicit protocol/wire format or a test fixture. For normal UI, omit .locale(...) so the style inherits the user's locale, and test round trips across representative locales.
No. The recipes reference explicitly says to treat URL.FormatStyle as display formatting, not URL sanitization or a security boundary.
Quick Setup:
.claude/skills/Repository
dpearson2699/swift-ios-skills