Skip to content

Commit 0c93543

Browse files
author
Erik Strottmann
committed
Update Trie to Swift 4.2
Removes `#if swift(>=4.0)` checks and calls to deprecated `String.characters` property, and enables Xcode 10 recommended warnings.
1 parent 9f5e81e commit 0c93543

File tree

6 files changed

+39
-27
lines changed

6 files changed

+39
-27
lines changed

Trie/ReadMe.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func contains(word: String) -> Bool {
3333
var currentNode = root
3434

3535
// 2
36-
var characters = Array(word.lowercased().characters)
36+
var characters = Array(word.lowercased())
3737
var currentIndex = 0
3838

3939
// 3
@@ -74,7 +74,7 @@ func insert(word: String) {
7474
var currentNode = root
7575

7676
// 2
77-
for character in word.lowercased().characters {
77+
for character in word.lowercased() {
7878
// 3
7979
if let childNode = currentNode.children[character] {
8080
currentNode = childNode

Trie/Trie/Trie.xcodeproj/project.pbxproj

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,23 @@
195195
isa = PBXProject;
196196
attributes = {
197197
LastSwiftUpdateCheck = 0810;
198-
LastUpgradeCheck = 0820;
198+
LastUpgradeCheck = 1000;
199199
ORGANIZATIONNAME = "Rick Zaccone";
200200
TargetAttributes = {
201201
EB798DF91DFEF79900F0628D = {
202202
CreatedOnToolsVersion = 8.1;
203+
LastSwiftMigration = 1000;
203204
ProvisioningStyle = Automatic;
204205
};
205206
EB798E0A1DFEF79900F0628D = {
206207
CreatedOnToolsVersion = 8.1;
208+
LastSwiftMigration = 1000;
207209
ProvisioningStyle = Automatic;
208210
TestTargetID = EB798DF91DFEF79900F0628D;
209211
};
210212
EB798E151DFEF79900F0628D = {
211213
CreatedOnToolsVersion = 8.1;
214+
LastSwiftMigration = 1000;
212215
ProvisioningStyle = Automatic;
213216
TestTargetID = EB798DF91DFEF79900F0628D;
214217
};
@@ -326,15 +329,23 @@
326329
CLANG_CXX_LIBRARY = "libc++";
327330
CLANG_ENABLE_MODULES = YES;
328331
CLANG_ENABLE_OBJC_ARC = YES;
332+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
329333
CLANG_WARN_BOOL_CONVERSION = YES;
334+
CLANG_WARN_COMMA = YES;
330335
CLANG_WARN_CONSTANT_CONVERSION = YES;
336+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
331337
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
332338
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
333339
CLANG_WARN_EMPTY_BODY = YES;
334340
CLANG_WARN_ENUM_CONVERSION = YES;
335341
CLANG_WARN_INFINITE_RECURSION = YES;
336342
CLANG_WARN_INT_CONVERSION = YES;
343+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
344+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
345+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
337346
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
347+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
348+
CLANG_WARN_STRICT_PROTOTYPES = YES;
338349
CLANG_WARN_SUSPICIOUS_MOVE = YES;
339350
CLANG_WARN_SUSPICIOUS_MOVES = YES;
340351
CLANG_WARN_UNREACHABLE_CODE = YES;
@@ -376,15 +387,23 @@
376387
CLANG_CXX_LIBRARY = "libc++";
377388
CLANG_ENABLE_MODULES = YES;
378389
CLANG_ENABLE_OBJC_ARC = YES;
390+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
379391
CLANG_WARN_BOOL_CONVERSION = YES;
392+
CLANG_WARN_COMMA = YES;
380393
CLANG_WARN_CONSTANT_CONVERSION = YES;
394+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
381395
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
382396
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
383397
CLANG_WARN_EMPTY_BODY = YES;
384398
CLANG_WARN_ENUM_CONVERSION = YES;
385399
CLANG_WARN_INFINITE_RECURSION = YES;
386400
CLANG_WARN_INT_CONVERSION = YES;
401+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
402+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
403+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
387404
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
405+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
406+
CLANG_WARN_STRICT_PROTOTYPES = YES;
388407
CLANG_WARN_SUSPICIOUS_MOVE = YES;
389408
CLANG_WARN_SUSPICIOUS_MOVES = YES;
390409
CLANG_WARN_UNREACHABLE_CODE = YES;
@@ -418,7 +437,7 @@
418437
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
419438
PRODUCT_BUNDLE_IDENTIFIER = edu.bucknell.zaccone.Trie;
420439
PRODUCT_NAME = "$(TARGET_NAME)";
421-
SWIFT_VERSION = 3.0;
440+
SWIFT_VERSION = 4.2;
422441
};
423442
name = Debug;
424443
};
@@ -431,7 +450,7 @@
431450
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
432451
PRODUCT_BUNDLE_IDENTIFIER = edu.bucknell.zaccone.Trie;
433452
PRODUCT_NAME = "$(TARGET_NAME)";
434-
SWIFT_VERSION = 3.0;
453+
SWIFT_VERSION = 4.2;
435454
};
436455
name = Release;
437456
};
@@ -445,7 +464,7 @@
445464
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
446465
PRODUCT_BUNDLE_IDENTIFIER = edu.bucknell.zaccone.TrieTests;
447466
PRODUCT_NAME = "$(TARGET_NAME)";
448-
SWIFT_VERSION = 3.0;
467+
SWIFT_VERSION = 4.2;
449468
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Trie.app/Contents/MacOS/Trie";
450469
};
451470
name = Debug;
@@ -460,7 +479,7 @@
460479
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
461480
PRODUCT_BUNDLE_IDENTIFIER = edu.bucknell.zaccone.TrieTests;
462481
PRODUCT_NAME = "$(TARGET_NAME)";
463-
SWIFT_VERSION = 3.0;
482+
SWIFT_VERSION = 4.2;
464483
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Trie.app/Contents/MacOS/Trie";
465484
};
466485
name = Release;
@@ -474,7 +493,7 @@
474493
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
475494
PRODUCT_BUNDLE_IDENTIFIER = edu.bucknell.zaccone.TrieUITests;
476495
PRODUCT_NAME = "$(TARGET_NAME)";
477-
SWIFT_VERSION = 3.0;
496+
SWIFT_VERSION = 4.2;
478497
TEST_TARGET_NAME = Trie;
479498
};
480499
name = Debug;
@@ -488,7 +507,7 @@
488507
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
489508
PRODUCT_BUNDLE_IDENTIFIER = edu.bucknell.zaccone.TrieUITests;
490509
PRODUCT_NAME = "$(TARGET_NAME)";
491-
SWIFT_VERSION = 3.0;
510+
SWIFT_VERSION = 4.2;
492511
TEST_TARGET_NAME = Trie;
493512
};
494513
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>

