Skip to content

Commit 096ccd6

Browse files
author
Tieme van Veen
committed
Migration to Swift 4.2
1 parent 5f3894b commit 096ccd6

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

.swift-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0
1+
4.2

ContextLabel.podspec

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Pod::Spec.new do |s|
99
s.source = { :git => 'https://github.com/michaelloistl/ContextLabel.git', :tag => s.version }
1010

1111
s.ios.deployment_target = '8.0'
12+
s.swift_version = '4.2'
1213

1314
s.source_files = 'Source/*.{swift}'
1415

ContextLabel.xcodeproj/project.pbxproj

+6-7
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,13 @@
166166
6A5EA95E1E7BC20900BCEF8C = {
167167
CreatedOnToolsVersion = 8.2.1;
168168
DevelopmentTeam = 52EDKXLXY5;
169+
LastSwiftMigration = 1010;
169170
ProvisioningStyle = Automatic;
170171
};
171172
6A5EA9721E7BC20900BCEF8C = {
172173
CreatedOnToolsVersion = 8.2.1;
173174
DevelopmentTeam = 52EDKXLXY5;
174-
LastSwiftMigration = 0920;
175+
LastSwiftMigration = 1010;
175176
ProvisioningStyle = Automatic;
176177
TestTargetID = 6A5EA95E1E7BC20900BCEF8C;
177178
};
@@ -371,7 +372,7 @@
371372
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
372373
PRODUCT_BUNDLE_IDENTIFIER = com.aplo.ContextLabel;
373374
PRODUCT_NAME = "$(TARGET_NAME)";
374-
SWIFT_VERSION = 4.0;
375+
SWIFT_VERSION = 4.2;
375376
};
376377
name = Debug;
377378
};
@@ -384,7 +385,7 @@
384385
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
385386
PRODUCT_BUNDLE_IDENTIFIER = com.aplo.ContextLabel;
386387
PRODUCT_NAME = "$(TARGET_NAME)";
387-
SWIFT_VERSION = 4.0;
388+
SWIFT_VERSION = 4.2;
388389
};
389390
name = Release;
390391
};
@@ -398,8 +399,7 @@
398399
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
399400
PRODUCT_BUNDLE_IDENTIFIER = com.aplo.ContextLabelTests;
400401
PRODUCT_NAME = "$(TARGET_NAME)";
401-
SWIFT_SWIFT3_OBJC_INFERENCE = On;
402-
SWIFT_VERSION = 4.0;
402+
SWIFT_VERSION = 4.2;
403403
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ContextLabel.app/ContextLabel";
404404
};
405405
name = Debug;
@@ -414,8 +414,7 @@
414414
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
415415
PRODUCT_BUNDLE_IDENTIFIER = com.aplo.ContextLabelTests;
416416
PRODUCT_NAME = "$(TARGET_NAME)";
417-
SWIFT_SWIFT3_OBJC_INFERENCE = On;
418-
SWIFT_VERSION = 4.0;
417+
SWIFT_VERSION = 4.2;
419418
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ContextLabel.app/ContextLabel";
420419
};
421420
name = Release;

ContextLabel/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1818

1919
window = UIWindow(frame: UIScreen.main.bounds)
2020
window!.rootViewController = UINavigationController(rootViewController: ViewController())

