Skip to content

Commit ba27b0e

Browse files
Merge pull request #205 from syn-deepakbadiger/Swift_4.1
Enabled Swift 4.1
2 parents fb50b97 + b3f8d74 commit ba27b0e

File tree

12 files changed

+55
-26
lines changed

12 files changed

+55
-26
lines changed

SwiftValidator/Rules/ExactLengthRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ExactLengthRule : Rule {
3636
- returns: A boolean value. True if validation is successful; False if validation fails.
3737
*/
3838
public func validate(_ value: String) -> Bool {
39-
return value.characters.count == length
39+
return value.count == length
4040
}
4141

4242
/**

SwiftValidator/Rules/FloatRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class FloatRule:Rule {
3434
public func validate(_ value: String) -> Bool {
3535
let regex = try? NSRegularExpression(pattern: "^[-+]?(\\d*[.])?\\d+$", options: [])
3636
if let regex = regex {
37-
let match = regex.numberOfMatches(in: value, options: [], range: NSRange(location: 0, length: value.characters.count))
37+
let match = regex.numberOfMatches(in: value, options: [], range: NSRange(location: 0, length: value.count))
3838
return match == 1
3939
}
4040
return false

SwiftValidator/Rules/FullNameRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class FullNameRule : Rule {
3131
- returns: A boolean value. True if validation is successful; False if validation fails.
3232
*/
3333
public func validate(_ value: String) -> Bool {
34-
let nameArray: [String] = value.characters.split { $0 == " " }.map { String($0) }
34+
let nameArray: [String] = value.split { $0 == " " }.map { String($0) }
3535
return nameArray.count >= 2
3636
}
3737

SwiftValidator/Rules/ISBNRule.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class ISBNRule: Rule {
3838
fatalError("Invalid ISBN sanitizing regex")
3939
}
4040

41-
let sanitized = regex.stringByReplacingMatches(in: value, options: [], range: NSMakeRange(0, value.characters.count), withTemplate: "")
41+
let sanitized = regex.stringByReplacingMatches(in: value, options: [], range: NSMakeRange(0, value.count), withTemplate: "")
4242

4343
return ISBN10Validator().verify(sanitized) || ISBN13Validator().verify(sanitized)
4444
}
@@ -140,15 +140,15 @@ private struct ISBN10Validator: ISBNValidator {
140140
var checksum = 0
141141

142142
for i in 0..<9 {
143-
if let intCharacter = Int(String(input[input.characters.index(input.startIndex, offsetBy: i)])) {
143+
if let intCharacter = Int(String(input[input.index(input.startIndex, offsetBy: i)])) {
144144
checksum += (i + 1) * intCharacter
145145
}
146146
}
147147

148-
if (input[input.characters.index(input.startIndex, offsetBy: 9)] == "X") {
148+
if (input[input.index(input.startIndex, offsetBy: 9)] == "X") {
149149
checksum += 10 * 10
150150
} else {
151-
if let intCharacter = Int(String(input[input.characters.index(input.startIndex, offsetBy: 9)])) {
151+
if let intCharacter = Int(String(input[input.index(input.startIndex, offsetBy: 9)])) {
152152
checksum += 10 * intCharacter
153153
}
154154
}
@@ -176,13 +176,13 @@ private struct ISBN13Validator: ISBNValidator {
176176
var checksum = 0
177177

178178
for i in 0..<12 {
179-
if let intCharacter = Int(String(input[input.characters.index(input.startIndex, offsetBy: i)])) {
179+
if let intCharacter = Int(String(input[input.index(input.startIndex, offsetBy: i)])) {
180180
print("\(factor[i%2]) * \(intCharacter)")
181181
checksum += factor[i % 2] * intCharacter
182182
}
183183
}
184184

185-
if let lastInt = Int(String(input[input.characters.index(input.startIndex, offsetBy: 12)])) {
185+
if let lastInt = Int(String(input[input.index(input.startIndex, offsetBy: 12)])) {
186186
return (lastInt - ((10 - (checksum % 10)) % 10) == 0)
187187
}
188188

SwiftValidator/Rules/MaxLengthRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class MaxLengthRule: Rule {
3737
- returns: A boolean value. True if validation is successful; False if validation fails.
3838
*/
3939
public func validate(_ value: String) -> Bool {
40-
return value.characters.count <= DEFAULT_LENGTH
40+
return value.count <= DEFAULT_LENGTH
4141
}
4242

4343
/**

SwiftValidator/Rules/MinLengthRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class MinLengthRule: Rule {
3838
- returns: A boolean value. True if validation is successful; False if validation fails.
3939
*/
4040
public func validate(_ value: String) -> Bool {
41-
return value.characters.count >= DEFAULT_LENGTH
41+
return value.count >= DEFAULT_LENGTH
4242
}
4343

4444
/**

Validator.xcodeproj/project.pbxproj

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
attributes = {
397397
LastSwiftMigration = 0700;
398398
LastSwiftUpdateCheck = 0700;
399-
LastUpgradeCheck = 0800;
399+
LastUpgradeCheck = 0930;
400400
ORGANIZATIONNAME = jpotts18;
401401
TargetAttributes = {
402402
62D1AE161A1E6D4400E4DFF8 = {
@@ -584,14 +584,22 @@
584584
CLANG_CXX_LIBRARY = "libc++";
585585
CLANG_ENABLE_MODULES = YES;
586586
CLANG_ENABLE_OBJC_ARC = YES;
587+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
587588
CLANG_WARN_BOOL_CONVERSION = YES;
589+
CLANG_WARN_COMMA = YES;
588590
CLANG_WARN_CONSTANT_CONVERSION = YES;
591+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
589592
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
590593
CLANG_WARN_EMPTY_BODY = YES;
591594
CLANG_WARN_ENUM_CONVERSION = YES;
592595
CLANG_WARN_INFINITE_RECURSION = YES;
593596
CLANG_WARN_INT_CONVERSION = YES;
597+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
598+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
599+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
594600
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
601+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
602+
CLANG_WARN_STRICT_PROTOTYPES = YES;
595603
CLANG_WARN_SUSPICIOUS_MOVE = YES;
596604
CLANG_WARN_UNREACHABLE_CODE = YES;
597605
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -619,6 +627,7 @@
619627
ONLY_ACTIVE_ARCH = YES;
620628
SDKROOT = iphoneos;
621629
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
630+
SWIFT_VERSION = 4.0;
622631
};
623632
name = Debug;
624633
};
@@ -630,14 +639,22 @@
630639
CLANG_CXX_LIBRARY = "libc++";
631640
CLANG_ENABLE_MODULES = YES;
632641
CLANG_ENABLE_OBJC_ARC = YES;
642+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
633643
CLANG_WARN_BOOL_CONVERSION = YES;
644+
CLANG_WARN_COMMA = YES;
634645
CLANG_WARN_CONSTANT_CONVERSION = YES;
646+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
635647
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
636648
CLANG_WARN_EMPTY_BODY = YES;
637649
CLANG_WARN_ENUM_CONVERSION = YES;
638650
CLANG_WARN_INFINITE_RECURSION = YES;
639651
CLANG_WARN_INT_CONVERSION = YES;
652+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
653+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
654+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
640655
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
656+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
657+
CLANG_WARN_STRICT_PROTOTYPES = YES;
641658
CLANG_WARN_SUSPICIOUS_MOVE = YES;
642659
CLANG_WARN_UNREACHABLE_CODE = YES;
643660
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -656,6 +673,8 @@
656673
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
657674
MTL_ENABLE_DEBUG_INFO = NO;
658675
SDKROOT = iphoneos;
676+
SWIFT_COMPILATION_MODE = wholemodule;
677+
SWIFT_VERSION = 4.0;
659678
VALIDATE_PRODUCT = YES;
660679
};
661680
name = Release;
@@ -668,7 +687,7 @@
668687
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
669688
PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)";
670689
PRODUCT_NAME = "$(TARGET_NAME)";
671-
SWIFT_VERSION = 3.0;
690+
SWIFT_VERSION = 4.0;
672691
};
673692
name = Debug;
674693
};
@@ -681,7 +700,7 @@
681700
PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)";
682701
PRODUCT_NAME = "$(TARGET_NAME)";
683702
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
684-
SWIFT_VERSION = 3.0;
703+
SWIFT_VERSION = 4.0;
685704
};
686705
name = Release;
687706
};
@@ -697,7 +716,7 @@
697716
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
698717
PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)";
699718
PRODUCT_NAME = "$(TARGET_NAME)";
700-
SWIFT_VERSION = 3.0;
719+
SWIFT_VERSION = 4.1;
701720
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator";
702721
};
703722
name = Debug;
@@ -710,14 +729,15 @@
710729
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
711730
PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)";
712731
PRODUCT_NAME = "$(TARGET_NAME)";
713-
SWIFT_VERSION = 3.0;
732+
SWIFT_VERSION = 4.1;
714733
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator";
715734
};
716735
name = Release;
717736
};
718737
FB465CCC1B9884F400398388 /* Debug */ = {
719738
isa = XCBuildConfiguration;
720739
buildSettings = {
740+
CODE_SIGN_IDENTITY = "";
721741
CURRENT_PROJECT_VERSION = 1;
722742
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
723743
DEFINES_MODULE = YES;
@@ -735,7 +755,7 @@
735755
PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)";
736756
PRODUCT_NAME = "$(TARGET_NAME)";
737757
SKIP_INSTALL = YES;
738-
SWIFT_VERSION = 3.0;
758+
SWIFT_VERSION = 4.0;
739759
TARGETED_DEVICE_FAMILY = "1,2";
740760
VERSIONING_SYSTEM = "apple-generic";
741761
VERSION_INFO_PREFIX = "";
@@ -745,6 +765,7 @@
745765
FB465CCD1B9884F400398388 /* Release */ = {
746766
isa = XCBuildConfiguration;
747767
buildSettings = {
768+
CODE_SIGN_IDENTITY = "";
748769
COPY_PHASE_STRIP = NO;
749770
CURRENT_PROJECT_VERSION = 1;
750771
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@@ -760,7 +781,7 @@
760781
PRODUCT_NAME = "$(TARGET_NAME)";
761782
SKIP_INSTALL = YES;
762783
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
763-
SWIFT_VERSION = 3.0;
784+
SWIFT_VERSION = 4.0;
764785
TARGETED_DEVICE_FAMILY = "1,2";
765786
VERSIONING_SYSTEM = "apple-generic";
766787
VERSION_INFO_PREFIX = "";
@@ -785,7 +806,7 @@
785806
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
786807
PRODUCT_BUNDLE_IDENTIFIER = "com.levous.$(PRODUCT_NAME:rfc1034identifier)";
787808
PRODUCT_NAME = "$(TARGET_NAME)";
788-
SWIFT_VERSION = 3.0;
809+
SWIFT_VERSION = 4.0;
789810
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator";
790811
};
791812
name = Debug;
@@ -806,7 +827,7 @@
806827
PRODUCT_BUNDLE_IDENTIFIER = "com.levous.$(PRODUCT_NAME:rfc1034identifier)";
807828
PRODUCT_NAME = "$(TARGET_NAME)";
808829
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
809-
SWIFT_VERSION = 3.0;
830+
SWIFT_VERSION = 4.0;
810831
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator";
811832
};
812833
name = Release;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0800"
3+
LastUpgradeVersion = "0930"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidatorTests.xcscheme

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0800"
3+
LastUpgradeVersion = "0930"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,8 +26,8 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
shouldUseLaunchSchemeArgsEnv = "YES"
30-
codeCoverageEnabled = "YES">
29+
codeCoverageEnabled = "YES"
30+
shouldUseLaunchSchemeArgsEnv = "YES">
3131
<Testables>
3232
<TestableReference
3333
skipped = "NO">

Validator.xcodeproj/xcshareddata/xcschemes/Validator.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0800"
3+
LastUpgradeVersion = "0930"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Validator/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate
7979
print("Validation FAILED!")
8080
}
8181

82-
func hideKeyboard(){
82+
@objc func hideKeyboard(){
8383
self.view.endEditing(true)
8484
}
8585

0 commit comments

Comments
 (0)