Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. iOS
  3. SwiftRichString

SwiftRichString

MITSwift3.7.2

A lightweight Swift library for elegant attributed string composition with declarative styling and tag-based rendering.

GitHubGitHub
3.1k stars211 forks0 contributors

What is SwiftRichString?

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.

Target Audience

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.

Value Proposition

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.

Overview

👩‍🎨 Elegant Attributed String composition in Swift sauce

Use Cases

Best For

  • Styling text in UILabels and UITextViews with reusable, app-wide themes
  • Rendering HTML or XML formatted strings from backend APIs into native attributed text
  • Building accessible interfaces with support for Dynamic Type text scaling
  • Embedding images (local or remote) within attributed strings
  • Applying text styles via regular expression patterns (e.g., highlighting emails or URLs)
  • Prototyping or building UIs with Interface Builder using styled text components

Not Ideal For

  • Projects built entirely with SwiftUI, as SwiftRichString is optimized for UIKit/AppKit attributed strings and lacks native SwiftUI integration.
  • Apps requiring full HTML rendering with complex layouts like tables, iframes, or CSS styling, since its XML/HTML support is tag-based and limited to basic attributes.
  • Cross-platform development targeting Android or web, due to its exclusive focus on Apple platforms (iOS, macOS, tvOS, watchOS).
  • Simple one-off text styling where direct NSAttributedString usage would suffice, as the library's setup for style management adds overhead.

Pros & Cons

Pros

Declarative Style API

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

Tag-Based XML/HTML Rendering

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.

Comprehensive Feature Set

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.

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

Cons

Platform Lock-in to Apple

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.

Steep Learning Curve for XML Customization

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.

Limited HTML Support

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.

Interface Builder Dependency

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.

Frequently Asked Questions

Quick Stats

Stars3,148
Forks211
Contributors0
Open Issues34
Last commit2 years ago
CreatedSince 2016

Tags

#auto-layout#ios#dynamic-type#tvos#nsattributedstring#xml-rendering#typography#attributed-strings#watchos#text#swift#ui-styling#declarative-syntax#swift-library#attributedstring#text-formatting#macos#xml-parsing

Built With

S
Swift 5

Included in

iOS51.7kSwift26.0k
Auto-fetched 22 hours ago

Related Projects

YYTextYYText

Powerful text framework for iOS to display and edit rich text.

Stars8,875
Forks1,833
Last commit1 year ago
PhoneNumberKitPhoneNumberKit

A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.

Stars5,377
Forks859
Last commit14 days ago
ZSSRichTextEditorZSSRichTextEditor

A beautiful rich text WYSIWYG editor for iOS with a syntax highlighted source view

Stars3,785
Forks589
Last commit4 years ago
BonMotBonMot

Beautiful, easy attributed strings in Swift

Stars3,556
Forks195
Last commit1 year ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub