diff --git a/Sources/SafeDICore/Generators/DependencyTreeGenerator.swift b/Sources/SafeDICore/Generators/DependencyTreeGenerator.swift index ede93a30..531f72c0 100644 --- a/Sources/SafeDICore/Generators/DependencyTreeGenerator.swift +++ b/Sources/SafeDICore/Generators/DependencyTreeGenerator.swift @@ -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") }