Skip to content

Commit 8bf4fb7

Browse files
chlumikkevin-hirsch
authored andcommitted
Update code to Swift 4.2 (AssistoLab#191)
* set swift 4.2 * repair uiviewanimationoptions * repair keyboard notifications * repair format options * fix compressed size * fix window Level * repair bringSubviewToFront * fix example * set swift 3 @objc inference to default * update settings
1 parent dc69b3d commit 8bf4fb7

File tree

8 files changed

+35
-25
lines changed

8 files changed

+35
-25
lines changed

Demo/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414

1515
var window: UIWindow?
1616

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

2020
return true

DropDown.xcodeproj/project.pbxproj

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@
285285
isa = PBXProject;
286286
attributes = {
287287
LastSwiftUpdateCheck = 0730;
288-
LastUpgradeCheck = 0900;
288+
LastUpgradeCheck = 1000;
289289
ORGANIZATIONNAME = "Kevin Hirsch";
290290
TargetAttributes = {
291291
0A76440E1B676C2300BF1A2D = {
@@ -423,12 +423,14 @@
423423
CLANG_WARN_BOOL_CONVERSION = YES;
424424
CLANG_WARN_COMMA = YES;
425425
CLANG_WARN_CONSTANT_CONVERSION = YES;
426+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
426427
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
427428
CLANG_WARN_EMPTY_BODY = YES;
428429
CLANG_WARN_ENUM_CONVERSION = YES;
429430
CLANG_WARN_INFINITE_RECURSION = YES;
430431
CLANG_WARN_INT_CONVERSION = YES;
431432
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
433+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
432434
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
433435
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
434436
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -461,7 +463,7 @@
461463
ONLY_ACTIVE_ARCH = YES;
462464
SDKROOT = iphoneos;
463465
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
464-
SWIFT_VERSION = 4.0;
466+
SWIFT_VERSION = 4.2;
465467
};
466468
name = Debug;
467469
};
@@ -477,12 +479,14 @@
477479
CLANG_WARN_BOOL_CONVERSION = YES;
478480
CLANG_WARN_COMMA = YES;
479481
CLANG_WARN_CONSTANT_CONVERSION = YES;
482+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
480483
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
481484
CLANG_WARN_EMPTY_BODY = YES;
482485
CLANG_WARN_ENUM_CONVERSION = YES;
483486
CLANG_WARN_INFINITE_RECURSION = YES;
484487
CLANG_WARN_INT_CONVERSION = YES;
485488
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
489+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
486490
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
487491
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
488492
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -507,7 +511,7 @@
507511
MTL_ENABLE_DEBUG_INFO = NO;
508512
SDKROOT = iphoneos;
509513
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
510-
SWIFT_VERSION = 4.0;
514+
SWIFT_VERSION = 4.2;
511515
VALIDATE_PRODUCT = YES;
512516
};
513517
name = Release;
@@ -524,7 +528,7 @@
524528
PRODUCT_BUNDLE_IDENTIFIER = com.assistoLab.Demo;
525529
PRODUCT_NAME = "$(TARGET_NAME)";
526530
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
527-
SWIFT_SWIFT3_OBJC_INFERENCE = On;
531+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
528532
TARGETED_DEVICE_FAMILY = "1,2";
529533
};
530534
name = Debug;
@@ -540,7 +544,7 @@
540544
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
541545
PRODUCT_BUNDLE_IDENTIFIER = com.assistoLab.Demo;
542546
PRODUCT_NAME = "$(TARGET_NAME)";
543-
SWIFT_SWIFT3_OBJC_INFERENCE = On;
547+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
544548
TARGETED_DEVICE_FAMILY = "1,2";
545549
};
546550
name = Release;
@@ -557,7 +561,7 @@
557561
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
558562
PRODUCT_BUNDLE_IDENTIFIER = "com.kevin.hirsch.$(PRODUCT_NAME:rfc1034identifier)";
559563
PRODUCT_NAME = "$(TARGET_NAME)";
560-
SWIFT_SWIFT3_OBJC_INFERENCE = On;
564+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
561565
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Demo.app/Demo";
562566
};
563567
name = Debug;
@@ -570,7 +574,7 @@
570574
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
571575
PRODUCT_BUNDLE_IDENTIFIER = "com.kevin.hirsch.$(PRODUCT_NAME:rfc1034identifier)";
572576
PRODUCT_NAME = "$(TARGET_NAME)";
573-
SWIFT_SWIFT3_OBJC_INFERENCE = On;
577+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
574578
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Demo.app/Demo";
575579
};
576580
name = Release;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

DropDown.xcodeproj/xcshareddata/xcschemes/DropDown.xcscheme

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "1000"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
language = ""
3029
shouldUseLaunchSchemeArgsEnv = "YES">
3130
<Testables>
3231
</Testables>
@@ -37,7 +36,6 @@
3736
buildConfiguration = "Debug"
3837
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3938
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
40-
language = ""
4139
launchStyle = "0"
4240
useCustomWorkingDirectory = "NO"
4341
ignoresPersistentStateOnLaunch = "NO"

DropDown/helpers/DPDConstants.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ internal struct DPDConstant {
4747
internal struct Animation {
4848

4949
static let Duration = 0.15
50-
static let EntranceOptions: UIViewAnimationOptions = [.allowUserInteraction, .curveEaseOut]
51-
static let ExitOptions: UIViewAnimationOptions = [.allowUserInteraction, .curveEaseIn]
50+
static let EntranceOptions: UIView.AnimationOptions = [.allowUserInteraction, .curveEaseOut]
51+
static let ExitOptions: UIView.AnimationOptions = [.allowUserInteraction, .curveEaseIn]
5252
static let DownScaleTransform = CGAffineTransform(scaleX: 0.9, y: 0.9)
5353

5454
}

DropDown/helpers/DPDKeyboardListener.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ extension KeyboardListener {
3636
NotificationCenter.default.addObserver(
3737
self,
3838
selector: #selector(keyboardWillShow(_:)),
39-
name: NSNotification.Name.UIKeyboardWillShow,
39+
name: UIResponder.keyboardWillShowNotification,
4040
object: nil)
4141
NotificationCenter.default.addObserver(
4242
self,
4343
selector: #selector(keyboardWillHide(_:)),
44-
name: NSNotification.Name.UIKeyboardWillHide,
44+
name: UIResponder.keyboardWillHideNotification,
4545
object: nil)
4646
}
4747

@@ -62,7 +62,7 @@ extension KeyboardListener {
6262
}
6363

6464
fileprivate func keyboardFrame(fromNotification notification: Notification) -> CGRect {
65-
return ((notification as NSNotification).userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? CGRect.zero
65+
return ((notification as NSNotification).userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? CGRect.zero
6666
}
6767

6868
}

DropDown/helpers/DPDUIView+Extension.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import UIKit
1212

1313
internal extension UIView {
1414

15-
func addConstraints(format: String, options: NSLayoutFormatOptions = [], metrics: [String: AnyObject]? = nil, views: [String: UIView]) {
15+
func addConstraints(format: String, options: NSLayoutConstraint.FormatOptions = [], metrics: [String: AnyObject]? = nil, views: [String: UIView]) {
1616
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: format, options: options, metrics: metrics, views: views))
1717
}
1818

19-
func addUniversalConstraints(format: String, options: NSLayoutFormatOptions = [], metrics: [String: AnyObject]? = nil, views: [String: UIView]) {
19+
func addUniversalConstraints(format: String, options: NSLayoutConstraint.FormatOptions = [], metrics: [String: AnyObject]? = nil, views: [String: UIView]) {
2020
addConstraints(format: "H:\(format)", options: options, metrics: metrics, views: views)
2121
addConstraints(format: "V:\(format)", options: options, metrics: metrics, views: views)
2222
}
@@ -44,7 +44,7 @@ internal extension UIWindow {
4444
let frontToBackWindows = Array(UIApplication.shared.windows.reversed())
4545

4646
for window in frontToBackWindows {
47-
if window.windowLevel == UIWindowLevelNormal {
47+
if window.windowLevel == UIWindow.Level.normal {
4848
currentWindow = window
4949
break
5050
}

DropDown/src/DropDown.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ public final class DropDown: UIView {
288288
/**
289289
The option of the show animation. Only change the caller. To change all drop down's use the static var.
290290
*/
291-
public var animationEntranceOptions: UIViewAnimationOptions = DropDown.animationEntranceOptions
291+
public var animationEntranceOptions: UIView.AnimationOptions = DropDown.animationEntranceOptions
292292

293293
/**
294294
The option of the hide animation. Only change the caller. To change all drop down's use the static var.
295295
*/
296-
public var animationExitOptions: UIViewAnimationOptions = DropDown.animationExitOptions
296+
public var animationExitOptions: UIView.AnimationOptions = DropDown.animationExitOptions
297297

298298
/**
299299
The downScale transformation of the tableview when the DropDown is appearing
@@ -730,7 +730,7 @@ extension DropDown {
730730
for index in 0..<dataSource.count {
731731
configureCell(templateCell, at: index)
732732
templateCell.bounds.size.height = cellHeight
733-
let width = templateCell.systemLayoutSizeFitting(UILayoutFittingCompressedSize).width
733+
let width = templateCell.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).width
734734

735735
if width > maxWidth {
736736
maxWidth = width
@@ -812,7 +812,7 @@ extension DropDown {
812812

813813
let visibleWindow = UIWindow.visibleWindow()
814814
visibleWindow?.addSubview(self)
815-
visibleWindow?.bringSubview(toFront: self)
815+
visibleWindow?.bringSubviewToFront(self)
816816

817817
self.translatesAutoresizingMaskIntoConstraints = false
818818
visibleWindow?.addUniversalConstraints(format: "|[dropDown]|", views: ["dropDown": self])
@@ -1117,12 +1117,12 @@ extension DropDown {
11171117
NotificationCenter.default.addObserver(
11181118
self,
11191119
selector: #selector(keyboardUpdate),
1120-
name: NSNotification.Name.UIKeyboardWillShow,
1120+
name: UIResponder.keyboardWillShowNotification,
11211121
object: nil)
11221122
NotificationCenter.default.addObserver(
11231123
self,
11241124
selector: #selector(keyboardUpdate),
1125-
name: NSNotification.Name.UIKeyboardWillHide,
1125+
name: UIResponder.keyboardWillHideNotification,
11261126
object: nil)
11271127
}
11281128

0 commit comments

Comments
 (0)