terhechte/SourceKittenDaemon

Empty complete response

Opened this issue · 5 comments

I installed SourceKittenDaemon by cloning and make install

start:

sourcekittendaemon start --project MyProject.xcodeproj/ --port 53259

Getting a list of files works ok.

If I do the following request:

[HTTP] GET /complete X-Offset:41 X-Path:/Users/dan2552/projects/my_project/MyProject/App/AppDelegate.swift

I get an empty collection as the response:

[

]

When running straight from SourceKitten (installed by homebrew) using:

sourcekitten complete --file /Users/dan2552/projects/my_project/MyProject/App/AppDelegate.swift --offset 41

I get a proper result back.

Any ideas what I might be doing wrong?

Contents off AppDelegate.swift:

import Foundation

let str = "hello"
str.

I'd try using the -sdk flag

sourcekitten complete --text "import UIKit ; UIColor." --offset 22 -- -target arm64-apple-ios9.0 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk

You'll need to check to see what sdk you have installed

ls /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/

I'm having the same problem. The result from /complete is always empty, while I can get result from command-line sourcekitten. @Dan2552 Have you made any progress in the past months?

BTW @joenewbry I don't understand what do you mean by using -sdk, as we are facing problem with sourcekittendaemon, not sourcekitten itself.

@SyberToto

I haven't tried SourceKittenDaemon since my original posting of the issue as to be honest once I started working out what the arguments etc were I figured I could just use SourceKitten directly. My end result was a Sublime Text plugin: https://github.com/Dan2552/SourceKittenSubl - maybe an adapter for SKD will be put in at some point.

I believe the arguments are the same for SKD though, so hope this helps you.

You can see in my implementation how I call on SourceKitten here
https://github.com/Dan2552/SourceKittenSubl/blob/master/src/source_kitten.py#L24
e.g.

-sdk "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"

Here's a complete example call to sourcekitten:

sourcekitten complete --text 'import UIKit; class Testing() { func aFunction() {  } }' --offset 51 -- -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -target armv7-apple-ios10.0 -j4

If you want to understand things deeper, this helped me a lot:
https://github.com/apple/swift/blob/beaf946d27c2199eebaf7a4c6d735cf80c5d8407/tools/SourceKit/docs/Protocol.md

Hi, I'm having the same problem too.
I don't know why, however, I found it occurs if the project uses CocoaPods to manage dependencies.
I hope this information would help somehow.

I'm having the same problem, even on michaelnew's fork that resolves most of the Swift 5 compatibility issues. On his fork everything seems to work as long as there is no .xcworkspace file. I think the underlying problem is that XCodeEdit does not have support for .xcworkspace files but I haven't tested with a project that includes an .xcworkspace that does not also have CocoaPods, so it may be an issue that is specific to CocoaPods.

UPDATE: For me at least, I seem to be running into issue #65 which I'm not sure why it was closed. After commenting out superfluous compiler flags (for the purposes of autocomplete) it worked.