swiftlang / vscode-swift

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

Provide a setting to disable SPM integration #678

Closed tristanlabelle closed 6 months ago

tristanlabelle commented 6 months ago

Is your feature request related to a problem? Please describe. The Swift extension attempts to integrates SPM builds and discovers tests for the test explorer even in a repo that uses CMake (which the Swift extension doesn't know how to discover tests for). This results in a visible error in the test explorer:

image

The repo in question has both SPM and CMake build definitions. SPM is used for macOS and CMake for Windows, so there isn't an easy way for the extension to figure out automatically which one it should prefer.

Describe the solution you'd like A new swift.spmIntegration boolean setting that can be set to false (for example in a repo's settings.json) to completely disable all SPM-related features of the Swift extension (build and testing).

Describe alternatives you've considered We can ignore the error.

Additional context May be related to https://github.com/swift-server/vscode-swift/pull/638

adam-fowler commented 6 months ago

Would it not be preferable to recognise when we have a CMake project and disable it at that point.

tristanlabelle commented 6 months ago

Recognizing a CMake project could be useful, but I think we still need this escape hatch. For example, our project uses SPM on macOS and CMake on Windows, so the extension's heuristic for behavior could be incorrect. And what if we had a Bazel project?

I think this is a more general problem where the Swift extension provides functionality orthogonal(ish) areas, and projects should be able to turn them off piecemeal if they do not apply (in our case, because the functionality is provided by a different extension):

adam-fowler commented 6 months ago

679 limits the activation of the test explorer and test discovery based on if package is a SwiftPM project with test targets or is not a SwiftPM project.

Do you still need to disable the test explorer after this? ie you have a SwiftPM project with test targets which you don't want the test explorer for.

tristanlabelle commented 6 months ago

@adam-fowler This is a good change but we still need the ability to configure the Swift extension to disable the test explorer, and actually to disable all SPM-related logic. Our project has both CMake build definitions (used on Windows) and SPM build definitions (used on macOS). When working on Windows, no SPM-specific functionality should be enabled.

adam-fowler commented 6 months ago

It sounds like you want a prefer CMake over SwiftPM toggle.

adam-fowler commented 6 months ago

It sounds like you want a prefer CMake over SwiftPM toggle.

Or maybe a disable SwiftPM integration flag.

tristanlabelle commented 6 months ago

Or maybe a disable SwiftPM integration flag.

That sounds right!

tristanlabelle commented 6 months ago

I updated the issue title and description accordingly.

adam-fowler commented 6 months ago

680