Skip to content

Commit

Permalink
Merge pull request #26 from minuscorp/swift-5-5-2-support
Browse files Browse the repository at this point in the history
  • Loading branch information
minuscorp authored Dec 10, 2021
2 parents 964537b + 35f0d4e commit 7081db0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Sources/PackageConfig/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,24 @@ enum Package {
// /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2
let fileManager = FileManager.default
let swiftPMDir = swiftPath.replacingOccurrences(of: "bin/swiftc", with: "lib/swift/pm")
#if swift(<5.5.2)
let swiftToolsVersion = getSwiftToolsVersion()
#if compiler(>=5.5.2)
// Since Swift 5.5.2 there're no more different versions installed in the toolchain and it is stored
// in another directory
let directory = try! fileManager.contentsOfDirectory(atPath: swiftPMDir)
.first(where: { $0.starts(with: "Manifest") })
let spmManifestDir = directory!
#else
let versions = try! fileManager.contentsOfDirectory(atPath: swiftPMDir)
.filter { $0 != "llbuild" }
.filter { $0.first?.isNumber ?? false }

let latestVersion = versions.sorted().last!
var spmManifestDir = latestVersion
let swiftToolsVersion = getSwiftToolsVersion()

if let swiftToolsVersion = swiftToolsVersion, versions.contains(swiftToolsVersion) {
spmManifestDir = swiftToolsVersion
}
#else
// Since Swift 5.5.2 there're no more different versions installed in the toolchain and it is stored
// in another directory
let directory = try! fileManager.contentsOfDirectory(atPath: swiftPMDir)
.first(where: { $0.starts(with: "Manifest") })
let spmManifestDir = swiftPMDir + "/" + directory!
#endif


Expand Down

0 comments on commit 7081db0

Please sign in to comment.