Closed svanimpe closed 6 years ago
@svanimpe thank you for your feedback! Seems like the whole domain is down. I will add some documentation here on Github in order to avoid this case.
Regarding the debugger:
Swift Debug
(if not, simply copy the json into your launch.json
)The launch.json
should now contain something similar to
{
"version": "0.2.0",
"configurations": [
{
"type": "swift-debug",
"request": "launch",
"name": "Swift Program Debug",
"program": "${workspaceRoot}/.build/debug/path-to-program-debugged"
}
]
}
configurations.program
path to the name of your target to be tested.Hmm. I did this but every time I try to launch, I get the following error: "Debug adapter process has terminated unexpectedly". In the extensions output window, I see:
(node:45788) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'getThreads' of null
(node:45788) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.(node:45792) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'getThreads' of null
(node:45792) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
My launch.json
file:
{
"version": "0.2.0",
"configurations": [
{
"type": "swift-debug",
"request": "launch",
"name": "Debug Program",
"program": "${workspaceRoot}/.build/debug/swift-test"
}
]
}
@svanimpe the file you are providing must exist.
The debugger currently works best for executables. In case of the Sourcery project you would nee to provide ${workspaceRoot}/.build/debug/sourcery
krzysztofzablocki/Sourcery/Package.swift#L7.
If you are interested in debugging your unit tests, it is not explicitly supported by now, but depending on your environment it may actually work https://github.com/jinmingjian/sde/issues/27.
In any case swift build
must have been run before (should happen automatically while editing swift files) and swift test
must have run if you are trying to debug your tests.
The file does exist. I can execute it just fine on the command-line. I assume ${workspaceRoot}
is the project's root directory (where Package.swift
is)?
@svanimpe In case your manifest is located at ~/org/project/Package.swift
and you open code ~/org/project
then ${workspaceRoot}
would be ~/org/project
, but if you would code ~/org
then ${workspaceRoot}
would only be ~/org
.
Is the project you are working with open source? In that case I could try it on your project myself.
Yes I've opened the project's main folder in VS Code, not a parent or subfolder.
My project is simply hello world (swift package init --type=executable
) to which I've added that launch file you suggested.
I have also tried using an explicit path (without using ${workspaceRoot}
) with no success.
@svanimpe I did try it on my machine, but it worked. I am running the latest Xcode and tried it with Swift 4.0 and 4.0.2. Are you using linux?
$ mkdir swift-test
$ cd swift-test
$ swift package init --type=executable
Creating executable package: swift-test
Creating Package.swift
Creating README.md
Creating .gitignore
Creating Sources/
Creating Sources/swift-test/main.swift
Creating Tests/
$ code .
$ pbpaste > .vscode/launch.json # with your file copied
# Now I set a breakpoint in `Sources/swift-test/main.swift` on the first line
# When I ran the debugger it stopped at line 1
That is exactly what I did, but it doesn't work for me. I get the error listed above.
I am using Xcode 9.1. I also have Swift 4.0.2 installed from swift.org. My VS Code is version 1.18.0
I did not forget you, but I couldn't reproduce it yet.
@svanimpe I just released 2.1.2 which might fix your issue. I still couldn‘t reproduce your issue, but by looking at the code I could find a case, that may lead to this behavior.
If this doesn‘t fix the issue for you, let me know.
Nope, still Debug adapter process has terminated unexpectedly
. I no longer see the the UnhandledPromiseRejectionWarning
, but debugging still doesn't work.
Do I need up update sourcekite as well? I've only reloaded the plugin to get version 2.1.2.
@svanimpe There is no new update for sourcekite
, but maybe it helps.
@svanimpe As stated in Debugging-Swift-in-VS-Code I deprecated the debugger as there is a better and more stable alternative called LLDB Debugger.
Hope this solves the debugging problems.
Edit: moved location of example to vknabel.com
In your Quick Preview, you show the debugger in action. How can I get this working? The link to the hands-on introduction (http://blog.dirac.io/2017/01/11/get_started_sde.html) is broken.