swiftlang / vscode-swift

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

Swift tasks are not created when project has both cmake and swiftpm configurations #798

Closed xedin closed 2 weeks ago

xedin commented 1 month ago

Describe the bug

Attempting to open SwiftPM project in VSCode with both CMake and Swift extensions installed means that the project cannot be built.

To Reproduce Steps to reproduce the behavior:

  1. Clone git@github.com:apple/swift-package-manager.git
  2. Install Swift extension and CMake (+ tools) extension
  3. Open the project as a workspace
  4. Cmd-Shift-P -> Tasks: Run Task
  5. There is only one task there Resolve Dependencies
  6. Status bar button Build comes from cmake extension and pressing it results in failures

Expected behavior

Package manager configuration is preferred over CMake and tasks to build the project are generated correctly after first open.

Environment

adam-fowler commented 1 month ago

Tasks: Run Task will show you a list of recently run tasks, and a list of extensions contributing tasks. swift should be in that list. Click on it and it will list all the build tasks. Alternatively use Tasks: Run Build Task (Ctrl/Cmd+Shift+B) to get a list of build tasks regardless of whether they have been run.

xedin commented 1 month ago

I see, When I tried to add swift build task it created a new tasks.json file. I guess the only problem here is related to CMake build that happens automatically and results in failures as soon as workspace is opened.

adam-fowler commented 1 month ago

You shouldn't need to add a tasks.json unless you are doing something out of the ordinary. The Swift extension will provide tasks to build debug or release versions of every target. You should be able to see this list with Cmd + Shift + B. These are only available though once the initial project load and resolve has finished.

xedin commented 1 month ago

The UI there might be confusing then because if that action is already available why even add tasks.json?

adam-fowler commented 1 month ago

As I said in the previous comment you don't need to as the extension generates the build tasks for you.

xedin commented 1 month ago

I am simply trying to explain what happens, I didn’t direct it to create that file, it just does probably because cmake configuration shadows one from package manager, I don’t know.

adam-fowler commented 1 month ago

Sorry I misunderstood. When you say "I tried to add swift build task", what did you do exactly? You shouldn't need to add a build task. They are generated for you. And you use Tasks: Run Build Task to access the list of build tasks. If you click on the cog at the right hand side of the menu it will create a tasks.json but you should not need to do that. You can just select the tasks and it'll run.

award999 commented 1 month ago

FWIW you are able to hit the configure (gear) button for the list of provided task presented when running the Tasks: Run Task command which will place the current configuration in the tasks.json and you can modify from there. So you are able to add and modify build task configurations. @xedin is that how you were trying to add a build task or were you going through some different steps?

adam-fowler commented 2 weeks ago

closing as we've had no response