ContextLabel/TableViewCell.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ class TableViewCell: UITableViewCell {
4545
_label.underlineStyle = { (linkResult) in
4646
switch linkResult.detectionType {
4747
case .userHandle, .hashtag:
48-
return .styleDouble
48+
return .double
4949
case .url:
50-
return .styleSingle
50+
return .single
5151
case .textLink:
52-
return .styleSingle
52+
return .single
5353
default:
54-
return .styleNone
54+
return []
5555
}
5656
}
5757

@@ -63,7 +63,7 @@ class TableViewCell: UITableViewCell {
6363

6464
// MARK: - Initializers
6565

66-
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
66+
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
6767
super.init(style: style, reuseIdentifier: reuseIdentifier)
6868

6969
contentView.addSubview(contextLabel)

Source/ContextLabel.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public struct TouchResult {
5454
public let linkResult: LinkResult?
5555
public let touches: Set<UITouch>
5656
public let event: UIEvent?
57-
public let state: UIGestureRecognizerState
57+
public let state: UIGestureRecognizer.State
5858
}
5959

6060
public struct TextLink {
@@ -135,18 +135,18 @@ open class ContextLabel: UILabel, NSLayoutManagerDelegate, UIGestureRecognizerDe
135135
}
136136

137137
public var underlineStyle: (LinkResult) -> NSUnderlineStyle = { _ in
138-
return .styleNone
138+
return []
139139
}
140140

141141
public var modifiedAttributedString: ((NSAttributedString) -> NSAttributedString)?
142142

143143
public var didTouch: (TouchResult) -> Void = { _ in }
144144

145-
public var didCopy: (String!) -> Void = { _ in }
145+
public var didCopy: (String?) -> Void = { _ in }
146146

147147
// MARK: - Properties
148148

149-
public var touchState: UIGestureRecognizerState = .possible
149+
public var touchState: UIGestureRecognizer.State = .possible
150150

151151
// LineSpacing
152152
public var lineSpacing: CGFloat?
@@ -463,7 +463,7 @@ open class ContextLabel: UILabel, NSLayoutManagerDelegate, UIGestureRecognizerDe
463463

464464
// MARK: - Methods
465465

466-
func addAttributes(_ attributes: Dictionary<NSAttributedStringKey, Any>, range: NSRange) {
466+
func addAttributes(_ attributes: Dictionary<NSAttributedString.Key, Any>, range: NSRange) {
467467
if let contextLabelData = contextLabelData {
468468
let mutableAttributedString = NSMutableAttributedString(attributedString: contextLabelData.attributedString)
469469
mutableAttributedString.addAttributes(attributes, range: range)
@@ -510,7 +510,7 @@ open class ContextLabel: UILabel, NSLayoutManagerDelegate, UIGestureRecognizerDe
510510
self.textLinks = textLinks
511511
}
512512

513-
open func attributesFromProperties() -> [NSAttributedStringKey : Any] {
513+
open func attributesFromProperties() -> [NSAttributedString.Key : Any] {
514514

515515
// Shadow attributes
516516
let shadow = NSShadow()
@@ -547,7 +547,7 @@ open class ContextLabel: UILabel, NSLayoutManagerDelegate, UIGestureRecognizerDe
547547
}
548548

549549
// Attributes dictionary
550-
var attributes: [NSAttributedStringKey : Any] = [
550+
var attributes: [NSAttributedString.Key : Any] = [
551551
.shadow: shadow,
552552
.paragraphStyle: mutableParagraphStyle,
553553
.foregroundColor: color
@@ -560,14 +560,14 @@ open class ContextLabel: UILabel, NSLayoutManagerDelegate, UIGestureRecognizerDe
560560
return attributes
561561
}
562562

563-
fileprivate func attributesWithTextColor(_ textColor: UIColor) -> [NSAttributedStringKey : Any] {
563+
fileprivate func attributesWithTextColor(_ textColor: UIColor) -> [NSAttributedString.Key : Any] {
564564
var attributes = attributesFromProperties()
565565
attributes[.foregroundColor] = textColor
566566

567567
return attributes
568568
}
569569

570-
fileprivate func attributes(with font: UIFont?, textColor: UIColor, underlineStyle: NSUnderlineStyle) -> [NSAttributedStringKey: Any] {
570+
fileprivate func attributes(with font: UIFont?, textColor: UIColor, underlineStyle: NSUnderlineStyle) -> [NSAttributedString.Key: Any] {
571571
var attributes = attributesWithTextColor(textColor)
572572
attributes[.underlineStyle] = underlineStyle.rawValue
573573
if let font = font {

0 commit comments

Comments
 (0)