diff --git a/.swift-version b/.swift-version index 06a4457..389f774 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.1 \ No newline at end of file +4.0 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index b38f7fc..d763d13 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -osx_image: xcode8.3 +osx_image: xcode9.1 language: objective-c env: diff --git a/Example/iOS/FormView.swift b/Example/iOS/FormView.swift index 388b139..41bc199 100644 --- a/Example/iOS/FormView.swift +++ b/Example/iOS/FormView.swift @@ -60,8 +60,8 @@ final class FormView: UIView { submitButton.setTitle(NSLocalizedString("Submit", comment: ""), for: UIControlState()) stackView.addArrangedSubview(submitButton) - bottomBufferView.setContentCompressionResistancePriority(UILayoutPriorityDefaultLow, for: stackView.axis) - bottomBufferView.setContentHuggingPriority(UILayoutPriorityDefaultLow, for: stackView.axis) + bottomBufferView.setContentCompressionResistancePriority(UILayoutPriority.defaultLow, for: stackView.axis) + bottomBufferView.setContentHuggingPriority(UILayoutPriority.defaultLow, for: stackView.axis) stackView.addArrangedSubview(bottomBufferView) diff --git a/Example/iOS/FormViewController.swift b/Example/iOS/FormViewController.swift index 808c192..1c6014f 100644 --- a/Example/iOS/FormViewController.swift +++ b/Example/iOS/FormViewController.swift @@ -47,7 +47,7 @@ final class FormViewController: UIViewController { // MARK: - Control Actions - func submitButtonPressed(_ sender: UIButton) { + @objc func submitButtonPressed(_ sender: UIButton) { let alertTitle: String let alertMessage: String if form.isValid { diff --git a/Example/macOS/AppDelegate.swift b/Example/macOS/AppDelegate.swift index 8ccd4eb..b80afc3 100644 --- a/Example/macOS/AppDelegate.swift +++ b/Example/macOS/AppDelegate.swift @@ -17,9 +17,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { lazy var window: NSWindow = { let result = NSWindow(contentRect: NSRect(x: 0, y: 0, - width: NSScreen.main()!.frame.width / 2.0, - height: NSScreen.main()!.frame.height / 2.0), - styleMask: [.titled, .miniaturizable, .resizable, .closable], + width: NSScreen.main!.frame.width / 2.0, + height: NSScreen.main!.frame.height / 2.0), + styleMask: [NSWindow.StyleMask.titled, NSWindow.StyleMask.miniaturizable, NSWindow.StyleMask.resizable, NSWindow.StyleMask.closable], backing: .buffered, defer: false) diff --git a/Example/macOS/FormViewController.swift b/Example/macOS/FormViewController.swift index 2e479a1..11770b5 100644 --- a/Example/macOS/FormViewController.swift +++ b/Example/macOS/FormViewController.swift @@ -49,7 +49,7 @@ final class FormViewController: NSViewController { // MARK: - Control Actions - func submitButtonPressed(_ sender: NSButton) { + @objc func submitButtonPressed(_ sender: NSButton) { let alertMessage: String if form.isValid { alertMessage = NSLocalizedString("Success: Your data has been submitted!", comment: "") @@ -61,7 +61,7 @@ final class FormViewController: NSViewController { alert.alertStyle = .critical alert.messageText = alertMessage - alert.beginSheetModal(for: NSApplication.shared().mainWindow!, completionHandler: nil) + alert.beginSheetModal(for: NSApplication.shared.mainWindow!, completionHandler: nil) } } diff --git a/FormValidatorSwift.xcodeproj/project.pbxproj b/FormValidatorSwift.xcodeproj/project.pbxproj index 39daa61..37b34f3 100644 --- a/FormValidatorSwift.xcodeproj/project.pbxproj +++ b/FormValidatorSwift.xcodeproj/project.pbxproj @@ -817,32 +817,36 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0820; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0910; ORGANIZATIONNAME = ustwo; TargetAttributes = { 0056755E1C47ED32005A43F0 = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0910; }; 005675671C47ED32005A43F0 = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0910; ProvisioningStyle = Manual; }; 0062E9CF1C45493E00021C0A = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0910; }; 0062E9D91C45493E00021C0A = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0910; ProvisioningStyle = Manual; }; 00AC81E71E1FB69200A184BB = { CreatedOnToolsVersion = 8.2.1; + LastSwiftMigration = 0910; ProvisioningStyle = Manual; }; 00AC81EF1E1FB69200A184BB = { CreatedOnToolsVersion = 8.2.1; DevelopmentTeam = 4JC5M8RR29; + LastSwiftMigration = 0910; ProvisioningStyle = Automatic; }; }; @@ -1311,7 +1315,7 @@ PRODUCT_NAME = FormValidatorSwift; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1334,7 +1338,7 @@ PRODUCT_NAME = FormValidatorSwift; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1349,6 +1353,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.ustwo.FormValidatorSwiftTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; + SWIFT_VERSION = 4.0; TVOS_DEPLOYMENT_TARGET = 9.1; }; name = Debug; @@ -1362,6 +1367,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.ustwo.FormValidatorSwiftTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; + SWIFT_VERSION = 4.0; TVOS_DEPLOYMENT_TARGET = 9.1; }; name = Release; @@ -1375,14 +1381,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -1428,14 +1440,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -1484,7 +1502,7 @@ PRODUCT_NAME = FormValidatorSwift; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1505,7 +1523,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.ustwo.FormValidatorSwift; PRODUCT_NAME = FormValidatorSwift; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -1517,7 +1535,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.ustwo.FormValidatorSwiftTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1529,7 +1547,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.ustwo.FormValidatorSwiftTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -1556,7 +1574,7 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1582,7 +1600,7 @@ PRODUCT_NAME = FormValidatorSwift; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -1602,7 +1620,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1621,7 +1639,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.ustwo.FormValidatorSwiftTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/FormValidatorSwift.xcodeproj/xcshareddata/xcschemes/FormValidatorSwift iOS.xcscheme b/FormValidatorSwift.xcodeproj/xcshareddata/xcschemes/FormValidatorSwift iOS.xcscheme index 64956be..ce696b2 100644 --- a/FormValidatorSwift.xcodeproj/xcshareddata/xcschemes/FormValidatorSwift iOS.xcscheme +++ b/FormValidatorSwift.xcodeproj/xcshareddata/xcschemes/FormValidatorSwift iOS.xcscheme @@ -1,6 +1,6 @@ @@ -56,6 +57,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/FormValidatorSwift.xcodeproj/xcshareddata/xcschemes/FormValidatorSwift macOS.xcscheme b/FormValidatorSwift.xcodeproj/xcshareddata/xcschemes/FormValidatorSwift macOS.xcscheme index 29b3916..f7f762b 100644 --- a/FormValidatorSwift.xcodeproj/xcshareddata/xcschemes/FormValidatorSwift macOS.xcscheme +++ b/FormValidatorSwift.xcodeproj/xcshareddata/xcschemes/FormValidatorSwift macOS.xcscheme @@ -1,6 +1,6 @@ @@ -56,6 +57,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/FormValidatorSwift.xcodeproj/xcshareddata/xcschemes/FormValidatorSwift tvOS.xcscheme b/FormValidatorSwift.xcodeproj/xcshareddata/xcschemes/FormValidatorSwift tvOS.xcscheme index b17daec..e689da6 100644 --- a/FormValidatorSwift.xcodeproj/xcshareddata/xcschemes/FormValidatorSwift tvOS.xcscheme +++ b/FormValidatorSwift.xcodeproj/xcshareddata/xcschemes/FormValidatorSwift tvOS.xcscheme @@ -1,6 +1,6 @@ 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.5.1) - public_suffix (~> 2.0, >= 2.0.2) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) babosa (1.0.2) - claide (1.0.1) + claide (1.0.2) cocoapods (1.2.1) activesupport (>= 4.0.2, < 5) claide (>= 1.0.1, < 2.0) @@ -40,42 +40,45 @@ GEM nap cocoapods-search (1.0.0) cocoapods-stats (1.0.0) - cocoapods-trunk (1.2.0) + cocoapods-trunk (1.3.0) nap (>= 0.8, < 2.0) - netrc (= 0.7.8) + netrc (~> 0.11) cocoapods-try (1.1.0) colored (1.2) colored2 (3.1.2) - commander-fastlane (4.4.4) + commander-fastlane (4.4.5) highline (~> 1.7.2) + concurrent-ruby (1.0.5) + declarative (0.0.10) + declarative-option (0.1.0) domain_name (0.5.20170404) unf (>= 0.0.5, < 1.0.0) dotenv (2.2.1) escape (0.0.4) - excon (0.56.0) - faraday (0.12.1) + excon (0.59.0) + faraday (0.13.1) multipart-post (>= 1.2, < 3) faraday-cookie_jar (0.0.6) faraday (>= 0.7.4) http-cookie (~> 1.0.0) - faraday_middleware (0.11.0.1) + faraday_middleware (0.12.2) faraday (>= 0.7.4, < 1.0) fastimage (2.1.0) - fastlane (2.37.0) + fastlane (2.64.1) CFPropertyList (>= 2.3, < 3.0.0) addressable (>= 2.3, < 3.0.0) babosa (>= 1.0.2, < 2.0.0) bundler (>= 1.12.0, < 2.0.0) colored - commander-fastlane (>= 4.4.0, < 5.0.0) + commander-fastlane (>= 4.4.5, < 5.0.0) dotenv (>= 2.1.1, < 3.0.0) excon (>= 0.45.0, < 1.0.0) faraday (~> 0.9) faraday-cookie_jar (~> 0.0.6) faraday_middleware (~> 0.9) - fastimage (>= 1.6) + fastimage (>= 2.1.0, < 3.0.0) gh_inspector (>= 1.0.1, < 2.0.0) - google-api-client (~> 0.9.2) + google-api-client (>= 0.13.1, < 0.14.0) highline (>= 1.7.2, < 2.0.0) json (< 3.0.0) mini_magick (~> 4.5.1) @@ -83,6 +86,7 @@ GEM multi_xml (~> 0.5) multipart-post (~> 2.0.0) plist (>= 3.1.0, < 4.0.0) + public_suffix (~> 2.0.0) rubyzip (>= 1.1.0, < 2.0.0) security (= 0.1.3) slack-notifier (>= 1.3, < 2.0.0) @@ -90,25 +94,24 @@ GEM terminal-table (>= 1.4.5, < 2.0.0) tty-screen (~> 0.5.0) word_wrap (~> 1.0.0) - xcodeproj (>= 1.4.4, < 2.0.0) + xcodeproj (>= 1.5.2, < 2.0.0) xcpretty (>= 0.2.4, < 1.0.0) xcpretty-travis-formatter (>= 0.0.3) - fastlane-plugin-versioning (0.2.6) + fastlane-plugin-versioning (0.3.1) + ffi (1.9.18) fourflusher (2.0.1) fuzzy_match (2.0.4) gh_inspector (1.0.3) - google-api-client (0.9.28) - addressable (~> 2.3) + google-api-client (0.13.6) + addressable (~> 2.5, >= 2.5.1) googleauth (~> 0.5) - httpclient (~> 2.7) - hurley (~> 0.1) - memoist (~> 0.11) - mime-types (>= 1.6) - representable (~> 2.3.0) - retriable (~> 2.0) - googleauth (0.5.1) - faraday (~> 0.9) - jwt (~> 1.4) + httpclient (>= 2.8.1, < 3.0) + mime-types (~> 3.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.0) + googleauth (0.6.2) + faraday (~> 0.12) + jwt (>= 1.4, < 3.0) logging (~> 2.0) memoist (~> 0.12) multi_json (~> 1.11) @@ -118,8 +121,8 @@ GEM http-cookie (1.0.3) domain_name (~> 0.5) httpclient (2.8.3) - hurley (0.2) - i18n (0.8.4) + i18n (0.9.1) + concurrent-ruby (~> 1.0) jazzy (0.0.14) activesupport (~> 4.1) mustache (~> 0.99) @@ -127,67 +130,76 @@ GEM redcarpet (~> 3.2) sass (~> 3.4) json (2.1.0) - jwt (1.5.6) + jwt (2.1.0) little-plugger (1.1.4) logging (2.2.2) little-plugger (~> 1.1) multi_json (~> 1.10) - memoist (0.15.0) + memoist (0.16.0) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mini_magick (4.5.1) - mini_portile2 (2.2.0) - minitest (5.10.2) + mini_portile2 (2.3.0) + minitest (5.10.3) molinillo (0.5.7) - multi_json (1.12.1) + multi_json (1.12.2) multi_xml (0.6.0) multipart-post (2.0.0) mustache (0.99.8) nanaimo (0.2.3) nap (1.1.0) - netrc (0.7.8) - nokogiri (1.8.0) - mini_portile2 (~> 2.2.0) + netrc (0.11.0) + nokogiri (1.8.1) + mini_portile2 (~> 2.3.0) os (0.9.6) plist (3.3.0) public_suffix (2.0.5) + rb-fsevent (0.10.2) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) redcarpet (3.4.0) - representable (2.3.0) - uber (~> 0.0.7) - retriable (2.1.0) + representable (3.0.4) + declarative (< 0.1.0) + declarative-option (< 0.2.0) + uber (< 0.2.0) + retriable (3.1.1) rouge (2.0.7) ruby-macho (1.1.0) rubyzip (1.2.1) - sass (3.4.24) + sass (3.5.3) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) security (0.1.3) - signet (0.7.3) + signet (0.8.1) addressable (~> 2.3) faraday (~> 0.9) - jwt (~> 1.5) + jwt (>= 1.5, < 3.0) multi_json (~> 1.10) slack-notifier (1.5.1) terminal-notifier (1.8.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) thread_safe (0.3.6) - tty-screen (0.5.0) - tzinfo (1.2.3) + tty-screen (0.5.1) + tzinfo (1.2.4) thread_safe (~> 0.1) - uber (0.0.15) + uber (0.1.0) unf (0.1.4) unf_ext unf_ext (0.0.7.4) - unicode-display_width (1.2.1) + unicode-display_width (1.3.0) word_wrap (1.0.0) - xcodeproj (1.4.4) + xcodeproj (1.5.3) CFPropertyList (~> 2.3.3) - claide (>= 1.0.1, < 2.0) + claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) nanaimo (~> 0.2.3) xcpretty (0.2.8) rouge (~> 2.0.7) - xcpretty-travis-formatter (0.0.4) + xcpretty-travis-formatter (1.0.0) xcpretty (~> 0.2, >= 0.0.7) PLATFORMS @@ -200,4 +212,4 @@ DEPENDENCIES jazzy BUNDLED WITH - 1.14.5 + 1.15.4 diff --git a/Sources/Conditions/AlphabeticCondition.swift b/Sources/Conditions/AlphabeticCondition.swift index 5386a77..adc5795 100644 --- a/Sources/Conditions/AlphabeticCondition.swift +++ b/Sources/Conditions/AlphabeticCondition.swift @@ -48,7 +48,7 @@ public struct AlphabeticCondition: ConfigurableCondition { return false } - return regExpression.numberOfMatches(in: sourceText, options: [], range: NSRange(location: 0, length: sourceText.characters.count)) == sourceText.characters.count + return regExpression.numberOfMatches(in: sourceText, options: [], range: NSRange(location: 0, length: sourceText.count)) == sourceText.count } } diff --git a/Sources/Conditions/AlphanumericCondition.swift b/Sources/Conditions/AlphanumericCondition.swift index 831faf3..d39a775 100644 --- a/Sources/Conditions/AlphanumericCondition.swift +++ b/Sources/Conditions/AlphanumericCondition.swift @@ -48,7 +48,7 @@ public struct AlphanumericCondition: ConfigurableCondition { return false } - return regExpression.numberOfMatches(in: sourceText, options: [], range: NSRange(location: 0, length: sourceText.characters.count)) == sourceText.characters.count + return regExpression.numberOfMatches(in: sourceText, options: [], range: NSRange(location: 0, length: sourceText.count)) == sourceText.count } } diff --git a/Sources/Conditions/CreditCardCondition.swift b/Sources/Conditions/CreditCardCondition.swift index 5fa9512..82845af 100644 --- a/Sources/Conditions/CreditCardCondition.swift +++ b/Sources/Conditions/CreditCardCondition.swift @@ -46,12 +46,12 @@ public struct CreditCardCondition: ConfigurableCondition { } let sourceTextNs = sourceText as NSString - let trimmedText = sourceTextNs.replacingOccurrences(of: "\\D", with: "", options: .regularExpression, range: NSRange(location:0, length:sourceTextNs.length)) as String + let trimmedText = sourceTextNs.replacingOccurrences(of: "\\D", with: "", options: .regularExpression, range: NSRange(location: 0, length: sourceTextNs.length)) as String return check(trimmedText, withRegex: regExp) } public func check(_ trimmedText: String, withRegex regExp: NSRegularExpression) -> Bool { - return regExp.firstMatch(in: trimmedText, options: [], range: NSRange(location:0, length:trimmedText.characters.count)) != nil + return regExp.firstMatch(in: trimmedText, options: [], range: NSRange(location: 0, length: trimmedText.count)) != nil } } diff --git a/Sources/Conditions/NumericCondition.swift b/Sources/Conditions/NumericCondition.swift index eb0c71d..309173d 100644 --- a/Sources/Conditions/NumericCondition.swift +++ b/Sources/Conditions/NumericCondition.swift @@ -48,7 +48,7 @@ public struct NumericCondition: ConfigurableCondition { return false } - return regExpression.numberOfMatches(in: sourceText, options: [], range: NSRange(location: 0, length: sourceText.characters.count)) == sourceText.characters.count + return regExpression.numberOfMatches(in: sourceText, options: [], range: NSRange(location: 0, length: sourceText.count)) == sourceText.count } } diff --git a/Sources/Conditions/PasswordStrengthCondition.swift b/Sources/Conditions/PasswordStrengthCondition.swift index a631d14..f713ea4 100644 --- a/Sources/Conditions/PasswordStrengthCondition.swift +++ b/Sources/Conditions/PasswordStrengthCondition.swift @@ -54,7 +54,7 @@ public struct PasswordStrengthCondition: ConfigurableCondition { var strength = matches.reduce(0, { $0 + ($1 > 0 ? 1 : 0) }) - if sourceText.characters.count > 8 { + if sourceText.count > 8 { strength += 1 } else { strength -= 1 @@ -68,7 +68,7 @@ public struct PasswordStrengthCondition: ConfigurableCondition { return 0 } - return regExpression.numberOfMatches(in: text, options: [], range: NSRange(location: 0, length: text.characters.count)) + return regExpression.numberOfMatches(in: text, options: [], range: NSRange(location: 0, length: text.count)) } } diff --git a/Sources/Conditions/RangeCondition.swift b/Sources/Conditions/RangeCondition.swift index 9210c80..f93ff3b 100644 --- a/Sources/Conditions/RangeCondition.swift +++ b/Sources/Conditions/RangeCondition.swift @@ -40,8 +40,8 @@ public struct RangeCondition: ConfigurableCondition { return false } - return sourceText.characters.count >= configuration.range.lowerBound && - sourceText.characters.count <= configuration.range.lowerBound.distance(to: configuration.range.upperBound) + return sourceText.count >= configuration.range.lowerBound && + sourceText.count <= configuration.range.lowerBound.distance(to: configuration.range.upperBound) } } diff --git a/Sources/Configurations/CreditCardConfiguration.swift b/Sources/Configurations/CreditCardConfiguration.swift index d00aa1a..59988c9 100644 --- a/Sources/Configurations/CreditCardConfiguration.swift +++ b/Sources/Configurations/CreditCardConfiguration.swift @@ -17,16 +17,16 @@ public struct CreditCardType: OptionSet, CustomStringConvertible { self.rawValue = rawValue } - static let americanExpress = CreditCardType(rawValue: 1 << 0) - static let dinersClub = CreditCardType(rawValue: 1 << 1) - static let discover = CreditCardType(rawValue: 1 << 2) - static let jcb = CreditCardType(rawValue: 1 << 3) - static let maestro = CreditCardType(rawValue: 1 << 4) - static let mastercard = CreditCardType(rawValue: 1 << 5) - static let visa = CreditCardType(rawValue: 1 << 6) - - static let all: CreditCardType = [.americanExpress, .dinersClub, .discover, .jcb, .maestro, .mastercard, .visa] - static let allArray: [CreditCardType] = [.americanExpress, .dinersClub, .discover, .jcb, .maestro, .mastercard, .visa] + public static let americanExpress = CreditCardType(rawValue: 1 << 0) + public static let dinersClub = CreditCardType(rawValue: 1 << 1) + public static let discover = CreditCardType(rawValue: 1 << 2) + public static let jcb = CreditCardType(rawValue: 1 << 3) + public static let maestro = CreditCardType(rawValue: 1 << 4) + public static let mastercard = CreditCardType(rawValue: 1 << 5) + public static let visa = CreditCardType(rawValue: 1 << 6) + + public static let all: CreditCardType = [.americanExpress, .dinersClub, .discover, .jcb, .maestro, .mastercard, .visa] + public static let allArray: [CreditCardType] = [.americanExpress, .dinersClub, .discover, .jcb, .maestro, .mastercard, .visa] /** Literal description for set of credit cards, separated with commas and single space. diff --git a/Sources/Controls/ValidatorTextField-AppKit.swift b/Sources/Controls/ValidatorTextField-AppKit.swift index 692955c..d91169b 100644 --- a/Sources/Controls/ValidatorTextField-AppKit.swift +++ b/Sources/Controls/ValidatorTextField-AppKit.swift @@ -55,10 +55,10 @@ open class ValidatorTextField: NSTextField, ValidatorControl { } NotificationCenter.default.removeObserver(responder, - name: NSNotification.Name.NSControlTextDidChange, + name: NSControl.textDidChangeNotification, object: self) NotificationCenter.default.removeObserver(responder, - name: NSNotification.Name.NSControlTextDidEndEditing, + name: NSControl.textDidEndEditingNotification, object: self) } @@ -71,11 +71,11 @@ open class ValidatorTextField: NSTextField, ValidatorControl { NotificationCenter.default.addObserver(responder, selector: #selector(ValidatorTextFieldResponder.textFieldDidChange(_:)), - name: NSNotification.Name.NSControlTextDidChange, + name: NSControl.textDidChangeNotification, object: self) NotificationCenter.default.addObserver(responder, selector: #selector(ValidatorTextFieldResponder.textFieldDidEndEditing(_:)), - name: NSNotification.Name.NSControlTextDidEndEditing, + name: NSControl.textDidEndEditingNotification, object: self) } @@ -125,7 +125,7 @@ internal class ValidatorTextFieldResponder: NSObject { // MARK: - Notifications - func textFieldDidChange(_ notification: Notification?) { + @objc func textFieldDidChange(_ notification: Notification?) { defer { // Inform delegate about changes delegate?.validatorControlDidChange(validatorTextField) @@ -162,7 +162,7 @@ internal class ValidatorTextFieldResponder: NSObject { } } - func textFieldDidEndEditing(_ notification: Notification?) { + @objc func textFieldDidEndEditing(_ notification: Notification?) { didEndEditing = true textFieldDidChange(nil) diff --git a/Sources/Controls/ValidatorTextField-UIKit.swift b/Sources/Controls/ValidatorTextField-UIKit.swift index 1685a20..6785670 100644 --- a/Sources/Controls/ValidatorTextField-UIKit.swift +++ b/Sources/Controls/ValidatorTextField-UIKit.swift @@ -120,7 +120,7 @@ internal class ValidatorTextFieldResponder: NSObject, UITextFieldDelegate { // MARK: - Notifications - func textFieldDidChange(_ notification: Notification?) { + @objc func textFieldDidChange(_ notification: Notification?) { defer { // Inform delegate about changes delegate?.validatorControlDidChange(validatorTextField) diff --git a/Sources/Protocols/Condition.swift b/Sources/Protocols/Condition.swift index 5114666..d387674 100644 --- a/Sources/Protocols/Condition.swift +++ b/Sources/Protocols/Condition.swift @@ -54,7 +54,7 @@ public extension Condition { return false } - return regExpression.firstMatch(in: sourceText, options: [], range: NSRange(location: 0, length: sourceText.characters.count)) != nil + return regExpression.firstMatch(in: sourceText, options: [], range: NSRange(location: 0, length: sourceText.count)) != nil } } diff --git a/Sources/Validators/CreditCardValidator.swift b/Sources/Validators/CreditCardValidator.swift index 1d2450d..0f37708 100644 --- a/Sources/Validators/CreditCardValidator.swift +++ b/Sources/Validators/CreditCardValidator.swift @@ -48,7 +48,7 @@ public struct CreditCardValidator: ConfigurableValidator { } let creditCardCondition = CreditCardCondition() - let trimmedCardNumber = String(creditCardNumber.characters.filter { $0 != " " }) + let trimmedCardNumber = String(creditCardNumber.filter { $0 != " " }) for cardType in CreditCardType.allArray { if let regex = try? NSRegularExpression(pattern: cardType.regex, options: .caseInsensitive), diff --git a/Tests/Unit Tests/Extensions/XCTestCase+Additions.swift b/Tests/Unit Tests/Extensions/XCTestCase+Additions.swift index 235f87a..f5308df 100644 --- a/Tests/Unit Tests/Extensions/XCTestCase+Additions.swift +++ b/Tests/Unit Tests/Extensions/XCTestCase+Additions.swift @@ -21,7 +21,12 @@ extension XCTestCase { // Test if expectedResult != actualResult { let message = "The `\(type(of: condition))` should respond with \(expectedResult) but received \(actualResult)." - self.recordFailure(withDescription: message, inFile: file, atLine: line, expected: true) + + #if os(iOS) || os(macOS) + self.recordFailure(withDescription: message, inFile: file, atLine: Int(line), expected: true) + #elseif os(tvOS) + self.recordFailure(withDescription: message, inFile: file, atLine: Int(line), expected: true) + #endif } } @@ -52,7 +57,12 @@ extension XCTestCase { } let message = "The `\(type(of: validator))` should respond with \(expectedResult.debugDescription) and but received \(actualResult.debugDescription)." - self.recordFailure(withDescription: message, inFile: file, atLine: line, expected: true) + + #if os(iOS) || os(macOS) + self.recordFailure(withDescription: message, inFile: file, atLine: Int(line), expected: true) + #elseif os(tvOS) + self.recordFailure(withDescription: message, inFile: file, atLine: Int(line), expected: true) + #endif } } diff --git a/fastlane/README.md b/fastlane/README.md index 9c584b4..ba455b0 100644 --- a/fastlane/README.md +++ b/fastlane/README.md @@ -12,9 +12,9 @@ xcode-select --install - + + diff --git a/iOS Example.xcodeproj/project.pbxproj b/iOS Example.xcodeproj/project.pbxproj index 5631cc3..890fde6 100644 --- a/iOS Example.xcodeproj/project.pbxproj +++ b/iOS Example.xcodeproj/project.pbxproj @@ -242,16 +242,16 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0910; ORGANIZATIONNAME = ustwo; TargetAttributes = { 003698401C4788B1004D1692 = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0910; }; 003698541C4788B1004D1692 = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0910; TestTargetID = 003698401C4788B1004D1692; }; }; @@ -407,14 +407,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -455,14 +461,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -501,7 +513,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.ustwo.iOS-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -516,7 +528,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.ustwo.iOS-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -529,7 +541,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.ustwo.iOS-ExampleUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TEST_TARGET_NAME = "iOS Example"; USES_XCTRUNNER = YES; }; @@ -543,7 +555,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.ustwo.iOS-ExampleUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TEST_TARGET_NAME = "iOS Example"; USES_XCTRUNNER = YES; }; diff --git a/iOS Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme b/iOS Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme index c71eef9..8ba5450 100644 --- a/iOS Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme +++ b/iOS Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme @@ -1,6 +1,6 @@ @@ -56,6 +57,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/macOS Example.xcodeproj/project.pbxproj b/macOS Example.xcodeproj/project.pbxproj index c510517..6d656a6 100644 --- a/macOS Example.xcodeproj/project.pbxproj +++ b/macOS Example.xcodeproj/project.pbxproj @@ -242,19 +242,19 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0820; - LastUpgradeCheck = 0820; + LastUpgradeCheck = 0910; ORGANIZATIONNAME = "Ustwo Fampany Ltd."; TargetAttributes = { 007244721E1FDB2D0050DFE9 = { CreatedOnToolsVersion = 8.2.1; DevelopmentTeam = 4JC5M8RR29; - LastSwiftMigration = 0820; + LastSwiftMigration = 0910; ProvisioningStyle = Automatic; }; 007244811E1FDB2D0050DFE9 = { CreatedOnToolsVersion = 8.2.1; DevelopmentTeam = 4JC5M8RR29; - LastSwiftMigration = 0820; + LastSwiftMigration = 0910; ProvisioningStyle = Automatic; TestTargetID = 007244721E1FDB2D0050DFE9; }; @@ -413,7 +413,9 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; @@ -421,7 +423,11 @@ 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -462,7 +468,9 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; @@ -470,7 +478,11 @@ 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -507,7 +519,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.ustwo.macOS-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -523,7 +535,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.ustwo.macOS-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -539,7 +551,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.ustwo.macOS-ExampleUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TEST_TARGET_NAME = "macOS Example"; }; name = Debug; @@ -555,7 +567,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.ustwo.macOS-ExampleUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TEST_TARGET_NAME = "macOS Example"; }; name = Release; diff --git a/macOS Example.xcodeproj/xcshareddata/xcschemes/macOS Example.xcscheme b/macOS Example.xcodeproj/xcshareddata/xcschemes/macOS Example.xcscheme index 4a70538..4833d13 100644 --- a/macOS Example.xcodeproj/xcshareddata/xcschemes/macOS Example.xcscheme +++ b/macOS Example.xcodeproj/xcshareddata/xcschemes/macOS Example.xcscheme @@ -1,6 +1,6 @@ @@ -56,6 +57,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO"
Homebrew -Installer Script -Rubygems +HomebrewInstaller ScriptRubyGems
macOS