Skip to content

Commit 241b968

Browse files
authored
Work/swift4.2 (SwiftKickMobile#227)
* Swift 4.2 conversion * Bump version number * Update swift_version
1 parent 07597ba commit 241b968

24 files changed

+120
-236
lines changed

Demo/Demo.xcodeproj/project.pbxproj

+3-20
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@
3131
remoteGlobalIDString = 86B48AEC1D5A41C900063E2B;
3232
remoteInfo = SwiftMessages;
3333
};
34-
22FB324221193A3B005C13D9 /* PBXContainerItemProxy */ = {
35-
isa = PBXContainerItemProxy;
36-
containerPortal = 22FB323A21193A3B005C13D9 /* SwiftMessages.xcodeproj */;
37-
proxyType = 2;
38-
remoteGlobalIDString = 224FB6A121163FB90081D4DE;
39-
remoteInfo = SwiftMessagesSegueExtras;
40-
};
4134
22FB324421193A3B005C13D9 /* PBXContainerItemProxy */ = {
4235
isa = PBXContainerItemProxy;
4336
containerPortal = 22FB323A21193A3B005C13D9 /* SwiftMessages.xcodeproj */;
@@ -120,7 +113,6 @@
120113
isa = PBXGroup;
121114
children = (
122115
22FB324121193A3B005C13D9 /* SwiftMessages.framework */,
123-
22FB324321193A3B005C13D9 /* SwiftMessagesSegueExtras.framework */,
124116
22FB324521193A3B005C13D9 /* SwiftMessagesTests.xctest */,
125117
);
126118
name = Products;
@@ -209,7 +201,7 @@
209201
86AEDCE11D5D1DB70030232E = {
210202
CreatedOnToolsVersion = 7.3.1;
211203
DevelopmentTeam = 38R82CD868;
212-
LastSwiftMigration = 0900;
204+
LastSwiftMigration = 1000;
213205
};
214206
};
215207
};
@@ -245,13 +237,6 @@
245237
remoteRef = 22FB324021193A3B005C13D9 /* PBXContainerItemProxy */;
246238
sourceTree = BUILT_PRODUCTS_DIR;
247239
};
248-
22FB324321193A3B005C13D9 /* SwiftMessagesSegueExtras.framework */ = {
249-
isa = PBXReferenceProxy;
250-
fileType = wrapper.framework;
251-
path = SwiftMessagesSegueExtras.framework;
252-
remoteRef = 22FB324221193A3B005C13D9 /* PBXContainerItemProxy */;
253-
sourceTree = BUILT_PRODUCTS_DIR;
254-
};
255240
22FB324521193A3B005C13D9 /* SwiftMessagesTests.xctest */ = {
256241
isa = PBXReferenceProxy;
257242
fileType = wrapper.cfbundle;
@@ -443,8 +428,7 @@
443428
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
444429
PRODUCT_BUNDLE_IDENTIFIER = it.swiftkick.Demo;
445430
PRODUCT_NAME = "$(TARGET_NAME)";
446-
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
447-
SWIFT_VERSION = 4.0;
431+
SWIFT_VERSION = 4.2;
448432
};
449433
name = Debug;
450434
};
@@ -459,8 +443,7 @@
459443
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
460444
PRODUCT_BUNDLE_IDENTIFIER = it.swiftkick.Demo;
461445
PRODUCT_NAME = "$(TARGET_NAME)";
462-
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
463-
SWIFT_VERSION = 4.0;
446+
SWIFT_VERSION = 4.2;
464447
};
465448
name = Release;
466449
};

Demo/Demo/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1515

1616
var window: UIWindow?
1717

18-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
18+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
1919
window?.tintColor = brandColor
2020
UISwitch.appearance().onTintColor = brandColor
2121
return true

