Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

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

TermsPrivacyAboutGitHubRSS
  1. Home
  2. iOS
  3. SwiftyAttributes

SwiftyAttributes

MITSwiftv5.3.0

A Swifty API for attributed strings in iOS, macOS, watchOS, and tvOS with a clean, chainable syntax.

GitHubGitHub
1.6k stars83 forks0 contributors

What is SwiftyAttributes?

SwiftyAttributes is a Swift library that provides a modern, type-safe API for creating and manipulating attributed strings on Apple platforms. It solves the problem of verbose and error-prone Foundation APIs by offering a chainable syntax and comprehensive enum-based attribute system. Developers can style text with attributes like colors, fonts, and underlines using clean, Swifty code.

Target Audience

iOS, macOS, watchOS, and tvOS developers who need to work with styled text in their apps, particularly those building rich text editors, custom UI components, or localized interfaces with mixed formatting.

Value Proposition

Developers choose SwiftyAttributes because it replaces Objective-C's cumbersome `NSAttributedString` APIs with a native Swift experience—offering type safety, chainable methods, and Swift Range support. It eliminates stringly-typed keys while maintaining full compatibility with all Cocoa attributes.

Overview

A Swifty API for attributed strings

Use Cases

Best For

  • Building rich text editors with complex formatting requirements
  • Creating custom UILabel or NSTextField subclasses with styled text
  • Localizing apps where different text segments need distinct styles
  • Implementing syntax highlighting in code editors or text views
  • Developing UI components with mixed font sizes, colors, or underlines
  • Migrating Objective-C attributed string code to modern Swift

Not Ideal For

  • Projects exclusively using SwiftUI for all text styling, as it relies on UIKit/AppKit's NSAttributedString
  • Cross-platform applications targeting non-Apple ecosystems like Android or web
  • Teams that prefer minimal dependencies and have simple attributed string needs already met by Foundation

Pros & Cons

Pros

Chainable Syntax

Enables readable, fluid code like 'Hello World!'.withTextColor(.blue).withUnderlineStyle(.styleSingle), reducing verbosity compared to Foundation APIs.

Type-Safe Attributes

Uses an enum for all attributes, such as .underlineStyle(.styleSingle), eliminating stringly-typed keys and reducing runtime errors.

Swift Range Support

Works with Swift's Range<Int> instead of NSRange, making it better integrated with Swift collections and avoiding manual conversions.

Comprehensive Coverage

Supports every attribute available in Cocoa and Cocoa Touch, ensuring full compatibility for any attributed string use case.

Cons

Platform Lock-In

Limited to Apple platforms (iOS, macOS, etc.), so it's unsuitable for cross-platform projects or those using non-Apple technologies.

Dependency Overhead

Adds an external library for functionality that Foundation provides natively, which can be unnecessary for simple apps and increase maintenance.

SwiftUI Integration Complexity

Designed for UIKit/AppKit, so using it with SwiftUI requires additional bridging or workarounds, complicating the codebase.

Frequently Asked Questions

Quick Stats

Stars1,631
Forks83
Contributors0
Open Issues3
Last commit2 years ago
CreatedSince 2015

Tags

#foundation#cocoa-touch#ios#tvos#nsattributedstring#cocoa#type-safe#ui-development#attributed-strings#watchos#cocoapods#swift#carthage#macos

Built With

S
Swift

Included in

iOS51.7kSwift26.0k
Auto-fetched 1 day ago

Related Projects

YYTextYYText

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

Stars8,877
Forks1,799
Last commit1 year ago
PhoneNumberKitPhoneNumberKit

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

Stars5,368
Forks854
Last commit11 days ago
ZSSRichTextEditorZSSRichTextEditor

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

Stars3,785
Forks590
Last commit4 years ago
BonMotBonMot

Beautiful, easy attributed strings in Swift

Stars3,561
Forks196
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