Skip to content

Add interactive tutorial mode for Swift extension #1469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,28 @@
!assets/documentation-webview/**
!assets/swift-docc-render/**
!node_modules/@vscode/codicons/**

# Keep tutorial assets
!assets/tutorial/**

.vscode/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these lines aren't necessary, everything is ignored by default

.vscode-test/**
src/**
test/**
scripts/**
.gitignore
.github/**
.devcontainer/**
.eslintrc.json
.mailmap
.mocha-reporter.js
.nvmrc
.prettierignore
.prettierrc.json
.unacceptablelanguageignore
.vscode-test.js
tsconfig.json
tsconfig-base.json
package-lock.json
CONTRIBUTING.md
CONTRIBUTORS.txt
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The Swift extension is supported on macOS, Linux, and Windows. To install, first

### Language features

The extension provides language features such as code completion and jump to definition via [SourceKit-LSP](https://github.com/apple/sourcekit-lsp). To ensure the extension functions correctly, its important to first build the project so that SourceKit-LSP has access to all the symbol data. Whenever you add a new dependency to your project, make sure to rebuild it so that SourceKit-LSP can update its information.
The extension provides language features such as code completion and jump to definition via [SourceKit-LSP](https://github.com/apple/sourcekit-lsp). To ensure the extension functions correctly, it's important to first build the project so that SourceKit-LSP has access to all the symbol data. Whenever you add a new dependency to your project, make sure to rebuild it so that SourceKit-LSP can update its information.

### Automatic task creation

Expand Down Expand Up @@ -107,7 +107,7 @@ Use the **Run > Start Debugging** menu item to run an executable and start debug

LLDB DAP is only available starting in Swift 6.0. On older versions of Swift the [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) extension will be used for debugging instead. You will be prompted to install the CodeLLDB extension in this case.

CodeLLDB includes a version of `lldb` that it uses by default for debugging, but this version of `lldb` doesnt support Swift. The Swift extension will automatically identify the required version and offer to update the CodeLLDB configuration as necessary so that debugging is supported.
CodeLLDB includes a version of `lldb` that it uses by default for debugging, but this version of `lldb` doesn't support Swift. The Swift extension will automatically identify the required version and offer to update the CodeLLDB configuration as necessary so that debugging is supported.

### Test Explorer

Expand All @@ -123,6 +123,25 @@ Once your project is built, the Test Explorer will list all your tests. These te
* [Test Coverage](docs/test-coverage.md)
* [Visual Studio Code Dev Containers](docs/remote-dev.md)

## Tutorial Mode

The Swift extension includes an interactive tutorial to help you get started with Swift development in VS Code. The tutorial covers:

- Installing and configuring the Swift toolchain
- Creating your first Swift project
- Building and running Swift code
- Debugging Swift applications
- Writing and running tests
- Using Swift Package Manager

To start the tutorial:

1. Open the Command Palette (Cmd+Shift+P on macOS, Ctrl+Shift+P on Windows/Linux)
2. Type "Swift: Start Tutorial" and press Enter
3. Follow the interactive steps in the tutorial panel

The tutorial will guide you through each step with visual aids and hands-on exercises. You can create a sample project at any time using the "Swift: Create Tutorial Project" command.

## Contributing

The Swift for Visual Studio Code extension is based on an extension originally created by the [Swift Server Working Group](https://www.swift.org/sswg/). It is now maintained as part of the [swiftlang organization](https://github.com/swiftlang/), and the original extension is deprecated. Contributions, including code, tests, and documentation, are welcome. For more details, refer to [CONTRIBUTING.md](CONTRIBUTING.md).
Expand Down
Empty file added assets/tutorial/build-run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added assets/tutorial/debugging.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added assets/tutorial/testing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 16 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 97 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,18 @@
"title": "Run Tests with Coverage",
"category": "Test",
"icon": "$(debug-coverage)"
},
{
"command": "swift.startTutorial",
"title": "Start Swift Tutorial",
"category": "Swift",
"icon": "$(book)"
},
{
"command": "swift.createTutorialProject",
"title": "Create Tutorial Project",
"category": "Swift",
"icon": "$(folder-opened)"
}
],
"configuration": [
Expand Down Expand Up @@ -1610,6 +1622,87 @@
}
]
}
],
"walkthroughs": [
{
"id": "swift-tutorial",
"title": "Getting Started with Swift in VS Code",
"description": "Learn how to use Swift in Visual Studio Code",
"steps": [
{
"id": "toolchain-setup",
"title": "Install Swift Toolchain",
"description": "First, you need to install the Swift toolchain on your system.",
"media": {
"image": "assets/tutorial/toolchain-setup.png",
"alt": "Swift toolchain installation"
},
"completionEvents": [
"onCommand:swift.selectToolchain"
]
},
{
"id": "create-project",
"title": "Create Your First Swift Project",
"description": "Create a new Swift package using Swift Package Manager.",
"media": {
"image": "assets/tutorial/create-project.png",
"alt": "Creating a new Swift project"
},
"completionEvents": [
"onCommand:swift.createNewProject"
]
},
{
"id": "build-run",
"title": "Build and Run",
"description": "Learn how to build and run your Swift project.",
"media": {
"image": "assets/tutorial/build-run.png",
"alt": "Building and running a Swift project"
},
"completionEvents": [
"onCommand:swift.run"
]
},
{
"id": "debugging",
"title": "Debugging",
"description": "Set breakpoints and debug your Swift code.",
"media": {
"image": "assets/tutorial/debugging.png",
"alt": "Debugging Swift code"
},
"completionEvents": [
"onCommand:swift.debug"
]
},
{
"id": "testing",
"title": "Testing",
"description": "Write and run tests for your Swift code.",
"media": {
"image": "assets/tutorial/testing.png",
"alt": "Testing Swift code"
},
"completionEvents": [
"onCommand:swift.run"
]
},
{
"id": "package-manager",
"title": "Swift Package Manager",
"description": "Learn how to manage dependencies with Swift Package Manager.",
"media": {
"image": "assets/tutorial/package-manager.png",
"alt": "Using Swift Package Manager"
},
"completionEvents": [
"onCommand:swift.updateDependencies"
]
}
]
}
]
},
"extensionDependencies": [
Expand Down Expand Up @@ -1648,16 +1741,16 @@
"@types/chai-subset": "^1.3.6",
"@types/glob": "^7.1.6",
"@types/lcov-parse": "^1.0.2",
"@types/lodash.throttle": "^4.1.9",
"@types/lodash.debounce": "^4.0.9",
"@types/lodash.throttle": "^4.1.9",
"@types/mocha": "^10.0.10",
"@types/mock-fs": "^4.13.4",
"@types/node": "^20.17.27",
"@types/node": "^20.17.28",
"@types/plist": "^3.0.5",
"@types/semver": "^7.5.8",
"@types/sinon": "^17.0.4",
"@types/sinon-chai": "^3.2.12",
"@types/vscode": "^1.88.0",
"@types/vscode": "^1.98.0",
"@types/xml2js": "^0.4.14",
"@typescript-eslint/eslint-plugin": "^8.28.0",
"@typescript-eslint/parser": "^8.28.0",
Expand All @@ -1672,8 +1765,8 @@
"esbuild": "^0.25.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^10.1.1",
"lodash.throttle": "^4.1.1",
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
"mocha": "^10.8.2",
"mock-fs": "^5.5.0",
"node-pty": "^1.0.0",
Expand Down
18 changes: 16 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { checkAndWarnAboutWindowsSymlinks } from "./ui/win32";
import { SwiftEnvironmentVariablesManager, SwiftTerminalProfileProvider } from "./terminal";
import { resolveFolderDependencies } from "./commands/dependencies/resolve";
import { SelectedXcodeWatcher } from "./toolchain/SelectedXcodeWatcher";
import { SwiftTutorial } from "./tutorial/swiftTutorial";

/**
* External API as exposed by the extension. Can be queried by other extensions
Expand Down Expand Up @@ -92,7 +93,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<Api> {
context.subscriptions.push(...commands.registerToolchainCommands(toolchain));

context.subscriptions.push(
vscode.workspace.onDidChangeConfiguration(event => {
vscode.workspace.onDidChangeConfiguration((event: vscode.ConfigurationChangeEvent) => {
// on toolchain config change, reload window
if (
event.affectsConfiguration("swift.path") &&
Expand Down Expand Up @@ -265,6 +266,19 @@ export async function activate(context: vscode.ExtensionContext): Promise<Api> {
workspaceContext
);

// Register tutorial commands
const tutorial = SwiftTutorial.getInstance(context);
context.subscriptions.push(
vscode.commands.registerCommand("swift.startTutorial", () => {
tutorial.showTutorial();
})
);
context.subscriptions.push(
vscode.commands.registerCommand("swift.createTutorialProject", () => {
tutorial.createSampleProject();
})
);

// Mark the extension as activated.
contextKeys.isActivated = true;

Expand All @@ -288,6 +302,6 @@ export async function activate(context: vscode.ExtensionContext): Promise<Api> {

async function deactivate(context: vscode.ExtensionContext): Promise<void> {
contextKeys.isActivated = false;
context.subscriptions.forEach(subscription => subscription.dispose());
context.subscriptions.forEach((subscription: vscode.Disposable) => subscription.dispose());
context.subscriptions.length = 0;
}
Loading
Loading