Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty complete response #52

Open
Dan2552 opened this issue Dec 15, 2016 · 5 comments
Open

Empty complete response #52

Dan2552 opened this issue Dec 15, 2016 · 5 comments

Comments

@Dan2552
Copy link

Dan2552 commented Dec 15, 2016

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.
@joenewbry
Copy link

joenewbry commented May 12, 2017

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/

@SyberToto
Copy link

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.

@Dan2552
Copy link
Author

Dan2552 commented Jun 15, 2017

@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

@fukamachi
Copy link

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.

@charshep
Copy link

charshep commented Mar 8, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants