From 0c115f371bcf57563a9b0e668ef060c046b74bc6 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 31 Oct 2019 21:12:39 +0000 Subject: [PATCH 1/2] Update to Xcode 11.1 recommended settings --- ICInputAccessory.xcodeproj/project.pbxproj | 5 +++- .../xcshareddata/xcschemes/Example.xcscheme | 24 ++++++++----------- .../xcschemes/ICInputAccessory-iOS.xcscheme | 6 +---- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/ICInputAccessory.xcodeproj/project.pbxproj b/ICInputAccessory.xcodeproj/project.pbxproj index fe17dc4..0a7f0f8 100644 --- a/ICInputAccessory.xcodeproj/project.pbxproj +++ b/ICInputAccessory.xcodeproj/project.pbxproj @@ -317,7 +317,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1110; ORGANIZATIONNAME = "Polydice, Inc."; TargetAttributes = { B53376871F4436D000230739 = { @@ -342,6 +342,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -572,6 +573,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -631,6 +633,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; diff --git a/ICInputAccessory.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/ICInputAccessory.xcodeproj/xcshareddata/xcschemes/Example.xcscheme index 46dccad..6553137 100644 --- a/ICInputAccessory.xcodeproj/xcshareddata/xcschemes/Example.xcscheme +++ b/ICInputAccessory.xcodeproj/xcshareddata/xcschemes/Example.xcscheme @@ -1,6 +1,6 @@ + + + + @@ -39,17 +48,6 @@ - - - - - - - - - - - - Date: Thu, 31 Oct 2019 21:18:09 +0000 Subject: [PATCH 2/2] Update syntax to Swift 5 --- CHANGELOG.md | 1 + ICInputAccessory.xcodeproj/project.pbxproj | 18 +++++++++--------- README.md | 3 ++- .../KeyboardDismissAccessoryView.swift | 2 +- .../OptionPickerControl.swift | 2 +- Source/TokenField/Token.swift | 10 +++++----- Source/TokenField/TokenField.swift | 4 ++-- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9456e11..f0fa4cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Unreleased * Update CI infrastructure to GitHub Actions +* Swift 5.0 ## v2.0.1 diff --git a/ICInputAccessory.xcodeproj/project.pbxproj b/ICInputAccessory.xcodeproj/project.pbxproj index 0a7f0f8..bb4a5fb 100644 --- a/ICInputAccessory.xcodeproj/project.pbxproj +++ b/ICInputAccessory.xcodeproj/project.pbxproj @@ -322,18 +322,18 @@ TargetAttributes = { B53376871F4436D000230739 = { CreatedOnToolsVersion = 8.3.3; - LastSwiftMigration = 0900; + LastSwiftMigration = 1110; ProvisioningStyle = Automatic; }; B533769A1F4436D000230739 = { CreatedOnToolsVersion = 8.3.3; - LastSwiftMigration = 0900; + LastSwiftMigration = 1110; ProvisioningStyle = Automatic; TestTargetID = B53376871F4436D000230739; }; B56BC4291C89A7EA00C20AD6 = { CreatedOnToolsVersion = 7.2.1; - LastSwiftMigration = 0900; + LastSwiftMigration = 1110; }; }; }; @@ -503,7 +503,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.polydice.ICInputAccessory.Example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -522,7 +522,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.polydice.ICInputAccessory.Example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -543,7 +543,7 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = Example; }; name = Debug; @@ -564,7 +564,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = Example; }; name = Release; @@ -698,7 +698,7 @@ PRODUCT_NAME = ICInputAccessory; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -718,7 +718,7 @@ PRODUCT_NAME = ICInputAccessory; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/README.md b/README.md index ecc3119..3d423f1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Customized text fields used in the [iCook app](https://itunes.apple.com/app/id55 [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg)](https://github.com/Carthage/Carthage) [![CocoaPods Compatible](https://img.shields.io/cocoapods/v/ICInputAccessory.svg)](https://cocoapods.org/pods/ICInputAccessory) ![Platform](https://img.shields.io/cocoapods/p/ICInputAccessory.svg) -![Swift 4.1](https://img.shields.io/badge/Swift-4.1-orange.svg) +![Swift 5](https://img.shields.io/badge/Swift-5-orange.svg) ### KeyboardDismissTextField @@ -36,6 +36,7 @@ ICInputAccessory | iOS | Xcode | Swift `~> 1.4.0` | 8.0+ | 8.3 | ![Swift 3.1](https://img.shields.io/badge/Swift-3.1-orange.svg) `~> 1.5.0` | 8.0+ | 9.3 | ![Swift 4.1](https://img.shields.io/badge/Swift-4.1-orange.svg) `~> 2.0.0` | 8.0+ | 10.0 | ![Swift 4.1](https://img.shields.io/badge/Swift-4.1-orange.svg) +`develop` | 8.0+ | 11.1 | ![Swift 5.0](https://img.shields.io/badge/Swift-5.0-orange.svg) ## Installation diff --git a/Source/KeyboardDismissTextField/KeyboardDismissAccessoryView.swift b/Source/KeyboardDismissTextField/KeyboardDismissAccessoryView.swift index 136f814..0827ed5 100644 --- a/Source/KeyboardDismissTextField/KeyboardDismissAccessoryView.swift +++ b/Source/KeyboardDismissTextField/KeyboardDismissAccessoryView.swift @@ -42,7 +42,7 @@ open class KeyboardDismissAccessoryView: UIView { let _button = UIButton() let resources = Bundle(for: type(of: self)) let icon = UIImage(named: "icook-iphone-button-hide-keyboard", in: resources, compatibleWith: nil) - _button.setImage(icon, for: UIControlState()) + _button.setImage(icon, for: UIControl.State()) _button.backgroundColor = Constants.ButtonColor _button.isExclusiveTouch = true _button.layer.cornerRadius = 4 diff --git a/Source/OptionPickerControl/OptionPickerControl.swift b/Source/OptionPickerControl/OptionPickerControl.swift index 76b40fb..9dc5898 100644 --- a/Source/OptionPickerControl/OptionPickerControl.swift +++ b/Source/OptionPickerControl/OptionPickerControl.swift @@ -52,7 +52,7 @@ open class OptionPickerControl: UIControl, UIPickerViewDat didSet { if hiddenTextField.isFirstResponder { sendActions(for: .valueChanged) - } else if let index = options.index(of: selectedOption) { + } else if let index = options.firstIndex(of: selectedOption) { picker.selectRow(index, inComponent: 0, animated: false) } } diff --git a/Source/TokenField/Token.swift b/Source/TokenField/Token.swift index 99e08c5..9c8b242 100644 --- a/Source/TokenField/Token.swift +++ b/Source/TokenField/Token.swift @@ -31,7 +31,7 @@ internal class Token: UIView { var text = "" { didSet { updateTextLabel() - frame = CGRect(origin: CGPoint.zero, size: systemLayoutSizeFitting(UILayoutFittingCompressedSize)) + frame = CGRect(origin: CGPoint.zero, size: systemLayoutSizeFitting(UIView.layoutFittingCompressedSize)) } } @@ -41,7 +41,7 @@ internal class Token: UIView { } } - var normalTextAttributes: [NSAttributedStringKey: NSObject] = [ + var normalTextAttributes: [NSAttributedString.Key: NSObject] = [ .foregroundColor: UIColor(red: 0.14, green: 0.38, blue: 0.95, alpha: 1), .backgroundColor: UIColor.clear ] { @@ -51,7 +51,7 @@ internal class Token: UIView { } } - var highlightedTextAttributes: [NSAttributedStringKey: NSObject] = [ + var highlightedTextAttributes: [NSAttributedString.Key: NSObject] = [ .foregroundColor: UIColor.white, .backgroundColor: UIColor(red: 0.14, green: 0.38, blue: 0.95, alpha: 1) ] { @@ -93,8 +93,8 @@ internal class Token: UIView { convenience init( text: String, delimiter: String = ",", - normalAttributes: [NSAttributedStringKey: NSObject]? = nil, - highlightedAttributes: [NSAttributedStringKey: NSObject]? = nil + normalAttributes: [NSAttributedString.Key: NSObject]? = nil, + highlightedAttributes: [NSAttributedString.Key: NSObject]? = nil ) { self.init() if let attributes = normalAttributes { normalTextAttributes = attributes } diff --git a/Source/TokenField/TokenField.swift b/Source/TokenField/TokenField.swift index f71aac2..316217a 100644 --- a/Source/TokenField/TokenField.swift +++ b/Source/TokenField/TokenField.swift @@ -123,14 +123,14 @@ open class TokenField: UIView, UITextFieldDelegate, BackspaceTextFieldDelegate { } /// Customized attributes for tokens in the normal state, e.g. `.font` and `.foregroundColor`. - public var normalTokenAttributes: [NSAttributedStringKey: NSObject]? { + public var normalTokenAttributes: [NSAttributedString.Key: NSObject]? { didSet { tokens.forEach { $0.normalTextAttributes = normalTokenAttributes ?? [:] } } } /// Customized attributes for tokens in the highlighted state. - public var highlightedTokenAttributes: [NSAttributedStringKey: NSObject]? { + public var highlightedTokenAttributes: [NSAttributedString.Key: NSObject]? { didSet { tokens.forEach { $0.highlightedTextAttributes = normalTokenAttributes ?? [:] } }