Skip to content

Commit e862885

Browse files
committed
Bump to Swift 5.1 and added documentation for function builders
1 parent 2b1a67c commit e862885

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ It provides convenient way to store styles you can reuse in your app's UI elemen
1818
| 🧬 | Fast & high customizable XML/HTML tagged string rendering |
1919
| 🌟 | Apply text transforms within styles |
2020
| 📐 | Native support for iOS 11 Dynamic Type |
21+
| 🖇 | Support for Swift 5.1's function builder to compose strings |
2122
|| Compact code base with no external dependencies. |
2223
| 🐦 | Fully made in Swift 5 from Swift ❥ lovers |
2324

@@ -177,6 +178,18 @@ You can also use `+` operator to add a style to a plain or attributed string:
177178
let attStr = "Hello" + ("\(username)" + big)
178179
```
179180

181+
Finally you can concatente strings usint function builders:
182+
183+
```swift
184+
let bold = Style { ... }
185+
let italic = Style { ... }
186+
187+
let attributedString = AttributedString.composing {
188+
"hello".set(style: bold)
189+
"world".set(style: italic)
190+
}
191+
```
192+
180193
<a name="manualstyling"/>
181194

182195
## Apply styles to `String` & `Attributed String`
@@ -692,8 +705,7 @@ The following properties are available:
692705

693706
## Requirements
694707

695-
SwiftRichString is compatible with Swift 5.x.
696-
All Apple platforms are supported:
708+
SwiftRichString is compatible with Swift 5.1+ on:
697709

698710
* iOS 8.0+
699711
* macOS 10.10+

SwiftRichString.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
1616
s.source = { :git => "https://github.com/malcommac/SwiftRichString.git", :tag => s.version.to_s }
1717
s.source_files = "Sources/**/*"
1818
s.frameworks = "Foundation"
19-
s.swift_versions = ['5.0', '5.1']
19+
s.swift_versions = ['5.1']
2020
end

SwiftRichString.xcodeproj/project.pbxproj

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@
145145
6472C89823AE723D0056A21D /* AsyncTextAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6472C89223AE723D0056A21D /* AsyncTextAttachment.swift */; };
146146
6472C89923AE723D0056A21D /* AsyncTextAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6472C89223AE723D0056A21D /* AsyncTextAttachment.swift */; };
147147
6472C89A23AE723D0056A21D /* AsyncTextAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6472C89223AE723D0056A21D /* AsyncTextAttachment.swift */; };
148+
6472C89C23AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6472C89B23AED08D0056A21D /* AttributedString+FunctionBuilder.swift */; };
149+
6472C89D23AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6472C89B23AED08D0056A21D /* AttributedString+FunctionBuilder.swift */; };
150+
6472C89E23AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6472C89B23AED08D0056A21D /* AttributedString+FunctionBuilder.swift */; };
151+
6472C89F23AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6472C89B23AED08D0056A21D /* AttributedString+FunctionBuilder.swift */; };
152+
6472C8A023AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6472C89B23AED08D0056A21D /* AttributedString+FunctionBuilder.swift */; };
153+
6472C8A123AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6472C89B23AED08D0056A21D /* AttributedString+FunctionBuilder.swift */; };
154+
6472C8A223AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6472C89B23AED08D0056A21D /* AttributedString+FunctionBuilder.swift */; };
155+
6472C8A323AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6472C89B23AED08D0056A21D /* AttributedString+FunctionBuilder.swift */; };
148156
64774AD3213E91B9008F8DC3 /* file.txt in Resources */ = {isa = PBXBuildFile; fileRef = 64774AD2213E91B9008F8DC3 /* file.txt */; };
149157
647AD64D21F3898400CF787E /* URLRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647AD64C21F3898400CF787E /* URLRepresentable.swift */; };
150158
647AD64E21F3898400CF787E /* URLRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647AD64C21F3898400CF787E /* URLRepresentable.swift */; };
@@ -347,6 +355,7 @@
347355
6472C88723AE41A00056A21D /* UIKit+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIKit+Extensions.swift"; sourceTree = "<group>"; };
348356
6472C88923AE67D10056A21D /* AttributedString+Attachments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AttributedString+Attachments.swift"; sourceTree = "<group>"; };
349357
6472C89223AE723D0056A21D /* AsyncTextAttachment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncTextAttachment.swift; sourceTree = "<group>"; };
358+
6472C89B23AED08D0056A21D /* AttributedString+FunctionBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AttributedString+FunctionBuilder.swift"; sourceTree = "<group>"; };
350359
64774AD2213E91B9008F8DC3 /* file.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = file.txt; sourceTree = "<group>"; };
351360
647AD64C21F3898400CF787E /* URLRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLRepresentable.swift; sourceTree = "<group>"; };
352361
647D775523AD8AF900733374 /* TextTransform.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextTransform.swift; sourceTree = "<group>"; };
@@ -528,6 +537,7 @@
528537
64507E8520AF3609009455BD /* String+Subscript.swift */,
529538
64507EA320B05015009455BD /* AttributedString+Extension.swift */,
530539
6472C88923AE67D10056A21D /* AttributedString+Attachments.swift */,
540+
6472C89B23AED08D0056A21D /* AttributedString+FunctionBuilder.swift */,
531541
6489330F209DE87D000E691A /* SystemFonts.swift */,
532542
64507E6120AEEE8D009455BD /* UIKit+Extras.swift */,
533543
);
@@ -1130,6 +1140,7 @@
11301140
D53F4E7B21F03E690085D26F /* DynamicText.swift in Sources */,
11311141
648932CA209DE194000E691A /* CommonsAttributes.swift in Sources */,
11321142
64507EBE20B18489009455BD /* Extensions.swift in Sources */,
1143+
6472C89C23AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */,
11331144
64507E8D20AF3A9C009455BD /* StyleProtocol.swift in Sources */,
11341145
6472C89323AE723D0056A21D /* AsyncTextAttachment.swift in Sources */,
11351146
64507EA420B05015009455BD /* AttributedString+Extension.swift in Sources */,
@@ -1171,6 +1182,7 @@
11711182
D53F4E7D21F03EEF0085D26F /* DynamicText.swift in Sources */,
11721183
648932CC209DE194000E691A /* CommonsAttributes.swift in Sources */,
11731184
64507EC020B18489009455BD /* Extensions.swift in Sources */,
1185+
6472C89E23AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */,
11741186
64507E8F20AF3A9C009455BD /* StyleProtocol.swift in Sources */,
11751187
6472C89523AE723D0056A21D /* AsyncTextAttachment.swift in Sources */,
11761188
64507EA620B05015009455BD /* AttributedString+Extension.swift in Sources */,
@@ -1204,6 +1216,7 @@
12041216
D53F4E7E21F03EEF0085D26F /* DynamicText.swift in Sources */,
12051217
648932CD209DE194000E691A /* CommonsAttributes.swift in Sources */,
12061218
64507EC120B18489009455BD /* Extensions.swift in Sources */,
1219+
6472C89F23AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */,
12071220
64507E9020AF3A9C009455BD /* StyleProtocol.swift in Sources */,
12081221
6472C89623AE723D0056A21D /* AsyncTextAttachment.swift in Sources */,
12091222
64507EA720B05015009455BD /* AttributedString+Extension.swift in Sources */,
@@ -1237,6 +1250,7 @@
12371250
D53F4E7C21F03EEE0085D26F /* DynamicText.swift in Sources */,
12381251
648932CB209DE194000E691A /* CommonsAttributes.swift in Sources */,
12391252
64507EBF20B18489009455BD /* Extensions.swift in Sources */,
1253+
6472C89D23AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */,
12401254
64507E8E20AF3A9C009455BD /* StyleProtocol.swift in Sources */,
12411255
6472C89423AE723D0056A21D /* AsyncTextAttachment.swift in Sources */,
12421256
64507EA520B05015009455BD /* AttributedString+Extension.swift in Sources */,
@@ -1270,6 +1284,7 @@
12701284
647D777523AE29F000733374 /* XMLDynamicAttributesResolver.swift in Sources */,
12711285
647AD65321F389A400CF787E /* URLRepresentable.swift in Sources */,
12721286
64507EF120B18F20009455BD /* AttributedString+Extension.swift in Sources */,
1287+
6472C8A223AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */,
12731288
647D776E23AE21EE00733374 /* StyleGroup.swift in Sources */,
12741289
64507EDE20B18F0F009455BD /* AppDelegate.swift in Sources */,
12751290
D53F4E8021F03F240085D26F /* DynamicText.swift in Sources */,
@@ -1320,6 +1335,7 @@
13201335
64507F3120B1912B009455BD /* ColorConvertible.swift in Sources */,
13211336
64507F1020B1911B009455BD /* InterfaceController.swift in Sources */,
13221337
64507F3520B1912B009455BD /* Extensions.swift in Sources */,
1338+
6472C8A323AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */,
13231339
64507F2B20B1912B009455BD /* AttributedString+Extension.swift in Sources */,
13241340
64507F2520B1912B009455BD /* Style.swift in Sources */,
13251341
643565FB2153884C00CEEE9F /* Compatibility.swift in Sources */,
@@ -1356,6 +1372,7 @@
13561372
64507E7520AEF12C009455BD /* AssociatedValues.swift in Sources */,
13571373
64507E6E20AEEFA7009455BD /* UIKit+Extras.swift in Sources */,
13581374
647D776623AE09CE00733374 /* XMLStringBuilder.swift in Sources */,
1375+
6472C8A023AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */,
13591376
64893314209DE8AA000E691A /* SystemFonts.swift in Sources */,
13601377
6489332920A0CA76000E691A /* FontInfoAttribute.swift in Sources */,
13611378
6489330D209DE7E3000E691A /* ColorConvertible.swift in Sources */,
@@ -1377,6 +1394,7 @@
13771394
647AD65221F389A400CF787E /* URLRepresentable.swift in Sources */,
13781395
64507E7620AEF12C009455BD /* AssociatedValues.swift in Sources */,
13791396
647D776D23AE21ED00733374 /* StyleGroup.swift in Sources */,
1397+
6472C8A123AED08D0056A21D /* AttributedString+FunctionBuilder.swift in Sources */,
13801398
648932FA209DE6C5000E691A /* ViewController.swift in Sources */,
13811399
D53F4E8121F03F240085D26F /* DynamicText.swift in Sources */,
13821400
64507EBC20B1766D009455BD /* StyleRegEx.swift in Sources */,
@@ -1545,7 +1563,7 @@
15451563
ONLY_ACTIVE_ARCH = YES;
15461564
SDKROOT = iphoneos;
15471565
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1548-
SWIFT_VERSION = 4.2;
1566+
SWIFT_VERSION = 5.0;
15491567
TARGETED_DEVICE_FAMILY = "1,2";
15501568
VERSIONING_SYSTEM = "apple-generic";
15511569
VERSION_INFO_PREFIX = "";
@@ -1596,7 +1614,7 @@
15961614
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
15971615
MTL_ENABLE_DEBUG_INFO = NO;
15981616
SDKROOT = iphoneos;
1599-
SWIFT_VERSION = 4.2;
1617+
SWIFT_VERSION = 5.0;
16001618
TARGETED_DEVICE_FAMILY = "1,2";
16011619
VALIDATE_PRODUCT = YES;
16021620
VERSIONING_SYSTEM = "apple-generic";
@@ -1748,6 +1766,7 @@
17481766
SDKROOT = appletvos;
17491767
SKIP_INSTALL = YES;
17501768
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1769+
SWIFT_VERSION = 5.0;
17511770
TARGETED_DEVICE_FAMILY = 3;
17521771
TVOS_DEPLOYMENT_TARGET = 9.2;
17531772
};
@@ -1772,6 +1791,7 @@
17721791
SDKROOT = appletvos;
17731792
SKIP_INSTALL = YES;
17741793
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1794+
SWIFT_VERSION = 5.0;
17751795
TARGETED_DEVICE_FAMILY = 3;
17761796
TVOS_DEPLOYMENT_TARGET = 9.2;
17771797
};
@@ -1955,7 +1975,6 @@
19551975
SDKROOT = watchos;
19561976
SKIP_INSTALL = YES;
19571977
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
1958-
SWIFT_VERSION = 4.0;
19591978
TARGETED_DEVICE_FAMILY = 4;
19601979
WATCHOS_DEPLOYMENT_TARGET = 2.0;
19611980
};
@@ -1983,7 +2002,6 @@
19832002
SDKROOT = watchos;
19842003
SKIP_INSTALL = YES;
19852004
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1986-
SWIFT_VERSION = 4.0;
19872005
TARGETED_DEVICE_FAMILY = 4;
19882006
WATCHOS_DEPLOYMENT_TARGET = 2.0;
19892007
};

0 commit comments

Comments
 (0)