jpsim / SourceKitten

An adorable little framework and command line tool for interacting with SourceKit.
MIT License
2.31k stars 226 forks source link

How to specify external SPM dependencies? #788

Open 97mik opened 1 year ago

97mik commented 1 year ago

When I try to run a request and the file contains imports of a 3rd party Swift package:

key.request: source.request.indexsource
key.sourcefile: "ViewController.swift"
key.compilerargs:
- "-sdk"
- "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk"
- "-target"
- "arm64-apple-ios16.4"
- "ViewController.swift"

Then I get an error: no such module 'MyPackage' And I don't get the index of those lines that use the structure from the package.

How can I specify links to used packages?

jpsim commented 1 year ago

You'll need to determine what compiler arguments Xcode passes to SourceKit and mirror those here.

You can do that by launching Xcode from the command line and looking at the logs:

$ SOURCEKIT_LOGGING=3 /Applications/Xcode.app/Contents/MacOS/Xcode