Skip to content

Commit

Permalink
Match implicit dependencies when productNameWithExtension() is not co…
Browse files Browse the repository at this point in the history
…rrect
  • Loading branch information
mikeger committed May 5, 2024
1 parent 20b7655 commit ad5aa26
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/tuist/XcodeProj.git",
"state" : {
"revision" : "447c159b0c5fb047a024fd8d942d4a76cf47dde0",
"version" : "8.16.0"
"revision" : "313aaf1ad612135b7b0ccf731c86b5c07bf149b5",
"version" : "8.20.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ let package = Package(
],
products: products,
dependencies: [
.package(url: "https://github.com/tuist/XcodeProj.git", .upToNextMajor(from: "8.16.0")),
.package(url: "https://github.com/tuist/XcodeProj.git", .upToNextMajor(from: "8.20.0")),
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMajor(from: "1.2.0")),
.package(url: "https://github.com/kylef/PathKit.git", .upToNextMinor(from: "1.0.0")),
.package(url: "https://github.com/onevcat/Rainbow", .upToNextMajor(from: "4.0.0")),
Expand Down
24 changes: 22 additions & 2 deletions Sources/DependencyCalculator/DependencyGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,27 @@ extension PBXBuildFile {

return projectFolder + intermediatePath + path
} else {
Logger.warning("File without path: \(self)")
Logger.warning("File without path: self=\(self), \n self.file=\(String(describing: file)), \n self.product=\(String(describing: product))")
return nil
}
}
}

extension PBXNativeTarget {
func canProduce(_ productName: String) -> Bool {
if productNameWithExtension()?.lowercased() == productName.lowercased() {
return true
}

guard let ext = productType?.fileExtension else {
return false
}
// productNameWithExtension() is not always returning a correct name for the framework.
// Assume a tragetName.extension is a correct framework name, as a last resort
return "\(name).\(ext)".lowercased() == productName.lowercased()
}
}

extension WorkspaceInfo {
public static func parseWorkspace(at path: Path,
config: WorkspaceInfo.AdditionalConfig? = nil,
Expand Down Expand Up @@ -278,10 +293,15 @@ extension WorkspaceInfo {
file.path(projectFolder: path.parent())
} ?? []))

// Establish dependencies based on linked frameworks build phase
try target.frameworksBuildPhase()?.files?.forEach { file in
guard let path = file.file?.path else {
return
}

for (proj, projPath) in allProjects {
for someTarget in proj.pbxproj.nativeTargets {
if someTarget.productNameWithExtension() == file.file?.path {
if someTarget.canProduce(path) {
dependsOn.insert(targetIdentity,
dependOn: TargetIdentity.project(path: projPath, target: someTarget))
}
Expand Down

0 comments on commit ad5aa26

Please sign in to comment.