vknabel / vscode-swift-development-environment

New home of Swift Development Environment for VS Code
https://marketplace.visualstudio.com/items?itemName=vknabel.vscode-swift-development-environment
Apache License 2.0
175 stars 14 forks source link

Cannot navigate around my code #107

Closed alexspurling closed 3 years ago

alexspurling commented 3 years ago

This is a two part issue. Firstly, there does not appear to be any documentation that lists the features of the extension, hence I don't know whether to file a bug or a feature request.

Secondly, when I ctrl click on a symbol, nothing happens. Instead, I would expect be navigated to where it is defined. This is a feature of the Javascript editor in VSCode for example.

Is this already a feature of this Swift extension? If so, I can provide more information to help debug my issue. Otherwise, please consider this a feature request.

vknabel commented 3 years ago

Hi @alexspurling!

As this extension supports different language servers for Swift, I don't explicitly document both. As both language servers rely on the same underlying driver, they might also share the same caveats or shortcomings.

Can you share your example project, settings, the used swift version and platform? That way I can best figure out why jump to definition does not work in your case.

In theory this feature exists, but only under certain circumstances

alexspurling commented 3 years ago

I think this is my settings.json file. For some reason I cannot see the values of all of the settings though so I assume they adopt some default value.

{
    "window.zoomLevel": 0,
    "files.autoSave": "onFocusChange",
    "files.trimTrailingWhitespace": true,
    "swift.path.sourcekite": "/home/alexs/apps/sourcekite/bin/sourcekite",
    "swift.path.swift_driver_bin": "/home/alexs/apps/swift-5.4.2-RELEASE-ubuntu20.04/usr/bin/swift",
    "swift.targets": [
        {
            "name": "MyMobileApp",
            "path": "MyMobileApp",
            "sources": [
                "**/*.swift"
            ],
            "compilerArguments": []
        },
    ]
}

I am using Ubuntu 20.04 and installed Swift from here: https://swift.org/download/

I installed sourcekite according to the instructions here, although as you can see I changed the PREFIX to "/home/alexs/apps/sourcekite": https://github.com/vknabel/vscode-swift-development-environment#using-sourcekite

I cannot share the actual project code. I also don't know how to create an example project. If you could suggest one for me to use however I could try it out.

Let me know if you need any more information.

vknabel commented 3 years ago

Hey @alexspurling

I probably won't have enough time try replicate your setup, but it might already help if you switch to using the Swift Package Manager.

In that case you don't have to explicitly define swift.targets.

That way the auto-build functionality should automatically work. This might be the reason why jump to definition does not work in your case.

Hope this helps!

alexspurling commented 3 years ago

Hi @vknabel how do I switch to using the Swift Package Manager?

vknabel commented 3 years ago

You can check this Introduction to swift package manager.

alexspurling commented 3 years ago

Thanks. Unfortunately, it won't be possible for me to change the project structure of our app as I don't have the required experience to do that. I inherited the project from an iOS developer team and don't want to make such drastic changes just to be able to get code navigation in my IDE.

In general, does the Swift VSCode extension work with iOS apps built with Xcode? Is it intended only for server side apps rather than iOS apps?

vknabel commented 3 years ago

This extension works best for command line tools and server side applications.

There are ways to make it work for very basic iOS development, but only on macs.