A lightweight Swift library for elegant attributed string composition with declarative styling and tag-based rendering.
SwiftRichString is a Swift library designed to simplify working with attributed strings on Apple platforms. It provides a declarative API for creating reusable text styles, supports tag-based rendering from XML/HTML, and integrates with Interface Builder. The library solves the problem of verbose and error-prone attributed string manipulation by offering a clean, type-safe approach.
iOS, macOS, tvOS, and watchOS developers who need to style text with attributes (fonts, colors, spacing) in their apps, particularly those building rich text UIs, dynamic labels, or theming systems.
Developers choose SwiftRichString for its elegant syntax, zero dependencies, and comprehensive feature set—including Dynamic Type support, image embedding, and regex styling—which drastically reduces the complexity of attributed string management compared to using Foundation APIs directly.
👩🎨 Elegant Attributed String composition in Swift sauce
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses a builder-pattern syntax for defining reusable styles, making attributed string creation concise and type-safe, as demonstrated in the README's style definition examples like `Style { $0.font = SystemFonts.AmericanTypewriter.font(size: 25) }`.
Supports parsing and styling XML/HTML tagged strings with StyleXML groups, enabling dynamic text rendering from backend sources, shown in examples with tags like <bold> and <italic> for complex string composition.
Includes Dynamic Type support for accessibility, image embedding with lazy loading, regular expression styling, and Interface Builder integration, covering most attributed string needs without external dependencies.
Written entirely in Swift 5 with a compact codebase, reducing project bloat and ensuring compatibility across Apple platforms, as highlighted in the README's installation section.
Exclusively supports iOS, macOS, tvOS, and watchOS, making it unsuitable for cross-platform projects or frameworks like Flutter or React Native, limiting its adoption in mixed environments.
Advanced XML features, such as reacting to tag attributes or handling unknown tags, require implementing protocols like XMLDynamicAttributesResolver, which can be complex and error-prone for developers, as noted in the customization section.
While it handles basic tags, the README admits that complex HTML elements (e.g., tables, nested structures) are not supported out-of-the-box, relying on tag-based rendering rather than full HTML parsing.
Deep integration with Interface Builder for UILabel, UITextView, and UITextField may not align with code-only or SwiftUI-based projects, adding unnecessary complexity for teams avoiding storyboards.