Trie/Trie/Trie/Trie.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
// Copyright © 2016 Rick Zaccone. All rights reserved.
77
//
88

9-
// last checked with Xcode 9.0b4
10-
#if swift(>=4.0)
11-
print("Hello, Swift 4!")
12-
#endif
13-
149
import Foundation
1510

1611
/// A node in the trie
@@ -105,7 +100,7 @@ extension Trie {
105100
return
106101
}
107102
var currentNode = root
108-
for character in word.lowercased().characters {
103+
for character in word.lowercased() {
109104
if let childNode = currentNode.children[character] {
110105
currentNode = childNode
111106
} else {
@@ -130,7 +125,7 @@ extension Trie {
130125
return false
131126
}
132127
var currentNode = root
133-
for character in word.lowercased().characters {
128+
for character in word.lowercased() {
134129
guard let childNode = currentNode.children[character] else {
135130
return false
136131
}
@@ -148,7 +143,7 @@ extension Trie {
148143
/// search failed.
149144
private func findLastNodeOf(word: String) -> Node? {
150145
var currentNode = root
151-
for character in word.lowercased().characters {
146+
for character in word.lowercased() {
152147
guard let childNode = currentNode.children[character] else {
153148
return nil
154149
}

Trie/Trie/Trie/ViewController.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
// Copyright © 2016 Rick Zaccone. All rights reserved.
77
//
88

9-
// last checked with Xcode 9.0b4
10-
#if swift(>=4.0)
11-
print("Hello, Swift 4!")
12-
#endif
13-
149
import Cocoa
1510

1611
class ViewController: NSViewController {

Trie/Trie/TrieTests/TrieTests.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
// Copyright © 2016 Rick Zaccone. All rights reserved.
77
//
88

9-
// last checked with Xcode 9.0b4
10-
#if swift(>=4.0)
11-
print("Hello, Swift 4!")
12-
#endif
13-
149
import XCTest
1510
@testable import Trie
1611

0 commit comments

Comments
 (0)