tuist / tuist

Tuist's CLI
https://tuist.dev
MIT License
4.62k stars 562 forks source link

Implicit import scanner does not detect external dependencies #6697

Closed karwa closed 1 month ago

karwa commented 2 months ago

What happened?

I have an external dependency (a SwiftPM package) which is declared as an explicit dependency by Target A. Target B only has an explicit dependency on Target A. Surprisingly, it is able to import the SwiftPM package, too.

It would be nice if the implicit import inspector detected these cases.

How do we reproduce it?

Sample project: https://github.com/karwa/tuist-external-implicit-dependency

tuist inspect implicit-imports does not detect any implicit imports in this project.

Error log

% tuist inspect implicit-imports                                                                                                                       
Loading and constructing the graph
It might take a while if the cache is empty
We did not find any implicit dependencies in your project.

The following warnings need attention:
 · We detected outdated dependencies. Please run "tuist install" to update them.

macOS version

14.6.1

Tuist version

4.26.0

Xcode version

15.4

fortmarek commented 2 months ago

Thanks for raising this 🙏

@rofle100lvl any ideas?

rofle100lvl commented 2 months ago

Here we use allInternalTargets method. If we use allTargets method in this project we will get this dependency. But we still need to remove source code checking of external dependencies I'll push fix later today/on weekends

sphanley commented 2 months ago

Question: I'm testing this against my project and it's flagging my test targets as having a number of dependencies which are dependencies of the host app target. What's the best practice here? Should those be treated as implicit dependencies, or is it valid and appropriate for them to be omitted from my test targets because they are resolved from the app target that's being tested?