Skip to content

Commit

Permalink
Do not parse third-party code in Swift Package plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dfed committed Dec 11, 2023
1 parent 3786558 commit 654c0fd
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,30 @@ struct SafeDIGenerateDependencyTree: BuildToolPlugin {

extension Target {

var sourceModuleRecursiveDependencies: [SourceModuleTarget] {
var sourceModuleRecursiveDependencies: [SwiftSourceModuleTarget] {
recursiveTargetDependencies.compactMap {
$0 as? SourceModuleTarget
// Since we only understand Swift files, we only care about SwiftSourceModuleTargets.
guard let swiftModule = $0 as? SwiftSourceModuleTarget else {
return nil
}

// We only care about first-party code. Ignore third-party dependencies.
guard
swiftModule
.directory
// Removing the module name.
.removingLastComponent()
// Removing 'Sources'.
.removingLastComponent()
// Removing the package name.
.removingLastComponent()
.lastComponent != "checkouts"
else {
return nil
}
return swiftModule
}
}

}

#if canImport(XcodeProjectPlugin)
Expand Down

0 comments on commit 654c0fd

Please sign in to comment.