SourceKitten icon indicating copy to clipboard operation
SourceKitten copied to clipboard

did not find primary SourceFile

Open iMostfa opened this issue 5 years ago • 4 comments

i have a problem when making a request using the framework: here's my code: `

let file = File(path: "/Users/username/Downloads/file.swift")!
let request  = SourceKittenFramework.Request.cursorInfo(file: "/Users/mostfa/Downloads/file.swift", offset: (90), arguments: [file.path!])
let cursorInfo = try  request.send()

print(cursorInfo)

`

and the response i get is {"error":true,"reason":"did not find primary SourceFile"}

i tried to google it, but didn't find an answer :(

file path is correct, and the structure for same file is generated as expected, can anyone help me with this ? thank you very much

iMostfa avatar Aug 04 '20 07:08 iMostfa

Have you found a solution? I'm running into the same problem after an XCode update.

kristiinara avatar Oct 29 '20 15:10 kristiinara

Have you found a solution? I'm running into the same problem after an XCode update.

Unfortunately, no

iMostfa avatar Nov 06 '20 08:11 iMostfa

SourceKit has required an explicit SDK for CursorInfo for a few Swift releases now.

So you need to include "-sdk", "/path/to/sdk" in the args.

Yes, the error response from SourceKit is misleading.

johnfairh avatar Nov 06 '20 09:11 johnfairh

I had the same problem with the index request, but have both sdk and target specified. Could there be some additional argument that needs to be specified?

kristiinara avatar Nov 06 '20 09:11 kristiinara