Open LLlkaiwen opened 4 months ago
one indexstore should not be imported with different targetPathOverride
But that's the point of targetPathOverride
. It allows both the merged target and the library target to have indexing information. Though it should only import twice if the library and the merged target both exist in Xcode, which can happen if the library can merge successfully into one target but not another.
As I know, the targetPathOverride
is only used to remap the path of Object files
. Also I find that the imported index will works if only the source file path is remapped correctly. So, maybe we can import all indexstores with empty targetPathOverride
only once.
The object path needs to match the the one the target would create, otherwise Xcode doesn't see unit file and recreates it (because it uses the same object path and gets the same expected hash).
I see now how this will import the same indexstore twice even if the merged library never appears bare in the project. Ideally it should only import an indexstore with multiple targetOverridePath
if there is a target in the project for that targetOverridePath
. This is slightly tricky because with target (un)focusing we may want to import and indexstore even though no target is generated.
When generating the xcodeproj, we can get which xcode target
everybazel target
belongs to. And we can also get which bazel target
ervey indexstore
belong to.
So, if we record the relation between xcode target
and bazel target
when generating xcodeproj, we can use that information to find which xcode target
every indexstore
real belongs to when importing index
Description
I find two different units in Datastore for one source file after Indexing ends.
The two units are both imported from bazel generated indexstore because Xcode does not index the file 'ContentView.swift' I think the reason may be that one indexstore is recorded two times with diffrent targetPathOverride in bi.filelist.
Reproduction steps
we can reproduce the behavior in examples/rules_ios.
Index.noindex/DataStore/v5/units
Expected behavior
one indexstore should not be imported with different targetPathOverride
rules_xcodeproj version
2.5.2
Xcode version
15.0
Bazel version
7.1.1
rules_apple version
No response
rules_swift version
No response
Additional information
No response