From 3b82e4cdb81fa42705ef84066f4fe82f29c1bbc8 Mon Sep 17 00:00:00 2001 From: Brian Clymer Date: Tue, 18 Dec 2018 14:32:50 -0600 Subject: [PATCH] Xcode 10 / Swift 4.2 upgrade. --- ALTextInputBar.xcodeproj/project.pbxproj | 20 ++++++------------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ ALTextInputBar/ALKeyboardObservingView.swift | 6 +++--- ALTextInputBar/ALTextInputBar.swift | 8 ++++---- ALTextInputBar/ALTextView.swift | 6 +++--- Example/AppDelegate.swift | 2 +- Example/ViewController.swift | 10 +++++----- 7 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 ALTextInputBar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/ALTextInputBar.xcodeproj/project.pbxproj b/ALTextInputBar.xcodeproj/project.pbxproj index b1397bd..bcdeebd 100644 --- a/ALTextInputBar.xcodeproj/project.pbxproj +++ b/ALTextInputBar.xcodeproj/project.pbxproj @@ -9,11 +9,8 @@ /* Begin PBXBuildFile section */ FA41B0B21AEBC57D00593A04 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FA41B0B01AEBC57D00593A04 /* Images.xcassets */; }; FA4AE6741B0494200086AEBF /* ALTextInputBarDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4AE6731B0494200086AEBF /* ALTextInputBarDelegate.swift */; }; - FA4AE6751B0494200086AEBF /* ALTextInputBarDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4AE6731B0494200086AEBF /* ALTextInputBarDelegate.swift */; }; FA4AE6771B0494AE0086AEBF /* ALKeyboardObservingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4AE6761B0494AE0086AEBF /* ALKeyboardObservingView.swift */; }; - FA4AE6781B0494AE0086AEBF /* ALKeyboardObservingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4AE6761B0494AE0086AEBF /* ALKeyboardObservingView.swift */; }; FA4AE67A1B0495F60086AEBF /* ALTextInputUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4AE6791B0495F60086AEBF /* ALTextInputUtilities.swift */; }; - FA4AE67B1B0495F60086AEBF /* ALTextInputUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4AE6791B0495F60086AEBF /* ALTextInputUtilities.swift */; }; FA61C9471AEAEC5F00920E37 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA61C9461AEAEC5F00920E37 /* AppDelegate.swift */; }; FA61C9491AEAEC5F00920E37 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA61C9481AEAEC5F00920E37 /* ViewController.swift */; }; FA61C95D1AEAEC5F00920E37 /* ALTextInputBarTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA61C95C1AEAEC5F00920E37 /* ALTextInputBarTests.swift */; }; @@ -184,11 +181,11 @@ FA61C9401AEAEC5F00920E37 = { CreatedOnToolsVersion = 6.3.1; DevelopmentTeam = GAPQH4AM76; - LastSwiftMigration = 0920; + LastSwiftMigration = 1010; }; FA61C9551AEAEC5F00920E37 = { CreatedOnToolsVersion = 6.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 1010; TestTargetID = FA61C9401AEAEC5F00920E37; }; }; @@ -250,9 +247,6 @@ buildActionMask = 2147483647; files = ( FA61C95D1AEAEC5F00920E37 /* ALTextInputBarTests.swift in Sources */, - FA4AE6751B0494200086AEBF /* ALTextInputBarDelegate.swift in Sources */, - FA4AE6781B0494AE0086AEBF /* ALKeyboardObservingView.swift in Sources */, - FA4AE67B1B0495F60086AEBF /* ALTextInputUtilities.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -379,8 +373,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.TextInputBar; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -396,8 +389,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.zero.TextInputBar; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -418,7 +410,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.zero.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ALTextInputBar.app/ALTextInputBar"; }; name = Debug; @@ -435,7 +427,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.zero.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ALTextInputBar.app/ALTextInputBar"; }; name = Release; diff --git a/ALTextInputBar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ALTextInputBar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ALTextInputBar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ALTextInputBar/ALKeyboardObservingView.swift b/ALTextInputBar/ALKeyboardObservingView.swift index 7abb743..6df2b2c 100644 --- a/ALTextInputBar/ALKeyboardObservingView.swift +++ b/ALTextInputBar/ALKeyboardObservingView.swift @@ -16,7 +16,7 @@ public class ALKeyboardObservingView: UIView { private var defaultHeight: CGFloat = 44 override public var intrinsicContentSize: CGSize { - return CGSize(width: UIViewNoIntrinsicMetric, height: defaultHeight) + return CGSize(width: UIView.noIntrinsicMetric, height: defaultHeight) } @@ -52,7 +52,7 @@ public class ALKeyboardObservingView: UIView { public func updateHeight(height: CGFloat) { for constraint in constraints { - if constraint.firstAttribute == NSLayoutAttribute.height && constraint.firstItem as! NSObject == self { + if constraint.firstAttribute == NSLayoutConstraint.Attribute.height && constraint.firstItem as! NSObject == self { constraint.constant = height < defaultHeight ? defaultHeight : height } } @@ -75,7 +75,7 @@ public class ALKeyboardObservingView: UIView { } private func keyboardDidChangeFrame(frame: CGRect) { - let userInfo: [AnyHashable : Any] = [UIKeyboardFrameEndUserInfoKey: NSValue(cgRect:frame)] + let userInfo: [AnyHashable : Any] = [UIResponder.keyboardFrameEndUserInfoKey: NSValue(cgRect:frame)] NotificationCenter.default.post(name: NSNotification.Name(rawValue: ALKeyboardFrameDidChangeNotification), object: nil, userInfo: userInfo) } diff --git a/ALTextInputBar/ALTextInputBar.swift b/ALTextInputBar/ALTextInputBar.swift index f3edb4c..fc350e7 100644 --- a/ALTextInputBar/ALTextInputBar.swift +++ b/ALTextInputBar/ALTextInputBar.swift @@ -178,7 +178,7 @@ open class ALTextInputBar: UIView, ALTextViewDelegate { // MARK: - View positioning and layout - override open var intrinsicContentSize: CGSize { - return CGSize(width: UIViewNoIntrinsicMetric, height: defaultHeight) + return CGSize(width: UIView.noIntrinsicMetric, height: defaultHeight) } override open func layoutSubviews() { @@ -240,8 +240,8 @@ open class ALTextInputBar: UIView, ALTextViewDelegate { textView.frame = CGRect(x: textViewX, y: textViewY, width: textViewWidth, height: textViewHeight) - let offset = UIEdgeInsetsMake(-textViewBorderPadding.top, -textViewBorderPadding.left, -textViewBorderPadding.bottom, -textViewBorderPadding.right) - textViewBorderView.frame = UIEdgeInsetsInsetRect(textView.frame, offset) + let offset = UIEdgeInsets(top: -textViewBorderPadding.top, left: -textViewBorderPadding.left, bottom: -textViewBorderPadding.bottom, right: -textViewBorderPadding.right) + textViewBorderView.frame = textView.frame.inset(by: offset) } public func updateViews(animated: Bool) { @@ -265,7 +265,7 @@ open class ALTextInputBar: UIView, ALTextViewDelegate { let height = padding + newHeight for constraint in constraints { - if constraint.firstAttribute == NSLayoutAttribute.height && constraint.firstItem as! NSObject == self { + if constraint.firstAttribute == NSLayoutConstraint.Attribute.height && constraint.firstItem as! NSObject == self { constraint.constant = height < defaultHeight ? defaultHeight : height } } diff --git a/ALTextInputBar/ALTextView.swift b/ALTextInputBar/ALTextView.swift index d82ae67..5b1292d 100644 --- a/ALTextInputBar/ALTextView.swift +++ b/ALTextInputBar/ALTextView.swift @@ -115,7 +115,7 @@ public class ALTextView: UITextView { placeholderLabel.isHidden = shouldHidePlaceholder() if !placeholderLabel.isHidden { placeholderLabel.frame = placeholderRectThatFits(rect: bounds) - sendSubview(toBack: placeholderLabel) + sendSubviewToBack(placeholderLabel) } } @@ -153,7 +153,7 @@ public class ALTextView: UITextView { var newHeight: CGFloat = 0 if let font = font { - let attributes = [NSAttributedStringKey.font: font] + let attributes = [NSAttributedString.Key.font: font] let boundingSize = CGSize(width: frame.size.width - textContainerInset.left - textContainerInset.right, height: .greatestFiniteMagnitude) let size = text.boundingRect(with: boundingSize, options: NSStringDrawingOptions.usesLineFragmentOrigin, attributes: attributes, context: nil) newHeight = ceil(size.height) @@ -201,7 +201,7 @@ public class ALTextView: UITextView { */ private func placeholderRectThatFits(rect: CGRect) -> CGRect { let padding = textContainer.lineFragmentPadding - var placeHolderRect = UIEdgeInsetsInsetRect(rect, textContainerInset) + var placeHolderRect = rect.inset(by: textContainerInset) placeHolderRect.origin.x += padding placeHolderRect.size.width -= padding * 2 diff --git a/Example/AppDelegate.swift b/Example/AppDelegate.swift index 6e13e6f..94dbea8 100644 --- a/Example/AppDelegate.swift +++ b/Example/AppDelegate.swift @@ -14,7 +14,7 @@ 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. diff --git a/Example/ViewController.swift b/Example/ViewController.swift index 8e38300..39de5b7 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -34,8 +34,8 @@ class ViewController: UIViewController { configureInputBar() NotificationCenter.default.addObserver(self, selector: #selector(keyboardFrameChanged(notification:)), name: NSNotification.Name(rawValue: ALKeyboardFrameDidChangeNotification), object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil) } override func viewWillLayoutSubviews() { @@ -77,21 +77,21 @@ class ViewController: UIViewController { @objc func keyboardFrameChanged(notification: NSNotification) { if let userInfo = notification.userInfo { - let frame = userInfo[UIKeyboardFrameEndUserInfoKey] as! CGRect + let frame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! CGRect textInputBar.frame.origin.y = frame.origin.y } } @objc func keyboardWillShow(notification: NSNotification) { if let userInfo = notification.userInfo { - let frame = userInfo[UIKeyboardFrameEndUserInfoKey] as! CGRect + let frame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! CGRect textInputBar.frame.origin.y = frame.origin.y } } @objc func keyboardWillHide(notification: NSNotification) { if let userInfo = notification.userInfo { - let frame = userInfo[UIKeyboardFrameEndUserInfoKey] as! CGRect + let frame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! CGRect textInputBar.frame.origin.y = frame.origin.y } }