swift-formatstyle

Format Swift values with locale-aware Foundation FormatStyle APIs.

Updated May 10, 2026
One-click install
npx skills add https://github.com/FelixRauch/medat-figuren --skill swift-formatstyle-felixrauch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-formatstyle
Source: https://github.com/FelixRauch/medat-figuren/tree/main/.agents/skills/swift-formatstyle
Command: npx skills add https://github.com/FelixRauch/medat-figuren --skill swift-formatstyle-felixrauch

SYSTEM DOCUMENTATION & REQUIREMENTS

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).

Frequently Asked Questions about swift-formatstyle

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I format numbers and dates in SwiftUI using FormatStyle?

Format numbers and dates in SwiftUI by using the Text(_:format:) initializer with Foundation FormatStyle. This ensures locale-aware, type-safe rendering while maintaining view accessibility and avoiding legacy Formatter subclasses.

What is the best way to format currency and percentages in Swift?

Format currency and percentages in Swift by applying locale-aware FormatStyle APIs to your numeric values. This provides type-safe precision, rounding, and grouping without relying on deprecated Formatter implementations.

Do I need iOS 15 or iOS 16 to use Swift Duration FormatStyle?

Formatting Duration values requires iOS 16+ availability handling, whereas standard date and number FormatStyle APIs are available starting iOS 15. You must specify correct availability to avoid runtime errors.

How does FormatStyle compare to legacy Formatter subclasses in Swift?

FormatStyle replaces legacy Formatter subclasses by providing type-safe, locale-aware value formatting directly in Swift. It eliminates hard-to-maintain string precomputation and ensures values re-render correctly in SwiftUI.

Can I create a custom FormatStyle for domain-specific values in Swift?

Create custom formatting by conforming to the FormatStyle protocol for domain-specific display. Implement ParseableFormatStyle when parsing formatted strings back into values is also required.

Why should I avoid precomputing formatted strings in my SwiftUI view model?

Precomputing formatted strings in SwiftUI view models prevents values from re-rendering correctly and degrades accessibility. Using Text(_:format:) with FormatStyle ensures the view stays locale-aware and accessible.