Skip to content

Commit

Permalink
Convert SwiftPM to Swift 4
Browse files Browse the repository at this point in the history
  • Loading branch information
aciidgh committed Oct 16, 2017
1 parent 5aaa3b4 commit 0d9795f
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,5 @@ let package = Package(
name: "XcodeprojTests",
dependencies: ["Xcodeproj", "TestSupport"]),
],
swiftLanguageVersions: [3]
swiftLanguageVersions: [4]
)
21 changes: 0 additions & 21 deletions Sources/Basic/NSRegularExpressionShim.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/PackageDescription/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension Version: Hashable {
if let build = buildMetadataIdentifier {
result = (result &* mul) ^ UInt64(bitPattern: Int64(build.hashValue))
}
return Int(truncatingBitPattern: result)
return Int(truncatingIfNeeded: result)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/PackageDescription4/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ extension Version: Hashable {
result = (result &* mul) ^ UInt64(bitPattern: Int64(patch.hashValue))
result = prereleaseIdentifiers.reduce(result, { ($0 &* mul) ^ UInt64(bitPattern: Int64($1.hashValue)) })
result = buildMetadataIdentifiers.reduce(result, { ($0 &* mul) ^ UInt64(bitPattern: Int64($1.hashValue)) })
return Int(truncatingBitPattern: result)
return Int(truncatingIfNeeded: result)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/PackageModel/Module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ extension Sources {
let isLibrary = !relativePaths.contains { path in
let file = path.basename.lowercased()
// Look for a main.xxx file avoiding cases like main.xxx.xxx
return file.hasPrefix("main.") && file.filter({$0 == "."}).count == 1
return file.hasPrefix("main.") && String(file.filter({$0 == "."})).count == 1
}
return isLibrary ? .library : .executable
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/TestSupport/XCTestCasePerf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import XCTest
open class XCTestCasePerf: XCTestCase {

#if os(macOS) && !ENABLE_PERF_TESTS
override open class func defaultTestSuite() -> XCTestSuite {
override open class var defaultTestSuite: XCTestSuite {
return XCTestSuite(name: String(describing: type(of: self)))
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sources/Utility/PkgConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ struct PkgConfigParser {
// Append the value of the variable.
result += variableValue
// Update the fragment with post variable string.
fragment = fragment[fragment.index(after: variable.endIndex)..<fragment.endIndex]
fragment = String(fragment[fragment.index(after: variable.endIndex)...])
} else {
// No variable found, just append rest of the fragment to result.
result += fragment
Expand Down
2 changes: 1 addition & 1 deletion Sources/Utility/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extension Version: Hashable {
result = (result &* mul) ^ UInt64(bitPattern: Int64(patch.hashValue))
result = prereleaseIdentifiers.reduce(result, { ($0 &* mul) ^ UInt64(bitPattern: Int64($1.hashValue)) })
result = buildMetadataIdentifiers.reduce(result, { ($0 &* mul) ^ UInt64(bitPattern: Int64($1.hashValue)) })
return Int(truncatingBitPattern: result)
return Int(truncatingIfNeeded: result)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Utility/misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public func getClangVersion(versionOutput: String) -> (major: Int, minor: Int)?
}
let versionStartIndex = clangVersionString.index(clangVersionString.startIndex,
offsetBy: versionStringPrefix.utf8.count)
let versionString: String = clangVersionString[versionStartIndex..<clangVersionString.endIndex]
let versionString = clangVersionString[versionStartIndex...]
// Split major minor patch etc.
let versions = versionString.utf8.split(separator: UInt8(ascii: ".")).flatMap(String.init)
guard versions.count > 1, let major = Int(versions[0]), let minor = Int(versions[1]) else {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Workspace/Workspace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1159,10 +1159,10 @@ extension Workspace {
case (.removed, .removed): return true
case (.unchanged, .unchanged): return true
case (.updated(let a), .updated(let b)): return a == b
case (.added(_), _): return false
case (.removed(_), _): return false
case (.unchanged(_), _): return false
case (.updated(_), _): return false
case (.added, _): return false
case (.removed, _): return false
case (.unchanged, _): return false
case (.updated, _): return false
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/swiftpm-xctest-helper/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func run() throws {
guard let bundle = Bundle(path: bundlePath), bundle.load() else {
throw Error.unableToLoadBundle(bundlePath)
}
let suite = XCTestSuite.default()
let suite = XCTestSuite.default

let splitSet: Set<Character> = ["[", " ", "]", ":"]

Expand Down Expand Up @@ -63,7 +63,7 @@ func run() throws {
if let firstTest = testCaseSuite.tests.first {
name = String(reflecting: type(of: firstTest))
} else {
name = testCaseSuite.name ?? "nil"
name = testCaseSuite.name
}

// Collect the test methods.
Expand All @@ -85,7 +85,7 @@ func run() throws {
return ["name": name as NSString, "tests": tests as NSArray]
})
testCases.append([
"name": (testCaseSuite.name ?? "nil") as NSString,
"name": testCaseSuite.name as NSString,
"tests": testSuite as NSArray,
])
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/WorkspaceTests/WorkspaceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ final class WorkspaceTests: XCTestCase {
)

// Load the graph.
workspace.checkPackageGraph(roots: ["Root"]) { _ in }
workspace.checkPackageGraph(roots: ["Root"]) { _, _ in }

// Edit foo.
let fooPath = workspace.createWorkspace().editablesPath.appending(component: "Foo")
Expand Down
7 changes: 2 additions & 5 deletions Utilities/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ class Target(object):
if args.libdispatch_source_dir:
other_args.extend(["-Xcc", "-fblocks"])

# FIXME: Default to swift version 3 for now.
other_args.extend(["-swift-version", "3"])
other_args.extend(["-swift-version", "4"])

print(" %s:" % json.dumps(compile_swift_node), file=output)
print(" tool: swift-compiler", file=output)
Expand Down Expand Up @@ -1216,9 +1215,7 @@ def main():
if not os.path.exists(os.path.dirname(xcconfig_path)):
mkdir_p(os.path.dirname(xcconfig_path))
with open(xcconfig_path, "w") as f:
# Add hardcoded `-swift-version 3` in other swift flags for Xcode 8.3 support.
if find_xcode_version().startswith("Xcode 8.3"):
print("OTHER_SWIFT_FLAGS = $(inherited) -swift-version 3", file=f)
print("\n", file=f)
cmd += ["--xcconfig-overrides", xcconfig_path]

# Call `swift-package` to generate the Xcode project.
Expand Down

0 comments on commit 0d9795f

Please sign in to comment.