Closed dave256 closed 1 month ago
Hi @dave256 thanks for this. I think all your issues are centred on the fact the extension is failing to find lldb-dap.exe
. We need to work out why this is the case.
Although why it is looking for XCTest.exe is confusing. @plemarquand do you have any ideas?
I'm in the process of setting up a new dedicated Windows machine to try this out.
@dave256 it looks like we have a fix for this. Hopefully will have it released in the next day.
@adam-fowler yes, I saw the follow-post in the Swift forums. I will try it tomorrow or Saturday. I assume this is only for XCTest unit tests. I figured I'd teach the students the new Testing framework rather than XCTest if it was possible (rather than teach them the old way). when I try "import Testing" in a test file, VSCode can't find the module (even when I've installed the Swift 6 Toolchain). But again, if they can debug either style of tests, I (and they) will be thrilled as some of them used Swift Playgrounds on their iPad last semester and missed having a debugger (although I'm not certain they missed me forcing them to write unit tests.😁)
@dave256 Unfortunately swift-testing isn't in the open source Swift 6 toolchain yet, only in the Xcode 16 beta. However your students can try it out by adding it as an explicit dependency to your Package.swift:
.package(url: "https://github.com/apple/swift-testing.git", from: "0.11.0")
This new extension seemed to solve it looking for xctest.exe but the debugger still doesn't start.
Message 39 here has the details: https://forums.swift.org/t/vs-code-wont-run-swift-on-windows/72721/39
I can copy it here if you want.
@adam-fowler followed-up on the above Swift forum link. Still one more minor issue - the directory containing the xctest.dll file needs to be added to the PATH. Another update to this extension is planned that should alleviate the need to do that but I can confirm that adding that directory to the PATH worked. In my cases this is the directory I added to the PATH, rebooted, and it worked.
C:\Users\roger\AppData\Local\Programs\Swift\Platforms\6.0.0\Windows.platform\Developer\Library\XCTest-development\usr\bin64\
@dave256 Good stuff, @adam-fowler just put up and merged https://github.com/swiftlang/vscode-swift/pull/977 to add it to the PATH. I'm working on a follow on patch to do something similar for swift-testing as it looks like it needs it as well.
@plemarquand @adam-fowler I think I got the new Testing library to work although it took forever to build the first time (not surprisingly, especially given it had to build the testing package on this low-powered Windows laptop), but even an incremental build (adding another test) was very slow. At least VSCode recognized the @Test
macro and ran the test (and does stop at a breakpoint). I'll stick with XCTest for this fall semester. Thanks again for all your help.
@dave256 I just put up https://github.com/swiftlang/vscode-swift/pull/978 which should get swift-testing debugging working on Windows same as XCTest (without the need for you to add the path for XCTest.dll into your PATH).
Just to confirm, you got swift-testing tests running? It looked like in https://forums.swift.org/t/vs-code-wont-run-swift-on-windows/72721/41 they weren't working for you.
I agree the first time swift-testing compiles is slow on Windows. I believe it's related to its included macros. Subsequent builds after the first are faster, but definitely could stand to be quicker.
@plemarquand Thanks. I'll download the updated Swift extension when it's released, remove the added Path, and try it.
I did get swift-testing to work today. I may have not had it set up correctly in the Package.swift file before - I always get confused about the syntax for also adding the dependency inside the target. But yes, even the subsequent builds are a couple orders of magnitude slower than XCTest builds after adding a new test (but nothing compared to the initial build which needs to build Swift Testing). I'm fine with using XCTest this fall semester. If the speed seems fine on a more reasonable development computer that you have compared to the borrowed one I have to test with, I wouldn't worry about it too much. When the semester starts, I'll see how it works on a student computer or try it on one of the Windows computers in our computer lab next time I'm on campus and have time to get everything installed. I also posted a quick follow-up in the swift forums thread indicating I got the Swift Testing library working in VSCode.
@plemarquand I verified version 1.10.6 of the extension works without the need for the extra Path directory for the XCTest files. Thank you.
The discussion of this issue started here: https://forums.swift.org/t/vs-code-wont-run-swift-on-windows/72721/22
If you create a package on Windows 11 with
and then use VSCode to open the directory containing the package, you can run the package, but you can't debug the package.
I've tried this with the Swift 6 Toolchain (from the July 2nd build available on swift.org) but I also believe it doesn't work with Swift 5.10 release on swift.org.
If I right click in the gutter and choose to Debug the test, a Windows dialog pops up complaining "unable to find executable in the Swift\Platforms...\xctest.exe"
I turned on the Swift extension setting to "Output additional diagnostics to the Swift Output View" and this is what appears there when I right click in the gutter for the XCTestCase subclass and choose to debug.
Note the file
C:\Users\roger\AppData\Local\Programs\Swift\Toolchains\6.0.0+Asserts\usr\bin\lldb-dap.exe
does actually exist despite the error saying it failed to find it.
Choosing the Run menu's Start Debugging has me then choose lldb and then it complains and creates a launch.json file.
Choosing run again doesn't work, but I assume something must be put in place of
<executable file>
for theprogram
setting but I'm not certain what to put there.If I make a package with
and then choose the menu Run -> Start Debugging, I can debug that and it stops at breakpoints showing the values of variables, etc.
Expected behavior It should debug a package that is a standard library package.
Environment
swift --version
): 6.0-dev (but I believe I had the same issue with 5.10)If you need any more information I'm happy to provide it as I'd like to get this working by the end of August for use in a class since some of my students have Windows computers. I have a Mac so I'm not very familiar with Windows or VSCode but have a borrowed Windows laptop I'm using to work on this.