From 537875070bfc0caace3e87f3e74201413195154e Mon Sep 17 00:00:00 2001 From: Firoz Date: Sat, 1 Dec 2018 08:56:43 +0530 Subject: [PATCH] Swift 4.2 updates (#26) * Support for Swift 4.2; Xcode 10 - v0.3.0 * Update example project --- .../project.pbxproj | 70 ++++--------------- .../KWVerificationCodeView-Example.xcscheme | 4 +- .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++ .../KWVerificationCodeView/AppDelegate.swift | 2 +- Example/Podfile.lock | 8 +-- KWVerificationCodeView.podspec | 2 +- .../Classes/KWTextFieldView.swift | 29 ++++---- .../Classes/KWVerificationCodeView.swift | 2 +- README.md | 6 ++ 9 files changed, 48 insertions(+), 83 deletions(-) create mode 100644 Example/KWVerificationCodeView.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Example/KWVerificationCodeView.xcodeproj/project.pbxproj b/Example/KWVerificationCodeView.xcodeproj/project.pbxproj index 991148c..13407ac 100644 --- a/Example/KWVerificationCodeView.xcodeproj/project.pbxproj +++ b/Example/KWVerificationCodeView.xcodeproj/project.pbxproj @@ -47,7 +47,7 @@ C68BD3F967305D340EA20FFD /* Pods_KWVerificationCodeView_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_KWVerificationCodeView_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D1AA5A4C20D0FD7B007FE474 /* ProgramaticalVerificationCodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgramaticalVerificationCodeViewController.swift; sourceTree = ""; }; D51BF4885572F8FECD1E4AF7 /* Pods-KWVerificationCodeView_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-KWVerificationCodeView_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-KWVerificationCodeView_Example/Pods-KWVerificationCodeView_Example.debug.xcconfig"; sourceTree = ""; }; - E6C0C121AF93D56E0FE9F947 /* KWVerificationCodeView.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = KWVerificationCodeView.podspec; path = ../KWVerificationCodeView.podspec; sourceTree = ""; }; + E6C0C121AF93D56E0FE9F947 /* KWVerificationCodeView.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = KWVerificationCodeView.podspec; path = ../KWVerificationCodeView.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; F538A5E79FE77B8D323F9B7B /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; /* End PBXFileReference section */ @@ -174,7 +174,6 @@ 607FACCD1AFB9204008FA782 /* Frameworks */, 607FACCE1AFB9204008FA782 /* Resources */, 577FAF386CE51F89750D85AF /* [CP] Embed Pods Frameworks */, - 829634171A971BCD9370CC97 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -193,8 +192,6 @@ 607FACE11AFB9204008FA782 /* Sources */, 607FACE21AFB9204008FA782 /* Frameworks */, 607FACE31AFB9204008FA782 /* Resources */, - CBA7B196B73A5116959ADE29 /* [CP] Embed Pods Frameworks */, - E561E3AAD048FA052255B138 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -213,16 +210,16 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0920; + LastUpgradeCheck = 1010; ORGANIZATIONNAME = CocoaPods; TargetAttributes = { 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; - LastSwiftMigration = 0920; + LastSwiftMigration = 1010; }; 607FACE41AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; - LastSwiftMigration = 0820; + LastSwiftMigration = 1010; TestTargetID = 607FACCF1AFB9204008FA782; }; }; @@ -285,21 +282,6 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KWVerificationCodeView_Example/Pods-KWVerificationCodeView_Example-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 829634171A971BCD9370CC97 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KWVerificationCodeView_Example/Pods-KWVerificationCodeView_Example-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; 8A96BB52F0E82B4C4B2EC0C9 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -336,36 +318,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - CBA7B196B73A5116959ADE29 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KWVerificationCodeView_Tests/Pods-KWVerificationCodeView_Tests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - E561E3AAD048FA052255B138 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KWVerificationCodeView_Tests/Pods-KWVerificationCodeView_Tests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -429,12 +381,14 @@ 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; @@ -483,12 +437,14 @@ 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; @@ -531,8 +487,7 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "com.keepworks.KWVerificationCodeView-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 1; }; name = Debug; @@ -550,8 +505,7 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "com.keepworks.KWVerificationCodeView-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 1; }; name = Release; @@ -570,7 +524,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -584,7 +538,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/Example/KWVerificationCodeView.xcodeproj/xcshareddata/xcschemes/KWVerificationCodeView-Example.xcscheme b/Example/KWVerificationCodeView.xcodeproj/xcshareddata/xcschemes/KWVerificationCodeView-Example.xcscheme index a4c00f6..5980668 100644 --- a/Example/KWVerificationCodeView.xcodeproj/xcshareddata/xcschemes/KWVerificationCodeView-Example.xcscheme +++ b/Example/KWVerificationCodeView.xcodeproj/xcshareddata/xcschemes/KWVerificationCodeView-Example.xcscheme @@ -1,6 +1,6 @@ + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Example/KWVerificationCodeView/AppDelegate.swift b/Example/KWVerificationCodeView/AppDelegate.swift index e9d1fd4..e73c166 100644 --- a/Example/KWVerificationCodeView/AppDelegate.swift +++ b/Example/KWVerificationCodeView/AppDelegate.swift @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { return true } diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 5b87348..e1f2128 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,16 +1,16 @@ PODS: - - KWVerificationCodeView (0.2.0) + - KWVerificationCodeView (0.3.0) DEPENDENCIES: - KWVerificationCodeView (from `../`) EXTERNAL SOURCES: KWVerificationCodeView: - :path: ../ + :path: "../" SPEC CHECKSUMS: - KWVerificationCodeView: af71b4387c379ae52e8620b1f6a0ca334fc285b4 + KWVerificationCodeView: f9ad2952977379d34752a61967dd9b4cca3c0cde PODFILE CHECKSUM: c5456285278196ae1d72df7acbfd1db2fab11376 -COCOAPODS: 1.3.1 +COCOAPODS: 1.5.3 diff --git a/KWVerificationCodeView.podspec b/KWVerificationCodeView.podspec index ab34b86..6c91ad5 100644 --- a/KWVerificationCodeView.podspec +++ b/KWVerificationCodeView.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'KWVerificationCodeView' - s.version = '0.2.0' + s.version = '0.3.0' s.summary = 'A verification code view with validation.' s.description = 'A customisable verification code view with built in validation. Can be used for one time passwords (OTPs), email verification codes etc.' s.homepage = 'https://github.com/keepworks/kwverificationcodeview' diff --git a/KWVerificationCodeView/Classes/KWTextFieldView.swift b/KWVerificationCodeView/Classes/KWTextFieldView.swift index 2139b5b..33d7167 100644 --- a/KWVerificationCodeView/Classes/KWTextFieldView.swift +++ b/KWVerificationCodeView/Classes/KWTextFieldView.swift @@ -98,15 +98,6 @@ protocol KWTextFieldDelegate: class { NotificationCenter.default.removeObserver(self) } - // MARK: - Private Methods - private func setup() { - loadViewFromNib() - numberTextField.delegate = self - numberTextField.autocorrectionType = UITextAutocorrectionType.no - - NotificationCenter.default.addObserver(self, selector: #selector(textFieldDidChange(_:)), name: UITextField.textDidChangeNotification, object: numberTextField) - } - // MARK: - Public Methods public func activate() { numberTextField.becomeFirstResponder() @@ -124,16 +115,24 @@ protocol KWTextFieldDelegate: class { updateUnderline() } - // MARK: - FilePrivate Methods - @objc dynamic fileprivate func textFieldDidChange(_ notification: Foundation.Notification) { - if numberTextField.text?.count == 0 { - numberTextField.text = " " - } + // MARK: - Private Methods + private func setup() { + loadViewFromNib() + numberTextField.delegate = self + numberTextField.autocorrectionType = UITextAutocorrectionType.no + + NotificationCenter.default.addObserver(self, selector: #selector(textFieldDidChange(_:)), name: UITextField.textDidChangeNotification, object: numberTextField) } - fileprivate func updateUnderline() { + private func updateUnderline() { underlineView.backgroundColor = numberTextField.text?.trim() != "" ? underlineSelectedColor : underlineColor } + + @objc private func textFieldDidChange(_ notification: Foundation.Notification) { + if numberTextField.text?.count == 0 { + numberTextField.text = " " + } + } } // MARK: - UITextFieldDelegate diff --git a/KWVerificationCodeView/Classes/KWVerificationCodeView.swift b/KWVerificationCodeView/Classes/KWVerificationCodeView.swift index d8f0dde..f702e40 100644 --- a/KWVerificationCodeView/Classes/KWVerificationCodeView.swift +++ b/KWVerificationCodeView/Classes/KWVerificationCodeView.swift @@ -116,7 +116,7 @@ public protocol KWVerificationCodeViewDelegate: class { } } - fileprivate var textFieldViews = [KWTextFieldView]() + private var textFieldViews = [KWTextFieldView]() private var keyboardAppearance = UIKeyboardAppearance.default private var textFieldFont = UIFont.systemFont(ofSize: 24.0) private var requiredDigits: UInt8 { diff --git a/README.md b/README.md index 598e384..c9f8002 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,12 @@ it, simply add the following line to your Podfile: ```ruby pod "KWVerificationCodeView" ``` + +Or for xcode 9 use: +```ruby +pod "KWVerificationCodeView", '0.2.0' +``` + ## Usage Add a `UIView` in your *Storyboard* and change the class to `KWVerificationCodeView`. You can set the properties in the *Attributes Inspector* and see a live preview: