Skip to content

Commit 7b11867

Browse files
committed
Update dependencies for Swift 5.7
1 parent ff7327b commit 7b11867

File tree

5 files changed

+64
-12
lines changed

5 files changed

+64
-12
lines changed

Package.resolved

Lines changed: 26 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
import PackageDescription
55

66
let dependencies: [Package.Dependency]
7-
#if swift(>=5.6)
7+
#if swift(>=5.7)
8+
dependencies = [
9+
.package(url: "https://github.com/apple/swift-argument-parser.git", .exact("1.0.3")),
10+
.package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .branch("release/5.7")),
11+
.package(url: "https://github.com/apple/swift-tools-support-core.git", .branch("release/5.7")),
12+
]
13+
#elseif swift(>=5.6)
814
dependencies = [
915
.package(url: "https://github.com/apple/swift-argument-parser.git", .exact("1.0.3")),
1016
.package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .branch("release/5.6")),

Sources/CreateXCFramework/PackageInfo.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ struct PackageInfo {
8888

8989
self.toolchain = try UserToolchain(destination: try .hostDestination())
9090

91-
#if swift(>=5.6)
91+
#if swift(>=5.7)
92+
let loader = ManifestLoader(toolchain: self.toolchain)
93+
self.workspace = try Workspace(forRootPackage: root, customManifestLoader: loader)
94+
#elseif swift(>=5.6)
9295
let resources = ToolchainConfiguration(swiftCompilerPath: self.toolchain.swiftCompilerPath)
9396
let loader = ManifestLoader(toolchain: resources)
9497
self.workspace = try Workspace(forRootPackage: root, customManifestLoader: loader)

Sources/CreateXCFramework/ProjectGenerator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct ProjectGenerator {
2323

2424
var projectPath: AbsolutePath {
2525
let dir = AbsolutePath(self.package.projectBuildDirectory.path)
26-
return buildXcodeprojPath(outputDir: dir, projectName: self.package.manifest.displayName)
26+
return XcodeProject.makePath(outputDir: dir, projectName: self.package.manifest.displayName)
2727
}
2828

2929

Sources/CreateXCFramework/Zipper.swift

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import PackageGraph
1212
import PackageModel
1313
import TSCBasic
1414
import Workspace
15+
import Basics
1516

1617
struct Zipper {
1718

@@ -54,7 +55,9 @@ struct Zipper {
5455
}
5556

5657
func checksum (file: Foundation.URL) throws -> Foundation.URL {
57-
#if swift(>=5.6)
58+
#if swift(>=5.7)
59+
let sum = try checksum(forBinaryArtifactAt: AbsolutePath(file.path))
60+
#elseif swift(>=5.6)
5861
let sum = try self.package.workspace.checksum(forBinaryArtifactAt: AbsolutePath(file.path))
5962
#else
6063
let sum = self.package.workspace.checksum(forBinaryArtifactAt: AbsolutePath(file.path), diagnostics: self.package.diagnostics)
@@ -106,6 +109,28 @@ struct Zipper {
106109
func clean (file: Foundation.URL) throws {
107110
try FileManager.default.removeItem(at: file)
108111
}
112+
113+
#if swift(>=5.7)
114+
private func checksum(forBinaryArtifactAt path: AbsolutePath) throws -> String {
115+
let fileSystem = localFileSystem
116+
let checksumAlgorithm = SHA256()
117+
let archiver = ZipArchiver(fileSystem: fileSystem)
118+
119+
// Validate the path has a supported extension.
120+
guard let pathExtension = path.extension, archiver.supportedExtensions.contains(pathExtension) else {
121+
let supportedExtensionList = archiver.supportedExtensions.joined(separator: ", ")
122+
throw StringError("unexpected file type; supported extensions are: \(supportedExtensionList)")
123+
}
124+
125+
// Ensure that the path with the accepted extension is a file.
126+
guard fileSystem.isFile(path) else {
127+
throw StringError("file not found at path: \(path.pathString)")
128+
}
129+
130+
let contents = try fileSystem.readFileContents(path)
131+
return checksumAlgorithm.hash(contents).hexadecimalRepresentation
132+
}
133+
#endif
109134
}
110135

111136
#if swift(>=5.6)

0 commit comments

Comments
 (0)