Skip to content

Commit

Permalink
Only import if it is possible to import
Browse files Browse the repository at this point in the history
  • Loading branch information
dfed committed Dec 9, 2023
1 parent 543d743 commit 98f74cb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/SafeDICore/Generators/DependencyTreeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ public final class DependencyTreeGenerator {

private var imports: String {
Set(moduleNames)
.map { "import \($0)" }
.map {
"""
#if canImport(\($0))
import \($0)
#endif
"""
}
.sorted()
.joined(separator: "\n")
}
Expand Down

0 comments on commit 98f74cb

Please sign in to comment.