Skip to content

Commit 449b14b

Browse files
Update to Swift 4
- applied XCode fixes in Quicksort.swift and Quicsort playgrund - renamed "Tests" project to "Tests(quicksort)" and recreated scheme - to be easier pickable in schemes list - applied swift 4 settings
1 parent 2fcf397 commit 449b14b

File tree

7 files changed

+47
-58
lines changed

7 files changed

+47
-58
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ script:
3232
- xcodebuild test -project ./Minimum\ Spanning\ Tree\ \(Unweighted\)/Tests/Tests.xcodeproj -scheme Tests
3333
- xcodebuild test -project ./Priority\ Queue/Tests/Tests.xcodeproj -scheme Tests
3434
- xcodebuild test -project ./Queue/Tests/Tests.xcodeproj -scheme Tests
35-
- xcodebuild test -project ./Quicksort/Tests/Tests.xcodeproj -scheme Tests
35+
- xcodebuild test -project ./Quicksort/Tests/Tests(quicksort).xcodeproj -scheme Tests(quicksort)
3636
- xcodebuild test -project ./Radix\ Sort/Tests/Tests.xcodeproj -scheme Tests
3737
- xcodebuild test -project ./Rootish\ Array\ Stack/Tests/Tests.xcodeproj -scheme Tests
3838
- xcodebuild test -project ./Select\ Minimum\ Maximum/Tests/Tests.xcodeproj -scheme Tests

Quicksort/Quicksort.playground/Contents.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//: Playground - noun: a place where people can play
22

3+
// last checked with Xcode 9.0b4
4+
#if swift(>=4.0)
5+
print("Hello, Swift 4!")
6+
#endif
7+
38
import Foundation
49

