swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
713 stars 47 forks source link

Does not create `swift: Build Debug` task or launch.json. #723

Closed ResourceHog closed 4 months ago

ResourceHog commented 4 months ago

Describe the bug I am unable to run a swift application in the debugger because the require launch.json and tasks are not added to vscode by the extension. image

To Reproduce Steps to reproduce the behavior:

  1. install swift extension
  2. swift package init
  3. Click on Run and Debug tab
  4. Click Run and Debug blue button

Expected behavior Should compile and run the code. Environment

adam-fowler commented 4 months ago

swift package init does not create a package that builds an executable. Did you mean swift package init --type executable? Also the dialog you posted above implies a launch.json was created as it is asking for a particular executable.

At startup the build tasks are disabled until package loading, resolve and test listing has completed. Do you have any spinners in the footer bar.

ResourceHog commented 4 months ago

I had tried to create my own launch.json and tasks with no success. I tried recreating the package with swift package init --type executable and it seems to have created a launch.json and some task correctly that time.

However, when I try to run the program with a simple print statement it seems like there is nothing being printed to console nor is it accepting inputs.

image

I expected there to be a "hello, world!" in the console followed by "What's your name" then it should wait for input. However what however the console only briefly opens and closes. I was able to take this screenshot thanks to a breakpoint it shows nothing was written to console.

I had read that it's actually the xcode debug console that this is supposed to be written to but, vscodes equivalent doesn't seem to have the right content on it.

ResourceHog commented 4 months ago

Reposting this here. This may be a bug in LLDB? https://github.com/apple/swift/issues/72374#issuecomment-2002003680

adam-fowler commented 4 months ago

Yes this is a bug in LLDB. There is a fair amount of discussion about it in #309. I'm going to close this as a duplicate