MobileNativeFoundation / index-import

Tool to import swiftc and clang index-store files into Xcode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Questions around usage

michaeleisel opened this issue · comments

For my project, I have an index-import script that runs without complaint (https://gist.github.com/michaeleisel/20888d8534100ce0943ac74489bbf8a6) and I've added --features=swift.index_while_building but it still doesn't seem to work. The project is generated with Tulsi and consists of a large top-level Swift library and smaller Objective-C and Swift dependencies. By default, Tulsi adds all the source files to some target that corresponds to that file's rule. This allows it to do some indexing, but with a lot of caveats, and index-import doesn't seem to add any more syntax coloring etc. than what it manages to index already. Some questions:

  • How does Lyft avoid Xcode not doing indexing anyways? I know that they use CC=... etc., but since this doesn't apply to indexing, won't it run as usual?
  • Does it matter which Xcode target each file is in? Do they need targets at all?
  • If indexing artifacts are being copied in for the top-level Swift target, but not for its Objective-C dependencies, can that cause issues? For me, Tulsi's attempt at indexing those targets doesn't succeed, meaning syntax coloring doesn't work anywhere in Swift that they're referenced, and index-import doesn't seem to help even after running it as post-build script phase. Does Lyft have any Objective-C dependencies, even just pre-built libraries, that it has to deal with this for?
  • Would it be possible to have an example project that allows one to observe clearly the impact of index-import and see how they should structure their own project?

How does Lyft avoid Xcode not doing indexing anyways?

Xcode does run indexing, but generally it is happy with the index we provide it, so that one seems to take precedence over its failing index commands. I think this is also a bit easier with Swift since we provide the swiftmodules from all dependencies in derived data.

Does it matter which Xcode target each file is in? Do they need targets at all?

Yes. The files must be part of targets and part of the active scheme for Xcode to correctly integrate indexing. Also since the indexes are module based the targets have to mirror that structure.

If indexing artifacts are being copied in for the top-level Swift target, but not for its Objective-C dependencies, can that cause issues?

I would expect this to be required as soon as you started trying to highlight or get code completion for the dependent targets. But inside the top-level Swift target it might be fine otherwise.

Does Lyft have any Objective-C dependencies, even just pre-built libraries, that it has to deal with this for?

All of our Objective-C dependencies are vendored as pre-compiled frameworks so this "just works" in Xcode even by providing valid FRAMEWORK_SEARCH_PATHS to those since there it can find the modulemaps and headers.