Skip to content

Commit 710cc34

Browse files
committed
#52 Fixes for Swift 4.2 compatibility
1 parent bafd948 commit 710cc34

File tree

4 files changed

+99
-8
lines changed

4 files changed

+99
-8
lines changed

Sources/SwiftRichString/Attributes/CommonsAttributes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import CoreGraphics
4141
public typealias Font = NSFont
4242
public typealias FontDescriptor = NSFontDescriptor
4343
public typealias SymbolicTraits = NSFontDescriptor.SymbolicTraits
44-
public typealias LineBreak = NSParagraphStyle.LineBreakMode
44+
public typealias LineBreak = NSLineBreakMode
4545

4646
let FontDescriptorFeatureSettingsAttribute = NSFontDescriptor.AttributeName.featureSettings
4747
let FontFeatureTypeIdentifierKey = NSFontDescriptor.FeatureKey.typeIdentifier

Sources/SwiftRichString/Style/Style.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,3 @@ public class Style: StyleProtocol {
617617
return styleCopy
618618
}
619619
}
620-
621-
// Helper function inserted by Swift 4.2 migrator.
622-
fileprivate func convertFromNSAttributedStringKey(_ input: NSAttributedString.Key) -> String {
623-
return input.rawValue
624-
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
//
2+
// SwiftRichString
3+
// Elegant Strings & Attributed Strings Toolkit for Swift
4+
//
5+
// Created by Daniele Margutti.
6+
// Copyright © 2018 Daniele Margutti. All rights reserved.
7+
//
8+
// Web: http://www.danielemargutti.com
9+
10+
// Twitter: @danielemargutti
11+
//
12+
//
13+
// Permission is hereby granted, free of charge, to any person obtaining a copy
14+
// of this software and associated documentation files (the "Software"), to deal
15+
// in the Software without restriction, including without limitation the rights
16+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17+
// copies of the Software, and to permit persons to whom the Software is
18+
// furnished to do so, subject to the following conditions:
19+
//
20+
// The above copyright notice and this permission notice shall be included in
21+
// all copies or substantial portions of the Software.
22+
//
23+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29+
// THE SOFTWARE.
30+
31+
import Foundation
32+
#if os(OSX)
33+
import AppKit
34+
#else
35+
import UIKit
36+
#endif
37+
38+
#if os(OSX)
39+
#if swift(>=4.2)
40+
#else
41+
public typealias NSLineBreakMode = NSParagraphStyle.LineBreakMode
42+
#endif
43+
#endif
44+
45+
// Helper function inserted by Swift 4.2 migrator.
46+
func convertFromNSAttributedStringKey(_ input: NSAttributedString.Key) -> String {
47+
return input.rawValue
48+
}
49+
50+
51+
#if swift(>=4.2)
52+
#else
53+
extension NSAttributedString {
54+
public typealias Key = NSAttributedStringKey
55+
}
56+
#endif
57+
58+
#if os(iOS) || os(tvOS) || os(watchOS)
59+
60+
extension NSAttributedString.Key {
61+
#if swift(>=4.2)
62+
#else
63+
static let accessibilitySpeechPunctuation = NSAttributedString.Key(UIAccessibilitySpeechAttributePunctuation)
64+
static let accessibilitySpeechLanguage = NSAttributedString.Key(UIAccessibilitySpeechAttributeLanguage)
65+
static let accessibilitySpeechPitch = NSAttributedString.Key(UIAccessibilitySpeechAttributePitch)
66+
67+
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, *)
68+
static let accessibilitySpeechIPANotation = NSAttributedString.Key(UIAccessibilitySpeechAttributeIPANotation)
69+
70+
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, *)
71+
static let accessibilitySpeechQueueAnnouncement = NSAttributedString.Key(UIAccessibilitySpeechAttributeQueueAnnouncement)
72+
73+
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, *)
74+
static let accessibilityTextHeadingLevel = NSAttributedString.Key(UIAccessibilityTextAttributeHeadingLevel)
75+
#endif
76+
}
77+
78+
#endif

SwiftRichString.xcodeproj/project.pbxproj

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88

