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

Build problems win CLI Swift app [SOLVED] #28

Closed carlca closed 6 years ago

carlca commented 6 years ago
macOS 10.13.6
Swift 4.1.2
VSCode Version 1.25.0-insider (1.25.0-insider)
MSDE 2.4.3

Hello, I have setup my system following this guide https://forums.swift.org/t/vscode-settings-for-swift/12216 and as you can see it include MSDE.

I'm trying to debug a simple CLI Swift app which has the usual Swift folder structure. When I hit the green run button, the first thing I see is this message...

screen shot 2018-06-22 at 22 29 30

If I select the "Show Errors" option, I see this message...

screen shot 2018-06-22 at 22 31 47

If I select "Debug Anyway", I see these messages...

screen shot 2018-06-22 at 22 34 28

and

screen shot 2018-06-22 at 22 35 35

Either way, I don't seem to be able to debug my program.

This is my launch.json...

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "preLaunchTask": "swiftc with debug",
            "name": "Debug",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "sourceLanguages": [
                "swift"
            ]
        }
    ]
}

This is my tasks.json...

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "swiftc with debug",
            "type": "shell",
            "command": "swiftc -g ${file}",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "panel": "dedicated"
            }
        }
    ]
}

Both config files were as suggested by the https://forums.swift.org/t/vscode-settings-for-swift/12216 page.

Thanks in advance for any help you can give me.

Cheers, Carl

vknabel commented 6 years ago

Hi, thanks for opening this issue. The configs you posted will try to compile the currently opened file alone.

I'm trying to debug a simple CLI Swift app which has the usual Swift folder structure

So you have a SwiftPM project with a Package.swift file? In that case you can use the proposed set up from the README.md#debugging. These will build your SwiftPM project.

vknabel commented 6 years ago

On the MSDE plugin repo at Github, there appear to be two alternative macOS installation options for installing sourcekite. One is described as when using swiftenv or multiple Toolchains while the other is described as using Xcode's Toolchain.

Which one should I use? I suspect it's the latter option but I would like to be sure!

If you do not regular switch between different swift versions, picking the latter option was correct!

carlca commented 6 years ago

Thanks, Valentin! With your help, I've now got syntax-highlighting, program execution and debugging all working in VSCode. Yay! Congratulations on your victory against Sweden, by the way, but you left it a bit late, didn't you 😉

vknabel commented 6 years ago

Happy to help 👍

Congratulations on your victory against Sweden, by the way, but you left it a bit late, didn't you.

Thanks. The best comment on the game: https://twitter.com/GaryLineker/status/1010612676530196480

Football is a simple game, 22 men chase the ball for 82 minutes and the Germans get a player sent off so 21 men chase the ball for 13 minutes and at the end the Germans somehow fucking win.