diff --git a/CHANGELOG.md b/CHANGELOG.md index a356e0c..3f84784 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ### Unreleased +### 0.13.2 ++ Fix swift 4 warnings about String.characters + ## 0.13.1 + Swift 4 diff --git a/Example/Tests/StringGherkinExtensionTests.swift b/Example/Tests/StringGherkinExtensionTests.swift index 99c0732..7eecd07 100644 --- a/Example/Tests/StringGherkinExtensionTests.swift +++ b/Example/Tests/StringGherkinExtensionTests.swift @@ -61,5 +61,4 @@ class StringGherkinExtensionTests: XCTestCase { let simpleString = "" XCTAssertEqual("", simpleString.camelCaseify) } - } diff --git a/Pod/Core/StringGherkinExtension.swift b/Pod/Core/StringGherkinExtension.swift index be4bd8b..ee63fc9 100644 --- a/Pod/Core/StringGherkinExtension.swift +++ b/Pod/Core/StringGherkinExtension.swift @@ -18,7 +18,7 @@ public extension String { */ var camelCaseify: String { get { - guard case let characters = (self.characters.split { $0 == " " || $0 == "-" }), characters.count > 1 else { + guard case let characters = (self.split { $0 == " " || $0 == "-" }), characters.count > 1 else { return self.uppercaseFirstLetterString } return characters.map { String($0).lowercased().uppercaseFirstLetterString }.joined(separator: "") @@ -33,8 +33,8 @@ public extension String { */ var uppercaseFirstLetterString: String { get { - guard case let characters = self.characters, let firstCharacter = characters.first else { return self } - return String(firstCharacter).uppercased() + String(characters.dropFirst()) + guard let firstCharacter = self.first else { return self } + return String(firstCharacter).uppercased() + String(self.dropFirst()) } } @@ -45,8 +45,8 @@ public extension String { */ var humanReadableString: String { get { - guard case let characters = self.characters, characters.count > 1, let firstCharacter = characters.first else { return self } - return String(firstCharacter) + characters.dropFirst().reduce("") { (word, character) in + guard self.count > 1, let firstCharacter = self.first else { return self } + return String(firstCharacter) + self.dropFirst().reduce("") { (word, character) in let letter = String(character) if letter == letter.uppercased() { return word + " " + letter diff --git a/Pod/Core/XCTestCase+Gherkin.swift b/Pod/Core/XCTestCase+Gherkin.swift index 527e586..4ced6f0 100644 --- a/Pod/Core/XCTestCase+Gherkin.swift +++ b/Pod/Core/XCTestCase+Gherkin.swift @@ -41,15 +41,14 @@ class GherkinState { fileprivate var missingStepsImplementations = [String]() func gherkinStepsAndMatchesMatchingExpression(_ expression: String) -> [(step: Step, match: NSTextCheckingResult)] { - let range = NSMakeRange(0, expression.characters.count) - let matches = self.steps.map { (step: Step) -> (step: Step, match: NSTextCheckingResult)? in + let range = NSMakeRange(0, expression.count) + return self.steps.flatMap { (step: Step) -> (step: Step, match: NSTextCheckingResult)? in if let match = step.regex.firstMatch(in: expression, options: [], range: range) { return (step:step, match:match) } else { return nil } - }.flatMap { $0 } - return matches + } } func gherkinStepsMatchingExpression(_ expression: String) -> [Step] { diff --git a/Pod/Native/NativeFeature.swift b/Pod/Native/NativeFeature.swift index 20c9746..0c0340b 100644 --- a/Pod/Native/NativeFeature.swift +++ b/Pod/Native/NativeFeature.swift @@ -56,7 +56,7 @@ extension NativeFeature { var lines = contentsFixedWindowsNewLineCharacters.components(separatedBy: "\n").map { $0.trimmingCharacters(in: whitespace) } // Filter comments (#) and tags (@), also filter white lines - lines = lines.filter { $0.characters.first != "#" && $0.characters.first != "@" && $0.characters.count > 0} + lines = lines.filter { $0.first != "#" && $0.first != "@" && $0.count > 0} guard lines.count > 0 else { return nil } diff --git a/XCTest-Gherkin.podspec b/XCTest-Gherkin.podspec index f0a0da6..0e9bacd 100644 --- a/XCTest-Gherkin.podspec +++ b/XCTest-Gherkin.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "XCTest-Gherkin" - s.version = "0.13.1" + s.version = "0.13.2" s.summary = "Gherkin style tests" s.description = <<-DESC Adds Gherkin syntax to XCTestCase