Open olbrichj opened 7 years ago
Okay I found a partial solution:
sourcekitten index --file $(pwd)/TestClass.swift --compilerargs -- "-sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk $(pwd)/MathClass.swift $(pwd)/TestClass.swift"
So for indexing one file and creating receivers I'll have to pass all the files in the compilerargs.
Do I have to parse every single file like this by itself? Or is there an option to bulk index like --file "File1";"File2"...
Truthfully I don't know about indexing much more than you do at this point. I mostly just re-exposed it out of SourceKit, but the tests for the indexing behavior aren't super educational either, and my traditional approach of learning by snooping how Xcode uses it doesn't work here, because Xcode 8 and later use SourceKitClient
to do its indexing, which isn't part of the open source SourceKit distribution 😞
Thanks for the reply. Seems a little bit more complicated than I thought. I've found the official protocol documentation for SourceKit Index: https://github.com/apple/swift/blob/master/tools/SourceKit/docs/Protocol.md#indexing Sadly it doesn't describe bulk indexing. I guess I'll open a ticket there.
But from what I've seen in the SourceKit response, there is no direct reference regarding which file was indexed, so I'm afraid I'll have to do it one by one.
Do you want to keep this issue open and I'll update what I find? Or shall we close it?
There is also a hash argument checking whether this file did change before reindexing it. Might be useful. I can't find it in sourcekitten
Hey,
I'm trying to index an entire Xcode project. Sadly the documentation for index is missing. In one of the issues I've found it describes I'll have to pass more arguments such as:
sourcekitten index --file $(pwd)/MathClass.swift --compilerargs -- "-sdk $(xcrun --show-sdk-path --sdk macosx) -j4 $(pwd)/MathClass.swift"
But truthfully I have a few problems understanding what exactly these arguments mean :(
Having two classes in one file, I'll get a key.receiver_usr when calling a method from another class. Splitting them into two and indexing them separately, I don't. I guess I have to pass the dependencies to sourcekitten... but I don't really know how.
There is probably no option yet to parse an entire Xcode project, or is there?
Help would be greatly appreciated :)
P.S. In case I figure it out I'd love to help updating the documentation.