Skip to content

Commit 03e27a1

Browse files
authored
Update to Swift 4.2 and v0.3.0 (#16)
* Update to Swift 4.2 * Update travis.yml
1 parent c144fdc commit 03e27a1

File tree

14 files changed

+97
-57
lines changed

14 files changed

+97
-57
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
language: objective-c
2-
osx_image: xcode8.1
1+
language: swift
2+
osx_image: xcode10
33

44
script:
55
- cd Example/
66
- pod install
77
- cd ..
8-
- xcodebuild -scheme Analysis_Tests -workspace Example/Analysis.xcworkspace -configuration Debug build test -destination "platform=iOS Simulator,name=iPhone 6"
8+
- xcodebuild clean test -scheme Analysis_Tests -workspace Example/Analysis.xcworkspace -destination "platform=iOS Simulator,name=iPhone X,OS=12.0"

Analysis.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Analysis"
3-
s.version = "0.2.0"
3+
s.version = "0.3.0"
44
s.summary = "Analyse your strings."
55

66
s.description = <<-DESC

Analysis/Classes/Analysis.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ public struct Analysis {
3131
.replacingOccurrences(of: ". ", with: ".\n")
3232
.replacingOccurrences(of: "? ", with: "?\n").lines
3333
.filter { !$0.trimmingCharacters(in: .whitespaces).isEmpty }
34-
words = input.characters
34+
words = input
3535
.split(separator: " ")
36-
.map(String.init)
3736
.map { $0.trimmingCharacters(in: CharacterSet.letters.inverted) }
38-
characters = Array(input.characters)
37+
characters = Array(input)
3938
}
4039

4140
/// Returns the sentence count of the `input`.
@@ -180,10 +179,10 @@ public struct Analysis {
180179
public func averageCharacters(per option: LengthOption) -> Double {
181180
switch option {
182181
case .word:
183-
return Double(words.reduce("", +).characters.count) / Double(wordCount())
182+
return Double(words.reduce("", +).count) / Double(wordCount())
184183
case .sentence:
185184
if sentences.count > 1 {
186-
return Double(sentences.reduce("", +).characters.count) / Double(sentenceCount())
185+
return Double(sentences.reduce("", +).count) / Double(sentenceCount())
187186
} else {
188187
return Double(characterCount(includingSpaces: true)) / Double(sentenceCount())
189188
}

Analysis/Classes/Dictionary+Sorting.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ extension Dictionary where Key: Comparable, Value: Comparable {
2525
case .key:
2626
switch direction {
2727
case .ascending:
28-
return sorted { $0.0.key < $0.1.key }
28+
return sorted { $0.key < $1.key }
2929
case .descending:
30-
return sorted { $0.0.key > $0.1.key }
30+
return sorted { $0.key > $1.key }
3131
}
3232
case .value:
3333
switch direction {
3434
case .ascending:
35-
return sorted { $0.0.value < $0.1.value }
35+
return sorted { $0.value < $1.value }
3636
case .descending:
37-
return sorted { $0.0.value > $0.1.value }
37+
return sorted { $0.value > $1.value }
3838
}
3939
}
4040
}

Analysis/Classes/SyllableCounter.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ public class SyllableCounter {
152152
// MARK: - Public methods
153153

154154
internal func count(word: String) -> Int {
155-
if word.characters.count <= 1 {
156-
return word.characters.count
155+
if word.count <= 1 {
156+
return word.count
157157
}
158158

159159
var mutatedWord = word.lowercased(with: Locale(identifier: "en_US")).trimmingCharacters(in: .punctuationCharacters)
@@ -162,14 +162,14 @@ public class SyllableCounter {
162162
return exceptionValue
163163
}
164164

165-
if mutatedWord.characters.last == "e" {
166-
mutatedWord = String(mutatedWord.characters.dropLast())
165+
if mutatedWord.last == "e" {
166+
mutatedWord = String(mutatedWord.dropLast())
167167
}
168168

169169
var count = 0
170170
var previousIsVowel = false
171171

172-
for character in mutatedWord.characters {
172+
for character in mutatedWord {
173173
let isVowel = vowels.contains(character)
174174
if isVowel && !previousIsVowel {
175175
count += 1
@@ -178,14 +178,14 @@ public class SyllableCounter {
178178
}
179179

180180
for pattern in addSyllables {
181-
let matches = pattern.matches(in: mutatedWord, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSRange(location: 0, length: mutatedWord.characters.count))
181+
let matches = pattern.matches(in: mutatedWord, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSRange(location: 0, length: mutatedWord.count))
182182
if !matches.isEmpty {
183183
count += 1
184184
}
185185
}
186186

187187
for pattern in subSyllables {
188-
let matches = pattern.matches(in: mutatedWord, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSRange(location: 0, length: mutatedWord.characters.count))
188+
let matches = pattern.matches(in: mutatedWord, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSRange(location: 0, length: mutatedWord.count))
189189
if !matches.isEmpty {
190190
count -= 1
191191
}

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# next
22

3+
# [0.3.0](https://github.com/BasThomas/Analysis/releases/tag/0.3.0)
4+
5+
- Updated to Swift 4.2.
6+
37
# [0.2.0](https://github.com/BasThomas/Analysis/releases/tag/0.2.0)
48

59
- Added `syllableCount()`, which counts the total amount of syllables of the `input`.

Example/Analysis.xcodeproj/project.pbxproj

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,16 @@
222222
isa = PBXProject;
223223
attributes = {
224224
LastSwiftUpdateCheck = 0720;
225-
LastUpgradeCheck = 0810;
225+
LastUpgradeCheck = 1000;
226226
ORGANIZATIONNAME = "Bas Broek";
227227
TargetAttributes = {
228228
607FACCF1AFB9204008FA782 = {
229229
CreatedOnToolsVersion = 6.3.1;
230-
LastSwiftMigration = 0810;
230+
LastSwiftMigration = 1000;
231231
};
232232
607FACE41AFB9204008FA782 = {
233233
CreatedOnToolsVersion = 6.3.1;
234-
LastSwiftMigration = 0810;
234+
LastSwiftMigration = 1000;
235235
TestTargetID = 607FACCF1AFB9204008FA782;
236236
};
237237
};
@@ -298,13 +298,16 @@
298298
files = (
299299
);
300300
inputPaths = (
301+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
302+
"${PODS_ROOT}/Manifest.lock",
301303
);
302304
name = "[CP] Check Pods Manifest.lock";
303305
outputPaths = (
306+
"$(DERIVED_FILE_DIR)/Pods-Analysis_Example-checkManifestLockResult.txt",
304307
);
305308
runOnlyForDeploymentPostprocessing = 0;
306309
shellPath = /bin/sh;
307-
shellScript = "diff \"${PODS_ROOT}/../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";
310+
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";
308311
showEnvVarsInLog = 0;
309312
};
310313
9720F7DDF7A6499D6392BC2D /* [CP] Check Pods Manifest.lock */ = {
@@ -313,13 +316,16 @@
313316
files = (
314317
);
315318
inputPaths = (
319+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
320+
"${PODS_ROOT}/Manifest.lock",
316321
);
317322
name = "[CP] Check Pods Manifest.lock";
318323
outputPaths = (
324+
"$(DERIVED_FILE_DIR)/Pods-Analysis_Tests-checkManifestLockResult.txt",
319325
);
320326
runOnlyForDeploymentPostprocessing = 0;
321327
shellPath = /bin/sh;
322-
shellScript = "diff \"${PODS_ROOT}/../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";
328+
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";
323329
showEnvVarsInLog = 0;
324330
};
325331
B726F347928269BC02F4A2CC /* [CP] Embed Pods Frameworks */ = {
@@ -328,9 +334,12 @@
328334
files = (
329335
);
330336
inputPaths = (
337+
"${SRCROOT}/Pods/Target Support Files/Pods-Analysis_Example/Pods-Analysis_Example-frameworks.sh",
338+
"${BUILT_PRODUCTS_DIR}/Analysis/Analysis.framework",
331339
);
332340
name = "[CP] Embed Pods Frameworks";
333341
outputPaths = (
342+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Analysis.framework",
334343
);
335344
runOnlyForDeploymentPostprocessing = 0;
336345
shellPath = /bin/sh;
@@ -428,14 +437,22 @@
428437
CLANG_CXX_LIBRARY = "libc++";
429438
CLANG_ENABLE_MODULES = YES;
430439
CLANG_ENABLE_OBJC_ARC = YES;
440+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
431441
CLANG_WARN_BOOL_CONVERSION = YES;
442+
CLANG_WARN_COMMA = YES;
432443
CLANG_WARN_CONSTANT_CONVERSION = YES;
444+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
433445
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
434446
CLANG_WARN_EMPTY_BODY = YES;
435447
CLANG_WARN_ENUM_CONVERSION = YES;
436448
CLANG_WARN_INFINITE_RECURSION = YES;
437449
CLANG_WARN_INT_CONVERSION = YES;
450+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
451+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
452+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
438453
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
454+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
455+
CLANG_WARN_STRICT_PROTOTYPES = YES;
439456
CLANG_WARN_SUSPICIOUS_MOVE = YES;
440457
CLANG_WARN_UNREACHABLE_CODE = YES;
441458
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -475,14 +492,22 @@
475492
CLANG_CXX_LIBRARY = "libc++";
476493
CLANG_ENABLE_MODULES = YES;
477494
CLANG_ENABLE_OBJC_ARC = YES;
495+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
478496
CLANG_WARN_BOOL_CONVERSION = YES;
497+
CLANG_WARN_COMMA = YES;
479498
CLANG_WARN_CONSTANT_CONVERSION = YES;
499+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
480500
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
481501
CLANG_WARN_EMPTY_BODY = YES;
482502
CLANG_WARN_ENUM_CONVERSION = YES;
483503
CLANG_WARN_INFINITE_RECURSION = YES;
484504
CLANG_WARN_INT_CONVERSION = YES;
505+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
506+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
507+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
485508
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
509+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
510+
CLANG_WARN_STRICT_PROTOTYPES = YES;
486511
CLANG_WARN_SUSPICIOUS_MOVE = YES;
487512
CLANG_WARN_UNREACHABLE_CODE = YES;
488513
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -518,7 +543,8 @@
518543
MODULE_NAME = ExampleApp;
519544
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
520545
PRODUCT_NAME = "$(TARGET_NAME)";
521-
SWIFT_VERSION = 3.0;
546+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
547+
SWIFT_VERSION = 4.2;
522548
};
523549
name = Debug;
524550
};
@@ -533,7 +559,8 @@
533559
MODULE_NAME = ExampleApp;
534560
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
535561
PRODUCT_NAME = "$(TARGET_NAME)";
536-
SWIFT_VERSION = 3.0;
562+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
563+
SWIFT_VERSION = 4.2;
537564
};
538565
name = Release;
539566
};
@@ -553,7 +580,8 @@
553580
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
554581
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
555582
PRODUCT_NAME = "$(TARGET_NAME)";
556-
SWIFT_VERSION = 3.0;
583+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
584+
SWIFT_VERSION = 4.2;
557585
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Analysis_Example.app/Analysis_Example";
558586
};
559587
name = Debug;
@@ -570,7 +598,8 @@
570598
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
571599
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
572600
PRODUCT_NAME = "$(TARGET_NAME)";
573-
SWIFT_VERSION = 3.0;
601+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
602+
SWIFT_VERSION = 4.2;
574603
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Analysis_Example.app/Analysis_Example";
575604
};
576605
name = Release;

Example/Analysis.xcodeproj/xcshareddata/xcschemes/Analysis-Example.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 = "0810"
3+
LastUpgradeVersion = "1000"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -40,8 +40,8 @@
4040
buildConfiguration = "Debug"
4141
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4242
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43-
shouldUseLaunchSchemeArgsEnv = "YES"
44-
codeCoverageEnabled = "YES">
43+
codeCoverageEnabled = "YES"
44+
shouldUseLaunchSchemeArgsEnv = "YES">
4545
<Testables>
4646
<TestableReference
4747
skipped = "NO">

Example/Analysis.xcodeproj/xcshareddata/xcschemes/Analysis_Tests.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 = "0810"
3+
LastUpgradeVersion = "1000"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -40,8 +40,8 @@
4040
buildConfiguration = "Debug"
4141
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4242
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43-
shouldUseLaunchSchemeArgsEnv = "YES"
44-
codeCoverageEnabled = "YES">
43+
codeCoverageEnabled = "YES"
44+
shouldUseLaunchSchemeArgsEnv = "YES">
4545
<Testables>
4646
<TestableReference
4747
skipped = "NO">
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>

0 commit comments

Comments
 (0)