TextBuilder alternatives and similar libraries
Based on the "Text" category.
Alternatively, view TextBuilder alternatives based on common mentions on social networks and blogs.
-
PhoneNumberKit
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. -
SwiftRichString
👩🎨 Elegant Attributed String composition in Swift sauce -
TwitterTextEditor
A standalone, flexible API that provides a full-featured rich text editor for iOS applications. -
RichEditorView
RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing. -
SwiftString
A comprehensive, lightweight string extension for Swift -
Atributika
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement. -
Notepad
[iOS] A fully themeable markdown editor with live syntax highlighting. -
MarkdownKit
A simple and customizable Markdown Parser for Swift -
Mustard
🌭 Mustard is a Swift library for tokenizing strings when splitting by whitespace doesn't cut it. -
SwiftVerbalExpressions
Swift Port of VerbalExpressions -
PrediKit
An NSPredicate DSL for iOS, OSX, tvOS, & watchOS. Inspired by SnapKit and lovingly written in Swift. -
AttributedTextView
Easiest way to create an attributed UITextView (with support for multiple links and from html) -
Regex by crossroadlabs
Regular expressions for swift -
PySwiftyRegex
Easily deal with Regex in Swift in a Pythonic way -
OysterKit
OysterKit is a framework that provides a native Swift scanning, lexical analysis, and parsing capabilities. In addition it provides a language that can be used to rapidly define the rules used by OysterKit called STLR -
Tagging
A TextView that provides easy to use tagging feature for Mention or Hashtag -
PredicateFlow
Write amazing, strong-typed and easy-to-read NSPredicate. -
Regex by brynbellomy
Regex class for Swift. Wraps NSRegularExpression. -
OEMentions
An easy way to add mentions to uitextview like Facebook and Instagram -
SmarkDown
A Pure Swift implementation of the markdown mark-up language -
Veneer
A simple library for building attributed strings, for a more civilized age.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of TextBuilder or a related project?
README
TextBuilder
Introduction
Text
composition in SwiftUI can often be cumbersome, especially when there's logic affecting its format and content.
TextBuilder leverages the power of Swift Result Builders to solve this problem. TextBuilder mimics SwiftUI's ViewBuilder to make for a familiar experience at the point of use.
Usage
TextBuilder offers 3 ready-made builders out of the box, depending on which text separator you need.
Unspaced Text
@BasicTextBuilder
var loremIpsum: Text {
Text("Lorem").underline().foregroundColor(.blue)
Text("ipsum dolor")
Text("sit").bold()
Text("amet, consectetur")
}
Spaced Text
@SpacedTextBuilder
var loremIpsum: Text {
Text("Lorem").underline().foregroundColor(.blue)
Text("ipsum dolor")
Text("sit").bold()
Text("amet, consectetur")
}
Multiline Text
@MultilineTextBuilder
var loremIpsum: Text {
Text("Lorem").underline().foregroundColor(.blue)
Text("ipsum dolor")
Text("sit").bold()
Text("amet, consectetur")
}
Pro Tip ✨
TextBuilder accepts String
types directly as if they were plain Text
, and also provides a String.text
computed var to remove unwanted code noise when Text
is explicitly needed.
@MultilineTextBuilder
var loremIpsum: Text {
"Lorem".text.underline().foregroundColor(.blue)
"ipsum dolor"
"sit".text.bold()
"amet, consectetur"
}
Other Separators
There are two options to customize the separator used to compose your Text
.
First, you can use Text.init(separator:content:)
:
var loremIpsum: Text {
Text(separator: " 🍆 ") {
"Lorem".text.underline().foregroundColor(.blue)
"ipsum dolor"
"sit".text.bold()
"amet, consectetur"
}
}
But if you prefer to keep using a result builder, you can:
struct EggplantSeparator: TextBuilderSeparator {
static var separator: String { " 🍆 " }
}
@TextBuilder<EggplantSeparator>
var loremIpsum: Text {
"Lorem".text.underline().foregroundColor(.blue)
"ipsum dolor"
"sit".text.bold()
"amet, consectetur"
}
Benchmarks
MacBook Pro (14-inch, 2021)
Apple M1 Pro (10 cores, 8 performance and 2 efficiency)
32 GB Memory
$ swift run -c release Benchmarks
name time std iterations
---------------------------------------------------------------
@TextBuilder 3875.000 ns ± 5.94 % 359621
Text.init(separator:content:) 3750.000 ns ± 5.64 % 373819