510
// *** Simple but inefficient version of quicksort ***
@@ -80,7 +85,7 @@ func partitionHoare<T: Comparable>(_ a: inout [T], low: Int, high: Int) -> Int {
8085
repeat { i += 1 } while a[i] < pivot
8186

8287
if i < j {
83-
swap(&a[i], &a[j])
88+
a.swapAt(i, j)
8489
} else {
8590
return j
8691
}
@@ -132,7 +137,7 @@ list4
132137
*/
133138
public func swap<T>(_ a: inout [T], _ i: Int, _ j: Int) {
134139
if i != j {
135-
swap(&a[i], &a[j])
140+
a.swapAt(i, j)
136141
}
137142
}
138143

Quicksort/Quicksort.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func partitionHoare<T: Comparable>(_ a: inout [T], low: Int, high: Int) -> Int {
9090
repeat { i += 1 } while a[i] < pivot
9191

9292
if i < j {
93-
swap(&a[i], &a[j])
93+
a.swapAt(i, j)
9494
} else {
9595
return j
9696
}
@@ -144,7 +144,7 @@ func quicksortRandom<T: Comparable>(_ a: inout [T], low: Int, high: Int) {
144144
*/
145145
public func swap<T>(_ a: inout [T], _ i: Int, _ j: Int) {
146146
if i != j {
147-
swap(&a[i], &a[j])
147+
a.swapAt(i, j)
148148
}
149149
}
150150

Quicksort/Tests/Tests.xcodeproj/project.pbxproj renamed to Quicksort/Tests/Tests(quicksort).xcodeproj/project.pbxproj

+30-14
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/* End PBXBuildFile section */
1414

1515
/* Begin PBXFileReference section */
16-
7B2BBC801C779D720067B71D /* Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
16+
7B2BBC801C779D720067B71D /* Tests(quicksort).xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Tests(quicksort).xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
1717
7B2BBC941C779E7B0067B71D /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
1818
7B80C3E51C77A4CA003CECC7 /* Quicksort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Quicksort.swift; path = ../Quicksort.swift; sourceTree = SOURCE_ROOT; };
1919
7B80C3E71C77A4D0003CECC7 /* QuicksortTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuicksortTests.swift; sourceTree = SOURCE_ROOT; };
@@ -42,7 +42,7 @@
4242
7B2BBC721C779D710067B71D /* Products */ = {
4343
isa = PBXGroup;
4444
children = (
45-
7B2BBC801C779D720067B71D /* Tests.xctest */,
45+
7B2BBC801C779D720067B71D /* Tests(quicksort).xctest */,
4646
);
4747
name = Products;
4848
sourceTree = "<group>";
@@ -62,9 +62,9 @@
6262
/* End PBXGroup section */
6363

6464
/* Begin PBXNativeTarget section */
65-
7B2BBC7F1C779D720067B71D /* Tests */ = {
65+
7B2BBC7F1C779D720067B71D /* Tests(quicksort) */ = {
6666
isa = PBXNativeTarget;
67-
buildConfigurationList = 7B2BBC8C1C779D720067B71D /* Build configuration list for PBXNativeTarget "Tests" */;
67+
buildConfigurationList = 7B2BBC8C1C779D720067B71D /* Build configuration list for PBXNativeTarget "Tests(quicksort)" */;
6868
buildPhases = (
6969
7B2BBC7C1C779D720067B71D /* Sources */,
7070
7B2BBC7D1C779D720067B71D /* Frameworks */,
@@ -74,9 +74,9 @@
7474
);
7575
dependencies = (
7676
);
77-
name = Tests;
77+
name = "Tests(quicksort)";
7878
productName = TestsTests;
79-
productReference = 7B2BBC801C779D720067B71D /* Tests.xctest */;
79+
productReference = 7B2BBC801C779D720067B71D /* Tests(quicksort).xctest */;
8080
productType = "com.apple.product-type.bundle.unit-test";
8181
};
8282
/* End PBXNativeTarget section */
@@ -86,16 +86,16 @@
8686
isa = PBXProject;
8787
attributes = {
8888
LastSwiftUpdateCheck = 0720;
89-
LastUpgradeCheck = 0820;
89+
LastUpgradeCheck = 0900;
9090
ORGANIZATIONNAME = "Swift Algorithm Club";
9191
TargetAttributes = {
9292
7B2BBC7F1C779D720067B71D = {
9393
CreatedOnToolsVersion = 7.2;
94-
LastSwiftMigration = 0820;
94+
LastSwiftMigration = 0900;
9595
};
9696
};
9797
};
98-
buildConfigurationList = 7B2BBC6C1C779D710067B71D /* Build configuration list for PBXProject "Tests" */;
98+
buildConfigurationList = 7B2BBC6C1C779D710067B71D /* Build configuration list for PBXProject "Tests(quicksort)" */;
9999
compatibilityVersion = "Xcode 3.2";
100100
developmentRegion = English;
101101
hasScannedForEncodings = 0;
@@ -108,7 +108,7 @@
108108
projectDirPath = "";
109109
projectRoot = "";
110110
targets = (
111-
7B2BBC7F1C779D720067B71D /* Tests */,
111+
7B2BBC7F1C779D720067B71D /* Tests(quicksort) */,
112112
);
113113
};
114114
/* End PBXProject section */
@@ -145,14 +145,20 @@
145145
CLANG_CXX_LIBRARY = "libc++";
146146
CLANG_ENABLE_MODULES = YES;
147147
CLANG_ENABLE_OBJC_ARC = YES;
148+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
148149
CLANG_WARN_BOOL_CONVERSION = YES;
150+
CLANG_WARN_COMMA = YES;
149151
CLANG_WARN_CONSTANT_CONVERSION = YES;
150152
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
151153
CLANG_WARN_EMPTY_BODY = YES;
152154
CLANG_WARN_ENUM_CONVERSION = YES;
153155
CLANG_WARN_INFINITE_RECURSION = YES;
154156
CLANG_WARN_INT_CONVERSION = YES;
157+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
158+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
155159
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
160+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
161+
CLANG_WARN_STRICT_PROTOTYPES = YES;
156162
CLANG_WARN_SUSPICIOUS_MOVE = YES;
157163
CLANG_WARN_UNREACHABLE_CODE = YES;
158164
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -180,6 +186,7 @@
180186
ONLY_ACTIVE_ARCH = YES;
181187
SDKROOT = macosx;
182188
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
189+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
183190
};
184191
name = Debug;
185192
};
@@ -191,14 +198,20 @@
191198
CLANG_CXX_LIBRARY = "libc++";
192199
CLANG_ENABLE_MODULES = YES;
193200
CLANG_ENABLE_OBJC_ARC = YES;
201+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
194202
CLANG_WARN_BOOL_CONVERSION = YES;
203+
CLANG_WARN_COMMA = YES;
195204
CLANG_WARN_CONSTANT_CONVERSION = YES;
196205
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
197206
CLANG_WARN_EMPTY_BODY = YES;
198207
CLANG_WARN_ENUM_CONVERSION = YES;
199208
CLANG_WARN_INFINITE_RECURSION = YES;
200209
CLANG_WARN_INT_CONVERSION = YES;
210+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
211+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
201212
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
213+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
214+
CLANG_WARN_STRICT_PROTOTYPES = YES;
202215
CLANG_WARN_SUSPICIOUS_MOVE = YES;
203216
CLANG_WARN_UNREACHABLE_CODE = YES;
204217
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -219,6 +232,7 @@
219232
MTL_ENABLE_DEBUG_INFO = NO;
220233
SDKROOT = macosx;
221234
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
235+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
222236
};
223237
name = Release;
224238
};
@@ -230,7 +244,8 @@
230244
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
231245
PRODUCT_BUNDLE_IDENTIFIER = swift.algorithm.club.Tests;
232246
PRODUCT_NAME = "$(TARGET_NAME)";
233-
SWIFT_VERSION = 3.0;
247+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
248+
SWIFT_VERSION = 4.0;
234249
};
235250
name = Debug;
236251
};
@@ -242,14 +257,15 @@
242257
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
243258
PRODUCT_BUNDLE_IDENTIFIER = swift.algorithm.club.Tests;
244259
PRODUCT_NAME = "$(TARGET_NAME)";
245-
SWIFT_VERSION = 3.0;
260+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
261+
SWIFT_VERSION = 4.0;
246262
};
247263
name = Release;
248264
};
249265
/* End XCBuildConfiguration section */
250266