99
/* Begin PBXBuildFile section */
1010
52D6D9871BEFF229002C0205 /* SwiftRichString.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52D6D97C1BEFF229002C0205 /* SwiftRichString.framework */; };
11+
643565F42153883B00CEEE9F /* Compatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643565F32153883B00CEEE9F /* Compatibility.swift */; };
12+
643565F52153883B00CEEE9F /* Compatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643565F32153883B00CEEE9F /* Compatibility.swift */; };
13+
643565F62153883B00CEEE9F /* Compatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643565F32153883B00CEEE9F /* Compatibility.swift */; };
14+
643565F72153883B00CEEE9F /* Compatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643565F32153883B00CEEE9F /* Compatibility.swift */; };
15+
643565F82153884B00CEEE9F /* Compatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643565F32153883B00CEEE9F /* Compatibility.swift */; };
16+
643565F92153884B00CEEE9F /* Compatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643565F32153883B00CEEE9F /* Compatibility.swift */; };
17+
643565FA2153884C00CEEE9F /* Compatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643565F32153883B00CEEE9F /* Compatibility.swift */; };
18+
643565FB2153884C00CEEE9F /* Compatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643565F32153883B00CEEE9F /* Compatibility.swift */; };
1119
64507E5B20AEEB36009455BD /* StylesManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507E5A20AEEB36009455BD /* StylesManager.swift */; };
1220
64507E5C20AEEB36009455BD /* StylesManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507E5A20AEEB36009455BD /* StylesManager.swift */; };
1321
64507E5D20AEEB36009455BD /* StylesManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507E5A20AEEB36009455BD /* StylesManager.swift */; };
@@ -250,6 +258,7 @@
250258
52D6D9E21BEFFF6E002C0205 /* SwiftRichString.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftRichString.framework; sourceTree = BUILT_PRODUCTS_DIR; };
251259
52D6D9F01BEFFFBE002C0205 /* SwiftRichString.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftRichString.framework; sourceTree = BUILT_PRODUCTS_DIR; };
252260
52D6DA0F1BF000BD002C0205 /* SwiftRichString.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftRichString.framework; sourceTree = BUILT_PRODUCTS_DIR; };
261+
643565F32153883B00CEEE9F /* Compatibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Compatibility.swift; sourceTree = "<group>"; };
253262
64507E5A20AEEB36009455BD /* StylesManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StylesManager.swift; sourceTree = "<group>"; };
254263
64507E6120AEEE8D009455BD /* UIKit+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIKit+Extras.swift"; sourceTree = "<group>"; };
255264
64507E7020AEF12C009455BD /* AssociatedValues.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssociatedValues.swift; sourceTree = "<group>"; };
@@ -477,6 +486,7 @@
477486
64507E7020AEF12C009455BD /* AssociatedValues.swift */,
478487
64507E7720AEF611009455BD /* OrderedDictionary.swift */,
479488
64507EBD20B18489009455BD /* Extensions.swift */,
489+
643565F32153883B00CEEE9F /* Compatibility.swift */,
480490
);
481491
path = Support;
482492
sourceTree = "<group>";
@@ -1055,6 +1065,7 @@
10551065
64507E9B20AF4681009455BD /* String+Ext.swift in Sources */,
10561066
6489331E209DED04000E691A /* StyleGroup.swift in Sources */,
10571067
64507E7820AEF611009455BD /* OrderedDictionary.swift in Sources */,
1068+
643565F42153883B00CEEE9F /* Compatibility.swift in Sources */,
10581069
64507E6220AEEE8D009455BD /* UIKit+Extras.swift in Sources */,
10591070
);
10601071
runOnlyForDeploymentPostprocessing = 0;
@@ -1088,6 +1099,7 @@
10881099
64507E9D20AF4681009455BD /* String+Ext.swift in Sources */,
10891100
64893320209DED04000E691A /* StyleGroup.swift in Sources */,
10901101
64507E7A20AEF611009455BD /* OrderedDictionary.swift in Sources */,
1102+
643565F62153883B00CEEE9F /* Compatibility.swift in Sources */,
10911103
64507E6420AEEE8D009455BD /* UIKit+Extras.swift in Sources */,
10921104
);
10931105
runOnlyForDeploymentPostprocessing = 0;
@@ -1113,6 +1125,7 @@
11131125
64507E9E20AF4681009455BD /* String+Ext.swift in Sources */,
11141126
64893321209DED04000E691A /* StyleGroup.swift in Sources */,
11151127
64507E7B20AEF611009455BD /* OrderedDictionary.swift in Sources */,
1128+
643565F72153883B00CEEE9F /* Compatibility.swift in Sources */,
11161129
64507E6520AEEE8D009455BD /* UIKit+Extras.swift in Sources */,
11171130
);
11181131
runOnlyForDeploymentPostprocessing = 0;
@@ -1138,6 +1151,7 @@
11381151
64507E9C20AF4681009455BD /* String+Ext.swift in Sources */,
11391152
6489331F209DED04000E691A /* StyleGroup.swift in Sources */,
11401153
64507E7920AEF611009455BD /* OrderedDictionary.swift in Sources */,
1154+
643565F52153883B00CEEE9F /* Compatibility.swift in Sources */,
11411155
64507E6320AEEE8D009455BD /* UIKit+Extras.swift in Sources */,
11421156
);
11431157
runOnlyForDeploymentPostprocessing = 0;
@@ -1166,6 +1180,7 @@
11661180
64507EF720B18F20009455BD /* ColorConvertible.swift in Sources */,
11671181
64507EEE20B18F20009455BD /* StylesManager.swift in Sources */,
11681182
64507EF420B18F20009455BD /* FontData.swift in Sources */,
1183+
643565FA2153884C00CEEE9F /* Compatibility.swift in Sources */,
11691184
);
11701185
runOnlyForDeploymentPostprocessing = 0;
11711186
};
@@ -1189,6 +1204,7 @@
11891204
64507F3520B1912B009455BD /* Extensions.swift in Sources */,
11901205
64507F2B20B1912B009455BD /* AttributedString+Ext.swift in Sources */,
11911206
64507F2520B1912B009455BD /* Style.swift in Sources */,
1207+
643565FB2153884C00CEEE9F /* Compatibility.swift in Sources */,
11921208
64507F2820B1912B009455BD /* StylesManager.swift in Sources */,
11931209
64507F2720B1912B009455BD /* StyleRegEx.swift in Sources */,
11941210
64507F3420B1912B009455BD /* OrderedDictionary.swift in Sources */,
@@ -1221,6 +1237,7 @@
12211237
648932F0209DE47C000E691A /* FontConvertible.swift in Sources */,
12221238
64507E9F20AF4681009455BD /* String+Ext.swift in Sources */,
12231239
64507EB020B056FB009455BD /* FontData.swift in Sources */,
1240+
643565F82153884B00CEEE9F /* Compatibility.swift in Sources */,
12241241
);
12251242
runOnlyForDeploymentPostprocessing = 0;
12261243
};
@@ -1248,6 +1265,7 @@
12481265
6489331C209DEAFF000E691A /* Style.swift in Sources */,
12491266
64507E8B20AF3609009455BD /* String+Subscript.swift in Sources */,
12501267
64893307209DE6CD000E691A /* FontConvertible.swift in Sources */,
1268+
643565F92153884B00CEEE9F /* Compatibility.swift in Sources */,
12511269
);
12521270
runOnlyForDeploymentPostprocessing = 0;
12531271
};
@@ -1586,7 +1604,7 @@
15861604
SKIP_INSTALL = YES;
15871605
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
15881606
TARGETED_DEVICE_FAMILY = 3;
1589-
TVOS_DEPLOYMENT_TARGET = 9.0;
1607+
TVOS_DEPLOYMENT_TARGET = 9.2;
15901608
};
15911609
name = Debug;
15921610
};
@@ -1609,7 +1627,7 @@
16091627
SKIP_INSTALL = YES;
16101628
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
16111629
TARGETED_DEVICE_FAMILY = 3;
1612-
TVOS_DEPLOYMENT_TARGET = 9.0;
1630+
TVOS_DEPLOYMENT_TARGET = 9.2;
16131631
};
16141632
name = Release;
16151633
};

0 commit comments

Comments
 (0)