Skip to content

Commit 25377f4

Browse files
committed
Merge branch 'upgrade-swift5' into 'master'
Upgrade to Swift 5 (Podspec v0.4.0) - Upgrade Code to Swift 5 - Add `focus()` method See merge request keepworks/KWVerificationCodeView!10
2 parents 70a5267 + 479db92 commit 25377f4

File tree

6 files changed

+26
-15
lines changed

6 files changed

+26
-15
lines changed

Example/KWVerificationCodeView.xcodeproj/project.pbxproj

+12-9
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,16 @@
210210
isa = PBXProject;
211211
attributes = {
212212
LastSwiftUpdateCheck = 0720;
213-
LastUpgradeCheck = 1010;
213+
LastUpgradeCheck = 1020;
214214
ORGANIZATIONNAME = CocoaPods;
215215
TargetAttributes = {
216216
607FACCF1AFB9204008FA782 = {
217217
CreatedOnToolsVersion = 6.3.1;
218-
LastSwiftMigration = 1010;
218+
LastSwiftMigration = 1020;
219219
};
220220
607FACE41AFB9204008FA782 = {
221221
CreatedOnToolsVersion = 6.3.1;
222-
LastSwiftMigration = 1010;
222+
LastSwiftMigration = 1020;
223223
TestTargetID = 607FACCF1AFB9204008FA782;
224224
};
225225
};
@@ -229,6 +229,7 @@
229229
developmentRegion = English;
230230
hasScannedForEncodings = 0;
231231
knownRegions = (
232+
English,
232233
en,
233234
Base,
234235
);
@@ -270,7 +271,7 @@
270271
files = (
271272
);
272273
inputPaths = (
273-
"${SRCROOT}/Pods/Target Support Files/Pods-KWVerificationCodeView_Example/Pods-KWVerificationCodeView_Example-frameworks.sh",
274+
"${PODS_ROOT}/Target Support Files/Pods-KWVerificationCodeView_Example/Pods-KWVerificationCodeView_Example-frameworks.sh",
274275
"${BUILT_PRODUCTS_DIR}/KWVerificationCodeView/KWVerificationCodeView.framework",
275276
);
276277
name = "[CP] Embed Pods Frameworks";
@@ -279,7 +280,7 @@
279280
);
280281
runOnlyForDeploymentPostprocessing = 0;
281282
shellPath = /bin/sh;
282-
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KWVerificationCodeView_Example/Pods-KWVerificationCodeView_Example-frameworks.sh\"\n";
283+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-KWVerificationCodeView_Example/Pods-KWVerificationCodeView_Example-frameworks.sh\"\n";
283284
showEnvVarsInLog = 0;
284285
};
285286
8A96BB52F0E82B4C4B2EC0C9 /* [CP] Check Pods Manifest.lock */ = {
@@ -373,6 +374,7 @@
373374
isa = XCBuildConfiguration;
374375
buildSettings = {
375376
ALWAYS_SEARCH_USER_PATHS = NO;
377+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
376378
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
377379
CLANG_CXX_LIBRARY = "libc++";
378380
CLANG_ENABLE_MODULES = YES;
@@ -429,6 +431,7 @@
429431
isa = XCBuildConfiguration;
430432
buildSettings = {
431433
ALWAYS_SEARCH_USER_PATHS = NO;
434+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
432435
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
433436
CLANG_CXX_LIBRARY = "libc++";
434437
CLANG_ENABLE_MODULES = YES;
@@ -487,7 +490,7 @@
487490
MODULE_NAME = ExampleApp;
488491
PRODUCT_BUNDLE_IDENTIFIER = "com.keepworks.KWVerificationCodeView-Example";
489492
PRODUCT_NAME = "$(TARGET_NAME)";
490-
SWIFT_VERSION = 4.2;
493+
SWIFT_VERSION = 5.0;
491494
TARGETED_DEVICE_FAMILY = 1;
492495
};
493496
name = Debug;
@@ -505,7 +508,7 @@
505508
MODULE_NAME = ExampleApp;
506509
PRODUCT_BUNDLE_IDENTIFIER = "com.keepworks.KWVerificationCodeView-Example";
507510
PRODUCT_NAME = "$(TARGET_NAME)";
508-
SWIFT_VERSION = 4.2;
511+
SWIFT_VERSION = 5.0;
509512
TARGETED_DEVICE_FAMILY = 1;
510513
};
511514
name = Release;
@@ -524,7 +527,7 @@
524527
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
525528
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
526529
PRODUCT_NAME = "$(TARGET_NAME)";
527-
SWIFT_VERSION = 4.2;
530+
SWIFT_VERSION = 5.0;
528531
};
529532
name = Debug;
530533
};
@@ -538,7 +541,7 @@
538541
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
539542
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
540543
PRODUCT_NAME = "$(TARGET_NAME)";
541-
SWIFT_VERSION = 4.2;
544+
SWIFT_VERSION = 5.0;
542545
};
543546
name = Release;
544547
};

Example/KWVerificationCodeView.xcodeproj/xcshareddata/xcschemes/KWVerificationCodeView-Example.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1010"
3+
LastUpgradeVersion = "1020"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Example/Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ EXTERNAL SOURCES:
99
:path: "../"
1010

1111
SPEC CHECKSUMS:
12-
KWVerificationCodeView: f9ad2952977379d34752a61967dd9b4cca3c0cde
12+
KWVerificationCodeView: ad0d493e30d203c45f21f3d7b6a4d2b64be53252
1313

1414
PODFILE CHECKSUM: c5456285278196ae1d72df7acbfd1db2fab11376
1515

16-
COCOAPODS: 1.5.3
16+
COCOAPODS: 1.7.4

KWVerificationCodeView.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'KWVerificationCodeView'
3-
s.version = '0.3.0'
3+
s.version = '0.4.0'
44
s.summary = 'A verification code view with validation.'
55
s.description = 'A customisable verification code view with built in validation. Can be used for one time passwords (OTPs), email verification codes etc.'
66
s.homepage = 'https://github.com/keepworks/kwverificationcodeview'

KWVerificationCodeView/Classes/KWVerificationCodeView.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ public protocol KWVerificationCodeViewDelegate: class {
148148
}
149149

150150
// MARK: - Public Methods
151+
public func focus() {
152+
textFieldViews[0].numberTextField.becomeFirstResponder()
153+
}
154+
151155
public func getVerificationCode() -> String {
152156
var verificationCode = ""
153157
for textFieldView in textFieldViews {
@@ -215,7 +219,7 @@ public protocol KWVerificationCodeViewDelegate: class {
215219
// MARK: - KWTextFieldDelegate
216220
extension KWVerificationCodeView: KWTextFieldDelegate {
217221
func moveToNext(_ textFieldView: KWTextFieldView) {
218-
let validIndex = textFieldViews.index(of: textFieldView) == textFieldViews.count - 1 ? textFieldViews.index(of: textFieldView)! : textFieldViews.index(of: textFieldView)! + 1
222+
let validIndex = textFieldViews.firstIndex(of: textFieldView) == textFieldViews.count - 1 ? textFieldViews.firstIndex(of: textFieldView)! : textFieldViews.firstIndex(of: textFieldView)! + 1
219223
textFieldViews[validIndex].activate()
220224
}
221225

@@ -225,7 +229,7 @@ extension KWVerificationCodeView: KWTextFieldDelegate {
225229
}
226230

227231
if textFieldView.code == " " {
228-
let validIndex = textFieldViews.index(of: textFieldView)! == 0 ? 0 : textFieldViews.index(of: textFieldView)! - 1
232+
let validIndex = textFieldViews.firstIndex(of: textFieldView)! == 0 ? 0 : textFieldViews.firstIndex(of: textFieldView)! - 1
229233
textFieldViews[validIndex].activate()
230234
textFieldViews[validIndex].reset()
231235
}

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ Returns true when the entered code is valid.
8282

8383
getVerificationCode() -> String
8484

85+
Focus on First Text Field
86+
87+
focus()
88+
8589
Returns the validation code.
8690

8791
clear()

0 commit comments

Comments
 (0)