From f8c3903750cefea34c4a253965ebad91c8d3e271 Mon Sep 17 00:00:00 2001 From: Amit Kumar Swami Date: Tue, 16 Oct 2018 16:20:39 +0800 Subject: [PATCH] Update to Xcode 10, Swift 4.2 --- .../project.pbxproj | 41 +++++++++++-- .../FloatLabelExample/AppDelegate.swift | 2 +- .../Base.lproj/Main.storyboard | 58 ++++++++++--------- FloatLabelFields/FloatLabelTextField.swift | 10 ++-- FloatLabelFields/FloatLabelTextView.swift | 18 +++--- 5 files changed, 82 insertions(+), 47 deletions(-) diff --git a/FloatLabelExample/FloatLabelExample.xcodeproj/project.pbxproj b/FloatLabelExample/FloatLabelExample.xcodeproj/project.pbxproj index 87413f9..7ca6fa7 100644 --- a/FloatLabelExample/FloatLabelExample.xcodeproj/project.pbxproj +++ b/FloatLabelExample/FloatLabelExample.xcodeproj/project.pbxproj @@ -114,12 +114,12 @@ attributes = { LastSwiftMigration = 0730; LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0730; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = "RookSoft Ltd."; TargetAttributes = { DD72F5E61A2845270097D54A = { CreatedOnToolsVersion = 6.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 1000; }; }; }; @@ -196,13 +196,23 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -211,6 +221,7 @@ ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -223,11 +234,13 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.1; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -240,13 +253,23 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -254,15 +277,19 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.1; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -276,7 +303,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.farook.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -288,7 +316,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.farook.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/FloatLabelExample/FloatLabelExample/AppDelegate.swift b/FloatLabelExample/FloatLabelExample/AppDelegate.swift index bc9ceff..b0adfad 100644 --- a/FloatLabelExample/FloatLabelExample/AppDelegate.swift +++ b/FloatLabelExample/FloatLabelExample/AppDelegate.swift @@ -12,7 +12,7 @@ import UIKit class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application:UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey:Any]? = nil) -> Bool { + func application(_ application:UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey:Any]? = nil) -> Bool { // Override point for customization after application launch. return true } diff --git a/FloatLabelExample/FloatLabelExample/Base.lproj/Main.storyboard b/FloatLabelExample/FloatLabelExample/Base.lproj/Main.storyboard index e83a143..7b8d6ed 100644 --- a/FloatLabelExample/FloatLabelExample/Base.lproj/Main.storyboard +++ b/FloatLabelExample/FloatLabelExample/Base.lproj/Main.storyboard @@ -1,8 +1,11 @@ - - + + + + + - - + + @@ -10,26 +13,26 @@ - + - + - + - + - + - + @@ -37,53 +40,56 @@ - - + + - + - + - - + + + + + - - + + - + - + - - + + - - - + + + @@ -112,7 +118,7 @@ - + diff --git a/FloatLabelFields/FloatLabelTextField.swift b/FloatLabelFields/FloatLabelTextField.swift index 57c9462..3bd7172 100644 --- a/FloatLabelFields/FloatLabelTextField.swift +++ b/FloatLabelFields/FloatLabelTextField.swift @@ -115,7 +115,7 @@ import UIKit if let txt = text , !txt.isEmpty { var top = ceil(title.font.lineHeight + hintYPadding) top = min(top, maxTopInset()) - r = UIEdgeInsetsInsetRect(r, UIEdgeInsetsMake(top, 0.0, 0.0, 0.0)) + r = r.inset(by: UIEdgeInsets.init(top: top, left: 0.0, bottom: 0.0, right: 0.0)) } return r.integral } @@ -125,7 +125,7 @@ import UIKit if let txt = text , !txt.isEmpty { var top = ceil(title.font.lineHeight + hintYPadding) top = min(top, maxTopInset()) - r = UIEdgeInsetsInsetRect(r, UIEdgeInsetsMake(top, 0.0, 0.0, 0.0)) + r = r.inset(by: UIEdgeInsets.init(top: top, left: 0.0, bottom: 0.0, right: 0.0)) } return r.integral } @@ -144,7 +144,7 @@ import UIKit // MARK:- Private Methods fileprivate func setup() { - borderStyle = UITextBorderStyle.none + borderStyle = UITextField.BorderStyle.none titleActiveTextColour = tintColor // Set up title label title.alpha = 0.0 @@ -177,7 +177,7 @@ import UIKit fileprivate func showTitle(_ animated:Bool) { let dur = animated ? animationDuration : 0 - UIView.animate(withDuration: dur, delay:0, options: [UIViewAnimationOptions.beginFromCurrentState, UIViewAnimationOptions.curveEaseOut], animations:{ + UIView.animate(withDuration: dur, delay:0, options: [UIView.AnimationOptions.beginFromCurrentState, UIView.AnimationOptions.curveEaseOut], animations:{ // Animation self.title.alpha = 1.0 var r = self.title.frame @@ -188,7 +188,7 @@ import UIKit fileprivate func hideTitle(_ animated:Bool) { let dur = animated ? animationDuration : 0 - UIView.animate(withDuration: dur, delay:0, options: [UIViewAnimationOptions.beginFromCurrentState, UIViewAnimationOptions.curveEaseIn], animations:{ + UIView.animate(withDuration: dur, delay:0, options: [UIView.AnimationOptions.beginFromCurrentState, UIView.AnimationOptions.curveEaseIn], animations:{ // Animation self.title.alpha = 0.0 var r = self.title.frame diff --git a/FloatLabelFields/FloatLabelTextView.swift b/FloatLabelFields/FloatLabelTextView.swift index 3b24ae5..5670470 100644 --- a/FloatLabelFields/FloatLabelTextView.swift +++ b/FloatLabelFields/FloatLabelTextView.swift @@ -91,9 +91,9 @@ import UIKit deinit { if !isIB { let nc = NotificationCenter.default - nc.removeObserver(self, name:NSNotification.Name.UITextViewTextDidChange, object:self) - nc.removeObserver(self, name:NSNotification.Name.UITextViewTextDidBeginEditing, object:self) - nc.removeObserver(self, name:NSNotification.Name.UITextViewTextDidEndEditing, object:self) + nc.removeObserver(self, name:UITextView.textDidChangeNotification, object:self) + nc.removeObserver(self, name:UITextView.textDidBeginEditingNotification, object:self) + nc.removeObserver(self, name:UITextView.textDidEndEditingNotification, object:self) } } @@ -152,9 +152,9 @@ import UIKit // Observers if !isIB { let nc = NotificationCenter.default - nc.addObserver(self, selector:#selector(UIView.layoutSubviews), name:NSNotification.Name.UITextViewTextDidChange, object:self) - nc.addObserver(self, selector:#selector(UIView.layoutSubviews), name:NSNotification.Name.UITextViewTextDidBeginEditing, object:self) - nc.addObserver(self, selector:#selector(UIView.layoutSubviews), name:NSNotification.Name.UITextViewTextDidEndEditing, object:self) + nc.addObserver(self, selector:#selector(UIView.layoutSubviews), name:UITextView.textDidChangeNotification, object:self) + nc.addObserver(self, selector:#selector(UIView.layoutSubviews), name:UITextView.textDidBeginEditingNotification, object:self) + nc.addObserver(self, selector:#selector(UIView.layoutSubviews), name:UITextView.textDidEndEditingNotification, object:self) } } @@ -165,7 +165,7 @@ import UIKit } fileprivate func textRect()->CGRect { - var r = UIEdgeInsetsInsetRect(bounds, contentInset) + var r = bounds.inset(by: contentInset) r.origin.x += textContainer.lineFragmentPadding r.origin.y += textContainerInset.top return r.integral @@ -191,7 +191,7 @@ import UIKit fileprivate func showTitle(_ animated:Bool) { let dur = animated ? animationDuration : 0 - UIView.animate(withDuration: dur, delay:0, options: [UIViewAnimationOptions.beginFromCurrentState, UIViewAnimationOptions.curveEaseOut], animations:{ + UIView.animate(withDuration: dur, delay:0, options: [UIView.AnimationOptions.beginFromCurrentState, UIView.AnimationOptions.curveEaseOut], animations:{ // Animation self.title.alpha = 1.0 var r = self.title.frame @@ -202,7 +202,7 @@ import UIKit fileprivate func hideTitle(_ animated:Bool) { let dur = animated ? animationDuration : 0 - UIView.animate(withDuration: dur, delay:0, options: [UIViewAnimationOptions.beginFromCurrentState, UIViewAnimationOptions.curveEaseIn], animations:{ + UIView.animate(withDuration: dur, delay:0, options: [UIView.AnimationOptions.beginFromCurrentState, UIView.AnimationOptions.curveEaseIn], animations:{ // Animation self.title.alpha = 0.0 var r = self.title.frame