A Swift library providing a precise, type-safe representation of monetary amounts with ISO 4217 currency support.
Money is a Swift library that provides a type-safe representation of monetary amounts, ensuring each value is explicitly associated with a currency. It solves the problem of inaccurate financial calculations and currency mixing errors by using Decimal for precision and Swift's generics for compile-time safety. The library supports all ISO 4217 currencies and offers features like arithmetic operations, formatting, and Codable integration.
Swift developers building iOS, macOS, or server-side applications that handle financial data, such as e-commerce apps, banking software, or accounting tools. It's particularly useful for teams requiring strict correctness in monetary calculations.
Developers choose Money for its compile-time type safety, which prevents currency mismatches, and its use of Decimal for exact arithmetic, avoiding floating-point pitfalls. It offers a more robust alternative to ad-hoc money handling, with built-in support for standards like ISO 4217 and seamless integration with Swift's ecosystem.
A precise, type-safe representation of a monetary amount in a given currency
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Prevents accidental mixing of currencies by binding each amount to a specific type, as shown in the compiler error when comparing USD and EUR.
Uses Swift's Decimal to avoid floating-point rounding errors, with workarounds like string literals for accurate initialization.
Includes all standard currencies with minor unit handling, generated from up-to-date CSV data, though updates are manual.
Supports configurable encoding and decoding options, such as omitting currency or requiring string amounts for precision.
Handling multiple currencies generically can make code unwieldy, as admitted in the README's section on supporting multiple currencies.
Decimal arithmetic is slower than floating-point, which might impact performance-critical applications like high-frequency trading.
The ISO 4217 data isn't automatically updated, requiring manual intervention or issues for new or amended currencies.