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

Builtin "swift build" command invalidates cache for global command #24

Closed LinusU closed 6 years ago

LinusU commented 6 years ago

Whenever I save a file in an SPM project, swift build will automatically be run. After that has happened, running swift test from my terminal rebuilds all dependencies and the source.

This is not the case if I just run swift build and then swift test straight from my terminal.

I can also see the issue in reverse, that is, after I have run swift build or swift test from the terminal, the build time is much longer in VS Code.

This leads to the very annoying workflow that I save a test file, then wait for everything to be rebuilt from scratch in VS Code, then finally run swift test which again rebuilds everything from scratch, and then runs the tests.

Happy to provide any more information that might be relevant ☺️

vknabel commented 6 years ago

Thank you for opening the issue. I have experienced this myself, too. I guessed that /usr/bin/env swift is not exactly the same swift SDE used as I usually use swiftenv, but SDE does not and I have a global config for that. Although I have never validated this assumption.

It would be awesome if you could play a bit around with the swift.path.swift_driver_bin-setting or even debug a bit because I won't have enough time this week.

LinusU commented 6 years ago

Hmm, the only swift I'm using is /usr/bin/swift, as far as I know I don't have multiple versions installed.

The strange thing is, as far as I can tell, this package just spawn(swiftBinPath, ['build']) and I've just set swiftBinPath to /usr/bin/swift. It should be exactly the same, but for some reason, the cache gets invalidated 🤔

Will try to investigate some more...

vknabel commented 6 years ago

That seems strange. Maybe there are some relevant differences within the environment? Maybe setting the path to the expansion of /Applications/Xcode.app/**/bin/swift helps? But besides that, I’ve got no idea yet.

vknabel commented 6 years ago

@LinusU I could not find a solution on this by now. As a workaround we could add a new setting to allow passing a custom build path if this issue becomes too big.

This would additionally help others who want to automatically build their tests like https://github.com/jinmingjian/sde/pull/32, too.

vknabel commented 6 years ago

The workaround landed in 2.4.0.