Demo/Demo/ExploreViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ class ExploreViewController: UITableViewController, UITextFieldDelegate {
9797

9898
switch presentationContext.selectedSegmentIndex {
9999
case 1:
100-
config.presentationContext = .window(windowLevel: UIWindowLevelNormal)
100+
config.presentationContext = .window(windowLevel: UIWindow.Level.normal)
101101
case 2:
102-
config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
102+
config.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
103103
default:
104104
break
105105
}

Demo/Demo/Utils.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ extension UILabel {
1313
func configureBodyTextStyle() {
1414
let bodyStyle = NSMutableParagraphStyle()
1515
bodyStyle.lineSpacing = 5.0
16-
attributedText = NSAttributedString(string: text ?? "", attributes: [NSAttributedStringKey.paragraphStyle : bodyStyle])
16+
attributedText = NSAttributedString(string: text ?? "", attributes: [NSAttributedString.Key.paragraphStyle : bodyStyle])
1717
}
1818

1919
func configureCodeStyle(on substring: String?) {
20-
var attributes: [NSAttributedStringKey : Any] = [:]
20+
var attributes: [NSAttributedString.Key : Any] = [:]
2121
let codeFont = UIFont(name: "CourierNewPSMT", size: font.pointSize)!
22-
attributes[NSAttributedStringKey.font] = codeFont
23-
attributes[NSAttributedStringKey.backgroundColor] = UIColor(white: 0.96, alpha: 1)
22+
attributes[NSAttributedString.Key.font] = codeFont
23+
attributes[NSAttributedString.Key.backgroundColor] = UIColor(white: 0.96, alpha: 1)
2424
attributedText = attributedText?.setAttributes(attributes: attributes, onSubstring: substring)
2525
}
2626
}
2727

2828
extension NSAttributedString {
2929

30-
public func setAttributes(attributes: [NSAttributedStringKey : Any], onSubstring substring: String?) -> NSAttributedString {
30+
public func setAttributes(attributes: [NSAttributedString.Key : Any], onSubstring substring: String?) -> NSAttributedString {
3131
let mutableSelf = NSMutableAttributedString(attributedString: self)
3232
if let substring = substring {
3333
var range = NSRange()
@@ -46,7 +46,7 @@ extension NSAttributedString {
4646
return mutableSelf
4747
}
4848

49-
private static func set(attributes newAttributes: [NSAttributedStringKey : Any], in range: NSRange, of mutableString: NSMutableAttributedString) {
49+
private static func set(attributes newAttributes: [NSAttributedString.Key : Any], in range: NSRange, of mutableString: NSMutableAttributedString) {
5050
if range.length > 0 {
5151
var attributes = mutableString.attributes(at: range.location, effectiveRange: nil)
5252
for (key, value) in newAttributes {

Demo/Demo/ViewController.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ViewController: UITableViewController {
4949
}
5050

5151
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
52-
return UITableViewAutomaticDimension
52+
return UITableView.automaticDimension
5353
}
5454

5555
/*
@@ -71,7 +71,7 @@ class ViewController: UITableViewController {
7171
warning.configureContent(title: "Warning", body: "Consider yourself warned.", iconText: iconText)
7272
warning.button?.isHidden = true
7373
var warningConfig = SwiftMessages.defaultConfig
74-
warningConfig.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
74+
warningConfig.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
7575

7676
let success = MessageView.viewFromNib(layout: .cardView)
7777
success.configureTheme(.success)
@@ -80,7 +80,7 @@ class ViewController: UITableViewController {
8080
success.button?.isHidden = true
8181
var successConfig = SwiftMessages.defaultConfig
8282
successConfig.presentationStyle = .center
83-
successConfig.presentationContext = .window(windowLevel: UIWindowLevelNormal)
83+
successConfig.presentationContext = .window(windowLevel: UIWindow.Level.normal)
8484

8585
let info = MessageView.viewFromNib(layout: .messageView)
8686
info.configureTheme(.info)
@@ -95,14 +95,14 @@ class ViewController: UITableViewController {
9595
status.bodyLabel?.textColor = UIColor.white
9696
status.configureContent(body: "A tiny line of text covering the status bar.")
9797
var statusConfig = SwiftMessages.defaultConfig
98-
statusConfig.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
98+
statusConfig.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
9999

100100
let status2 = MessageView.viewFromNib(layout: .statusLine)
101101
status2.backgroundView.backgroundColor = UIColor.orange
102102
status2.bodyLabel?.textColor = UIColor.white
103103
status2.configureContent(body: "Switched to light status bar!")
104104
var status2Config = SwiftMessages.defaultConfig
105-
status2Config.presentationContext = .window(windowLevel: UIWindowLevelNormal)
105+
status2Config.presentationContext = .window(windowLevel: UIWindow.Level.normal)
106106
status2Config.preferredStatusBarStyle = .lightContent
107107

108108
SwiftMessages.show(view: error)
@@ -120,7 +120,7 @@ class ViewController: UITableViewController {
120120
imageView.clipsToBounds = true
121121
let messageView = BaseView(frame: .zero)
122122
messageView.layoutMargins = .zero
123-
messageView.preferredHeight = 120.0
123+
messageView.backgroundHeight = 120.0
124124
do {
125125
let backgroundView = CornerRoundingView()
126126
backgroundView.cornerRadius = 15
@@ -131,7 +131,7 @@ class ViewController: UITableViewController {
131131
}
132132
messageView.configureDropShadow()
133133
var config = SwiftMessages.defaultConfig
134-
config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
134+
config.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
135135
SwiftMessages.show(config: config, view: messageView)
136136
}
137137

@@ -141,7 +141,7 @@ class ViewController: UITableViewController {
141141
view.getTacosAction = { _ in SwiftMessages.hide() }
142142
view.cancelAction = { SwiftMessages.hide() }
143143
var config = SwiftMessages.defaultConfig
144-
config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
144+
config.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
145145
config.duration = .forever
146146
config.presentationStyle = .bottom
147147
config.dimMode = .gray(interactive: true)
@@ -160,7 +160,7 @@ class ViewController: UITableViewController {
160160
config.presentationStyle = .center
161161
config.duration = .forever
162162
config.dimMode = .blur(style: .dark, alpha: 1, interactive: true)
163-
config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
163+
config.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
164164
SwiftMessages.show(config: config, view: messageView)
165165
}
166166
}

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ var config = SwiftMessages.Config()
129129
// Slide up from the bottom.
130130
config.presentationStyle = .bottom
131131

132-
// Display in a window at the specified window level: UIWindowLevelStatusBar
133-
// displays over the status bar while UIWindowLevelNormal displays under.
134-
config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
132+
// Display in a window at the specified window level: UIWindow.Level.statusBar
133+
// displays over the status bar while UIWindow.Level.normal displays under.
134+
config.presentationContext = .window(windowLevel: .statusBar)
135135

136136
// Disable the default auto-hiding behavior.
137137
config.duration = .forever

SwiftMessages.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'SwiftMessages'
3-
spec.version = '5.0.1'
3+
spec.version = '5.0.2'
44
spec.license = { :type => 'MIT' }
55
spec.homepage = 'https://github.com/SwiftKickMobile/SwiftMessages'
66
spec.authors = { 'Timothy Moose' => 'tim@swiftkick.it' }
77
spec.summary = 'A very flexible message bar for iOS written in Swift.'
88
spec.source = {:git => 'https://github.com/SwiftKickMobile/SwiftMessages.git', :tag => spec.version}
99
spec.platform = :ios, '9.0'
10-
spec.swift_version = '4.1'
10+
spec.swift_version = '4.2'
1111
spec.ios.deployment_target = '9.0'
1212
spec.framework = 'UIKit'
1313
spec.requires_arc = true

SwiftMessages.xcodeproj/project.pbxproj

+3-5
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@
413413
TargetAttributes = {
414414
86B48AEB1D5A41C900063E2B = {
415415
CreatedOnToolsVersion = 7.3.1;
416-
LastSwiftMigration = 0900;
416+
LastSwiftMigration = 1000;
417417
ProvisioningStyle = Automatic;
418418
};
419419
86B48AF41D5A41C900063E2B = {
@@ -679,8 +679,7 @@
679679
PRODUCT_NAME = "$(TARGET_NAME)";
680680
SKIP_INSTALL = YES;
681681
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
682-
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
683-
SWIFT_VERSION = 4.0;
682+
SWIFT_VERSION = 4.2;
684683
TARGETED_DEVICE_FAMILY = "1,2";
685684
VERSIONING_SYSTEM = "apple-generic";
686685
VERSION_INFO_PREFIX = "";
@@ -706,8 +705,7 @@
706705
PRODUCT_BUNDLE_IDENTIFIER = it.swiftkick.SwiftMessages;
707706
PRODUCT_NAME = "$(TARGET_NAME)";
708707
SKIP_INSTALL = YES;
709-
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
710-
SWIFT_VERSION = 4.0;
708+
SWIFT_VERSION = 4.2;
711709
TARGETED_DEVICE_FAMILY = "1,2";
712710
VERSIONING_SYSTEM = "apple-generic";
713711
VERSION_INFO_PREFIX = "";

SwiftMessages.xcodeproj/xcshareddata/xcschemes/SwiftMessagesSegueExtras.xcscheme

-80
This file was deleted.

SwiftMessages/Animator.swift

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class AnimationContext {
6060

6161
public protocol Animator: class {
6262

63+
/// Adopting classes should declare as `weak`.
6364
var delegate: AnimationDelegate? { get set }
6465

6566
func show(context: AnimationContext, completion: @escaping AnimationCompletion)

SwiftMessages/BaseView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ open class BaseView: UIView, BackgroundViewable, MarginAdjustable {
245245

246246
open override var intrinsicContentSize: CGSize {
247247
if let preferredHeight = (self as InternalPreferredHeight).preferredHeight {
248-
return CGSize(width: UIViewNoIntrinsicMetric, height: preferredHeight)
248+
return CGSize(width: UIView.noIntrinsicMetric, height: preferredHeight)
249249
}
250250
return super.intrinsicContentSize
251251
}

SwiftMessages/MarginAdjustable+Animation.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public extension MarginAdjustable where Self: UIView {
3030
app.statusBarOrientation == .portrait || app.statusBarOrientation == .portraitUpsideDown {
3131
let frameInWindow = convert(bounds, to: window)
3232
let top = max(0, 20 - frameInWindow.minY)
33-
safeAreaInsets = UIEdgeInsetsMake(top, 0, 0, 0)
33+
safeAreaInsets = UIEdgeInsets(top: top, left: 0, bottom: 0, right: 0)
3434
} else {
3535
safeAreaInsets = .zero
3636
}

SwiftMessages/MaskingView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class MaskingView: PassthroughView {
2121
view.frame = bounds
2222
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
2323
addSubview(view)
24-
sendSubview(toBack: view)
24+
sendSubviewToBack(view)
2525
}
2626
}
2727
}

0 commit comments

Comments
 (0)