rules_swift icon indicating copy to clipboard operation
rules_swift copied to clipboard

[Feature Request] Support for changing internal/private import to private_deps automatically

Open CharlieSuP1 opened this issue 9 months ago • 1 comments

Let's say A depends on B,B depends on C。

By default, you need B.swiftmodule and C.swiftmodule to compile A。 So if C‘s public interface changed, module A must be recompiled.

To change this, you will need add C to B's private deps,and use internal/private import C in B's implementation. (Thanks for swift.experimental.AccessLevelOnImport feature,you won't need to write the _implementationOnly syntax ) So in this way, Bazel will not consider C.swiftmodule as A’s compile inputs,and compiler won't complain about it.

So can this be more automatic? My requested feature is: as for module B, any internal/private modules it imports, automatically become private deps,and won't propagate to module A.

And is there any support for new swift feature InternalImportsByDefault? Hopefully, make import internal by default and automatically change these dependencies to private deps will decrease lots of transitive dependencies and decrease build time in non-trivial projects.

One way to archive this may analyze swiftinterface for module B(if any),and find all public imports. Comparing these modules to deps of module B,changing any deps that not in B.swiftinterface to private_deps.

CharlieSuP1 avatar Jan 13 '25 10:01 CharlieSuP1