251267
/* Begin XCConfigurationList section */
252-
7B2BBC6C1C779D710067B71D /* Build configuration list for PBXProject "Tests" */ = {
268+
7B2BBC6C1C779D710067B71D /* Build configuration list for PBXProject "Tests(quicksort)" */ = {
253269
isa = XCConfigurationList;
254270
buildConfigurations = (
255271
7B2BBC871C779D720067B71D /* Debug */,
@@ -258,7 +274,7 @@
258274
defaultConfigurationIsVisible = 0;
259275
defaultConfigurationName = Release;
260276
};
261-
7B2BBC8C1C779D720067B71D /* Build configuration list for PBXNativeTarget "Tests" */ = {
277+
7B2BBC8C1C779D720067B71D /* Build configuration list for PBXNativeTarget "Tests(quicksort)" */ = {
262278
isa = XCConfigurationList;
263279
buildConfigurations = (
264280
7B2BBC8D1C779D720067B71D /* Debug */,

Quicksort/Tests/Tests.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme renamed to Quicksort/Tests/Tests(quicksort).xcodeproj/xcshareddata/xcschemes/Tests(quicksort).xcscheme

+6-38
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,26 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
77
buildImplicitDependencies = "YES">
8-
<BuildActionEntries>
9-
<BuildActionEntry
10-
buildForTesting = "YES"
11-
buildForRunning = "YES"
12-
buildForProfiling = "NO"
13-
buildForArchiving = "NO"
14-
buildForAnalyzing = "NO">
15-
<BuildableReference
16-
BuildableIdentifier = "primary"
17-
BlueprintIdentifier = "7B2BBC7F1C779D720067B71D"
18-
BuildableName = "Tests.xctest"
19-
BlueprintName = "Tests"
20-
ReferencedContainer = "container:Tests.xcodeproj">
21-
</BuildableReference>
22-
</BuildActionEntry>
23-
</BuildActionEntries>
248
</BuildAction>
259
<TestAction
2610
buildConfiguration = "Debug"
2711
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2812
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
13+
language = ""
2914
shouldUseLaunchSchemeArgsEnv = "YES">
3015
<Testables>
3116
<TestableReference
3217
skipped = "NO">
3318
<BuildableReference
3419
BuildableIdentifier = "primary"
3520
BlueprintIdentifier = "7B2BBC7F1C779D720067B71D"
36-
BuildableName = "Tests.xctest"
37-
BlueprintName = "Tests"
38-
ReferencedContainer = "container:Tests.xcodeproj">
21+
BuildableName = "Tests(quicksort).xctest"
22+
BlueprintName = "Tests(quicksort)"
23+
ReferencedContainer = "container:Tests(quicksort).xcodeproj">
3924
</BuildableReference>
4025
</TestableReference>
4126
</Testables>
@@ -46,21 +31,13 @@
4631
buildConfiguration = "Debug"
4732
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4833
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
34+
language = ""
4935
launchStyle = "0"
5036
useCustomWorkingDirectory = "NO"
5137
ignoresPersistentStateOnLaunch = "NO"
5238
debugDocumentVersioning = "YES"
5339
debugServiceExtension = "internal"
5440
allowLocationSimulation = "YES">
55-
<MacroExpansion>
56-
<BuildableReference
57-
BuildableIdentifier = "primary"
58-
BlueprintIdentifier = "7B2BBC7F1C779D720067B71D"
59-
BuildableName = "Tests.xctest"
60-
BlueprintName = "Tests"
61-
ReferencedContainer = "container:Tests.xcodeproj">
62-
</BuildableReference>
63-
</MacroExpansion>
6441
<AdditionalOptions>
6542
</AdditionalOptions>
6643
</LaunchAction>
@@ -70,15 +47,6 @@
7047
savedToolIdentifier = ""
7148
useCustomWorkingDirectory = "NO"
7249
debugDocumentVersioning = "YES">
73-
<MacroExpansion>
74-
<BuildableReference
75-
BuildableIdentifier = "primary"
76-
BlueprintIdentifier = "7B2BBC7F1C779D720067B71D"
77-
BuildableName = "Tests.xctest"
78-
BlueprintName = "Tests"
79-
ReferencedContainer = "container:Tests.xcodeproj">
80-
</BuildableReference>
81-
</MacroExpansion>
8250
</ProfileAction>
8351
<AnalyzeAction
8452
buildConfiguration = "Debug">

swift-algorithm-club.xcworkspace/contents.xcworkspacedata

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)