VS Code でのデバッグ
このガイドでは、Tauri アプリのコアプロセスをデバッグするための VS Code の設定について説明します。
vscode-lldb 拡張機能をインストールします。
.vscode/launch.json ファイルを作成し、以下の JSON コンテンツを貼り付けます:
{ // IntelliSense を使用して、可能な属性について学習します。 // 既存の属性の説明を表示するには、ホバーします。 // 詳細については、https://go.microsoft.com/fwlink/?linkid=830387 をご覧ください。 "version": "0.2.0", "configurations": [ { "type": "lldb", "request": "launch", "name": "Tauri Development Debug", "cargo": { "args": [ "build", "--manifest-path=./src-tauri/Cargo.toml", "--no-default-features" ] }, // `beforeDevCommand` を使用する場合のタスク。`.vscode/tasks.json` で構成する必要があります "preLaunchTask": "ui:dev" }, { "type": "lldb", "request": "launch", "name": "Tauri Production Debug", "cargo": { "args": ["build", "--release", "--manifest-path=./src-tauri/Cargo.toml"] }, // `beforeBuildCommand` を使用する場合のタスク。`.vscode/tasks.json` で構成する必要があります "preLaunchTask": "ui:build" } ]}これは cargo を直接使用して Rust アプリケーションをビルドし、開発モードと本番モードの両方でロードします。
Tauri CLI を使用しないため、CLI 専用機能は実行されないことに注意してください。beforeDevCommand および beforeBuildCommand スクリプトは、事前に実行するか、preLaunchTask フィールドでタスクとして構成する必要があります。以下は、開発サーバーを生成する beforeDevCommand 用と beforeBuildCommand 用の 2 つのタスクを持つ .vscode/tasks.json ファイルの例です:
{ // tasks.json 形式のドキュメントについては、https://go.microsoft.com/fwlink/?LinkId=733558 をご覧ください "version": "2.0.0", "tasks": [ { "label": "ui:dev", "type": "shell", // `dev` はバックグラウンドで実行され続けます // 理想的には、`problemMatcher` も構成する必要があります // https://code.visualstudio.com/docs/editor/tasks#_can-a-background-task-be-used-as-a-prelaunchtask-in-launchjson を参照してください "isBackground": true, // これを `beforeDevCommand` に変更します: "command": "yarn", "args": ["dev"] }, { "label": "ui:build", "type": "shell", // これを `beforeBuildCommand` に変更します: "command": "yarn", "args": ["build"] } ]}これで、src-tauri/src/main.rs またはその他の Rust ファイルにブレークポイントを設定し、F5 を押してデバッグを開始できます。
Windows での Visual Studio Windows Debugger の使用
Section titled “Windows での Visual Studio Windows Debugger の使用”Visual Studio Windows Debugger は Windows 専用のデバッガーであり、一般的に vscode-lldb よりも高速で、列挙型などの一部の Rust 機能のサポートが優れています。
C/C++ 拡張機能をインストールし、https://code.visualstudio.com/docs/cpp/config-msvc#_prerequisites に従って Visual Studio Windows Debugger をインストールします。
{ // IntelliSense を使用して、可能な属性について学習します。 // 既存の属性の説明を表示するには、ホバーします。 // 詳細については、https://go.microsoft.com/fwlink/?linkid=830387 をご覧ください。 "version": "0.2.0", "configurations": [ { "name": "Launch App Debug", "type": "cppvsdbg", "request": "launch", // exe 名を実際の exe 名に変更します // (リリースビルドをデバッグするには、`target/debug` を `release/debug` に変更します) "program": "${workspaceRoot}/src-tauri/target/debug/your-app-name-here.exe", "cwd": "${workspaceRoot}", "preLaunchTask": "ui:dev" } ]}Tauri CLI を使用しないため、CLI 専用機能は実行されないことに注意してください。tasks.json は lldb と同じですが、起動前に常にコンパイルする場合は、構成グループを追加し、launch.json の preLaunchTask をそのグループに向ける必要があります。
開発サーバー(beforeDevCommand に相当)とコンパイル(cargo build)をグループとして実行する例を以下に示します。これを使用するには、launch.json の preLaunchTask 構成を dev(またはグループに付けた名前)に変更します。
{ // tasks.json 形式のドキュメントについては、https://go.microsoft.com/fwlink/?LinkId=733558 をご覧ください "version": "2.0.0", "tasks": [ { "label": "build:debug", "type": "cargo", "command": "build", "options": { "cwd": "${workspaceRoot}/src-tauri" } }, { "label": "ui:dev", "type": "shell", // `dev` はバックグラウンドで実行され続けます // 理想的には、`problemMatcher` も構成する必要があります // https://code.visualstudio.com/docs/editor/tasks#_can-a-background-task-be-used-as-a-prelaunchtask-in-launchjson を参照してください "isBackground": true, // これを `beforeDevCommand` に変更します: "command": "yarn", "args": ["dev"] }, { "label": "dev", "dependsOn": ["build:debug", "ui:dev"], "group": { "kind": "build" } } ]}© 2025 Tauri Contributors. CC-BY / MIT