|
1 | 1 | # Commands
|
2 | 2 |
|
3 |
| -vscode-swift adds various commands to Visual Studio Code. |
| 3 | +Useful VS Code commands added by the Swift extension. |
4 | 4 |
|
5 |
| -The extension adds the following commands, available via the command palette. |
| 5 | +> 💡 Tip: Commands can be accessed from the VS Code command palette which is common to all VS Code extensions. See the [VS Code documentation about the command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) for a more in-depth overview. |
| 6 | +
|
| 7 | +The Swift extension adds the following commands, each prefixed with `"Swift: "` in the UI. |
6 | 8 |
|
7 | 9 | #### Configuration
|
8 | 10 |
|
9 |
| -- **Create New Project...**: Create a new Swift project using a template. This opens a dialog to guide you through creating a new project structure. |
10 |
| -- **Create New Swift File...**: Create a new `.swift` file in the current workspace. |
11 |
| -- **Select Toolchain**: Select the locally installed Swift toolchain (including Xcode toolchains on macOS) that you want to use Swift tools from. |
| 11 | +- **`Create New Project...`** - Create a new Swift project using a template. This opens a dialog to guide you through creating a new project structure. |
| 12 | +- **`Create New Swift File...`** - Create a new `.swift` file in the current workspace. |
| 13 | +- **`Select Toolchain...`** - Select the locally installed Swift toolchain (including Xcode toolchains on macOS) that you want to use Swift tools from. |
12 | 14 |
|
13 | 15 | The following command is only available on macOS:
|
14 | 16 |
|
15 |
| -- **Select Target Platform**: This is an experimental command that offers code completion for iOS and tvOS projects. |
| 17 | +- **`Select Target Platform...`** - An experimental command that offers code completion for iOS and tvOS projects. |
16 | 18 |
|
17 | 19 | #### Building and Debugging
|
18 | 20 |
|
19 |
| -- **Run Build**: Run `swift build` for the package associated with the open file. |
20 |
| -- **Debug Build**: Run `swift build` with debugging enabled for the package associated with the open file, launching the binary and attaching the debugger. |
21 |
| -- **Attach to Process...**: Attach the debugger to an already running process for debugging. |
22 |
| -- **Clean Build Folder**: Clean the build folder for the package associated with the open file, removing all previously built products. |
| 21 | +- **`Run Build`** - Run `swift build` for the package associated with the open file. |
| 22 | +- **`Debug Build`** - Run `swift build` with debugging enabled for the package associated with the open file, launching the binary and attaching the debugger. |
| 23 | +- **`Attach to Process...`** - Attach the debugger to an already running process for debugging. |
| 24 | +- **`Clean Build Folder`** - Clean the build folder for the package associated with the open file, removing all previously built products. |
23 | 25 |
|
24 | 26 | #### Dependency Management
|
25 | 27 |
|
26 |
| -- **Resolve Package Dependencies**: Run `swift package resolve` on packages associated with the open file. |
27 |
| -- **Update Package Dependencies**: Run `swift package update` on packages associated with the open file. |
28 |
| -- **Reset Package Dependencies**: Run `swift package reset` on packages associated with the open file. |
29 |
| -- **Add to Workspace**: Add the current package to the active workspace in VS Code. |
30 |
| -- **Clean Build**: Run `swift package clean` on packages associated with the open file. |
31 |
| -- **Open Package.swift**: Open `Package.swift` for the package associated with the open file. |
32 |
| -- **Use Local Version**: Switch the package dependency to use a local version of the package instead of the remote repository version. |
33 |
| -- **Edit Locally**: Make the package dependency editable locally, allowing changes to the dependency to be reflected immediately. |
34 |
| -- **Revert To Original Version**: Revert the package dependency to its original, unedited state after local changes have been made. |
35 |
| -- **View Repository**: Open the external repository of the selected Swift package in a browser. |
| 28 | +- **`Resolve Package Dependencies`** - Run `swift package resolve` on packages associated with the open file. |
| 29 | +- **`Update Package Dependencies`** - Run `swift package update` on packages associated with the open file. |
| 30 | +- **`Reset Package Dependencies`** - Run `swift package reset` on packages associated with the open file. |
| 31 | +- **`Add to Workspace`** - Add the current package to the active workspace in VS Code. |
| 32 | +- **`Clean Build`** - Run `swift package clean` on packages associated with the open file. |
| 33 | +- **`Open Package.swift`** - Open `Package.swift` for the package associated with the open file. |
| 34 | +- **`Use Local Version`** - Switch the package dependency to use a local version of the package instead of the remote repository version. |
| 35 | +- **`Edit Locally`** - Make the package dependency editable locally, allowing changes to the dependency to be reflected immediately. |
| 36 | +- **`Revert To Original Version`** - Revert the package dependency to its original, unedited state after local changes have been made. |
| 37 | +- **`View Repository`** - Open the external repository of the selected Swift package in a browser. |
36 | 38 |
|
37 | 39 | #### Testing
|
38 | 40 |
|
39 |
| -- **Test: Run All Tests**: Run all the tests across all test targes in the open project. |
40 |
| -- **Test: Rerun Last Run**: Perform the last test run again. |
41 |
| -- **Test: Open Coverage**: Open the last generated coverage report, if one exists. |
42 |
| -- **Test: Run All Tests in Parallel**: Run all tests in parallel. This action only affects XCTests. Swift-testing tests are parallel by default, and their parallelism [is controlled in code](https://developer.apple.com/documentation/testing/parallelization). |
| 41 | +- **`Test: Run All Tests`** - Run all the tests across all test targes in the open project. |
| 42 | +- **`Test: Rerun Last Run`** - Perform the last test run again. |
| 43 | +- **`Test: Open Coverage`** - Open the last generated coverage report, if one exists. |
| 44 | +- **`Test: Run All Tests in Parallel`** - Run all tests in parallel. This action only affects XCTests. Swift-testing tests are parallel by default, and their parallelism [is controlled in code](https://developer.apple.com/documentation/testing/parallelization). |
43 | 45 |
|
44 | 46 | #### Snippets and Scripts
|
45 | 47 |
|
46 |
| -- **Insert Function Comment**: Insert a standard comment block for documenting a Swift function in the current file. |
47 |
| -- **Run Swift Script**: Run the currently open file, as a Swift script. The file must not be part of a build target. If the file has not been saved it will save it to a temporary file so it can be run. |
48 |
| -- **Run Swift Snippet**: If the currently open file is a Swift snippet then run it. |
49 |
| -- **Debug Swift Snippet**: If the currently open file is a Swift snippet then debug it. |
| 48 | +- **`Insert Function Comment`** - Insert a standard comment block for documenting a Swift function in the current file. |
| 49 | +- **`Run Swift Script`** - Run the currently open file, as a Swift script. The file must not be part of a build target. If the file has not been saved it will save it to a temporary file so it can be run. |
| 50 | +- **`Run Swift Snippet`** - If the currently open file is a Swift snippet then run it. |
| 51 | +- **`Debug Swift Snippet`** - If the currently open file is a Swift snippet then debug it. |
50 | 52 |
|
51 | 53 | #### Diagnostics
|
52 | 54 |
|
53 |
| -- **Capture VS Code Swift Diagnostic Bundle**: Capture a diagnostic bundle from VS Code, containing logs and information to aid in troubleshooting Swift-related issues. |
54 |
| -- **Clear Diagnostics Collection**: Clear all collected diagnostics in the current workspace to start fresh. |
55 |
| -- **Restart LSP Server**: Restart the Swift Language Server Protocol (LSP) server for the current workspace. |
56 |
| -- **Re-Index Project**: Force a re-index of the project to refresh code completion and symbol navigation support. |
| 55 | +- **`Capture Diagnostic Bundle`** - Capture a diagnostic bundle from VS Code, containing logs and information to aid in troubleshooting Swift-related issues. |
| 56 | +- **`Clear Diagnostics Collection`** - Clear all collected diagnostics in the current workspace to start fresh. |
| 57 | +- **`Restart LSP Server`** - Restart the Swift Language Server Protocol (LSP) server for the current workspace. |
| 58 | +- **`Re-Index Project`** - Force a re-index of the project to refresh code completion and symbol navigation support. |
0 commit comments