Flutter 开发过程中,需要编写调试 Linux 平台相关的代码,下面介绍一下使用 VSCode 进行调试的相关配置。
在工程根目录下的 launch.json 中增加如下配置:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
{ "name": "Debug native", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/linux/arm64/debug/bundle/MyApp", // Path to your compiled Flutter Linux executable "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] }, |
注意 "program": "${workspaceFolder}/build/linux/arm64/debug/bundle/MyApp", // Path to your compiled Flutter Linux executable 根据项目的实际情况进行配置。
完整的配置如下:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
{ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Debug native", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/linux/arm64/debug/bundle/MyApp", // Path to your compiled Flutter Linux executable "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] }, ] } |
调试的时候,参考下图进行选择,选择的配置项目就是 "name": "Debug native",如下图:
