Skip to content

Tests not recompiled when using Xcode toolchain #1519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fatbobman opened this issue Apr 24, 2025 · 2 comments
Open

Tests not recompiled when using Xcode toolchain #1519

fatbobman opened this issue Apr 24, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@fatbobman
Copy link

Describe the bug
When using the Xcode Swift toolchain with the Swift for VSCode extension, I’ve encountered an issue where test code is not recompiled when running tests via the UI (either through the test sidebar or the inline test buttons). This leads to outdated or incorrect test results if the test implementation or any of its dependencies have changed.

This behavior is especially noticeable when the changes are made in modules or targets that the test code depends on — for instance, editing a function in a library target that’s imported by the test target. Despite such changes, running tests via the UI seems to bypass recompilation, resulting in stale binary execution.

Running swift test in the terminal, however, correctly triggers a rebuild and reflects all code changes.

Expected behavior
Tests should be recompiled whenever the test runner is triggered from the VSCode UI, particularly when changes have been made to modules or targets that the test code depends on — consistent with the behavior of swift test in the terminal.

Environment

  • OS: macOS 15.4.1
  • Swift version Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
  • Visual Studio Code version: Cursor 0.49.4
  • vscode-swift version: 2.2.0
@plemarquand
Copy link
Contributor

Does this issue still persist if you do View > Terminal > Building and Running Tests and copy and run the command used into a standalone terminal? The command should look something like /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift test --enable-xctest --disable-experimental-swift-testing -Xswiftc -diagnostic-style=llvm

@fatbobman
Copy link
Author

@plemarquand
I'm using a monorepo structure organized as follows:

MyProject/                  
├── .swiftlint.yml      
├── .vscode/settings.json 
├── Domain/
│   └── Package.swift
│   └── .vscode/settings.json
└── Persistent/
    └── Package.swift
    └── .vscode/settings.json

When I modify code in the Domain module (which is a dependency of the Persistent module) and then run tests by clicking the test button within Persistent, the tests are executed without recompiling sometimes , resulting in outdated test behavior based on the old code.

Image

However, when running /usr/bin/swift test directly in the terminal (also using the Xcode toolchain), it correctly triggers a full rebuild before executing the tests, and the updated code is reflected in the test results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

2 participants