This repository was archived by the owner on Nov 17, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 447
Add VS Code extension article #251
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| --- | ||
| title: NativeScript Extension for Visual Studio Code | ||
| description: How to install, set up and use the NativeScript extension for Visual Studio Code. | ||
| position: 11 | ||
| slug: nativescript-extension-for-visual-studio-code | ||
| --- | ||
|
|
||
| # NativeScript Extension for Visual Studio Code | ||
|
|
||
| 1. [Installation](#installation) | ||
| 2. [Debugging](#debugging) | ||
| 1. [Generate launch configurations](#generate-launch-configurations) | ||
| 2. [Launch an application with debugger](#launch-an-application-with-debugger) | ||
| 3. [Attach the debugger to an already running app](#attach-the-debugger-to-an-already-running-app) | ||
| 4. [Debug TypeScript](#debug-typescript) | ||
| 5. [Supply additional arguments to the debug command](#supply-additional-arguments-to-the-debug-command) | ||
| 6. [Turn on debugging protocol diagnostic logging](#turn-on-diagnostic-logging) | ||
| 3. [Use NativeScript-specific commands](#use-nativescript-specific-commands) | ||
| 4. [NativeScript CLI Version Detection](#nativescript-cli-version-detection) | ||
|
|
||
| ## Installation | ||
|
|
||
| To install the [NativeScript extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=Telerik.nativescript) open the Command Palette (`F1` or `Cmd+Shift+P`) and run `Extensions: Install Extension` command, then search for 'NativeScript' and choose it from the list. | ||
|
|
||
|  | ||
|
|
||
| After the installation completes, the extension appears in the list of installed extensions. You can see it if you run `Extensions: Show Installed Extensions` command from the Command Palette. | ||
|
|
||
| ## Debugging | ||
|
|
||
| Open your application root folder, created with the `tns create` command, in Visual Studio Code. | ||
|
|
||
| ### Generate launch configurations | ||
|
|
||
| Click the debugging icon  in the View bar, and then click the gear icon  to choose the NativeScript debug environment. A `launch.json` file should be generated in your `.vscode` folder located next to the `app` folder. The configurations, described in `launch.json` can be selected from the menu in the Debug Panel. | ||
|
|
||
|  | ||
|
|
||
| ### Launch an application with debugger | ||
|
|
||
| Choose one of the launch configurations (e.g. `Launch on iOS Emulator`) and press the `Start` button next to the menu. This will run your app in the iOS emulator and attach the VS Code debugger. The app should break on the first JavaScript/TypeScript statement. More information about the debugging support in VS Code can be found in the [VS Code Debugging Guide](https://code.visualstudio.com/docs/editor/debugging). | ||
|
|
||
|  | ||
|
|
||
| ### Attach the debugger to an already running app | ||
|
|
||
| If you already have a NativeScript application running your Android or iOS emulator or device you can attach the VS Code debugger to it, without rebuilding and restarting the application. Just select the desired attach configuration through the debug configuration menu and press the start button. | ||
|
|
||
| ### Debug TypeScript | ||
|
|
||
| In case you are writing your app in TypeScript you have fully functional debugging support in Visual Studio Code. To debug TypeScript, make sure the TS compiler is producing source maps by setting `"sourceMap": true"` in your `tsconfig.json`. | ||
|
|
||
| > Using the [TypeScript plugin for NativeScript](https://github.com/NativeScript/nativescript-dev-typescript) is strongly recommended instead of manually setting up the TypeScript compiler options and build tasks. The plugin handles the creation of all the configuration settings and guarantees smooth integration with Visual Studio Code. | ||
|
|
||
| ### Supply additional arguments to the debug command | ||
|
|
||
| Under the hood, starting a particular debug configuration executes the `tns debug` command with various arguments. You can append additional arguments by supplying them in the `tnsArgs` property of a debug configuration definition in `launch.json`. For example if you add `"tnsArgs": "--log=trace"` in the `Launch on iOS Emulator` configuration, in the background VS Code will execute `tns debug ios --emulator --no-client --log=trace` command, which will give you more verbose information in the Debug Console. | ||
|
|
||
|  | ||
|
|
||
| ### Turn on diagnostic logging | ||
|
|
||
| If the `diagnosticLogging` flag for a particular debug configuration in `launch.json` file is set to `true` (its default value is `false`), diagnostic messages will be logged on the debugger console after attaching the debugger to the NativeScript application. This is useful for rough debugging of the extension itself, because all sent/received messages which are part of the communication between the frontend and the backend are logged. | ||
|
|
||
| ## Use NativeScript-specific commands | ||
|
|
||
| Type `nativescript` in the Command Palette and you will see all NativeScript-specific commands. Currently there are only two of them but the list will grow in the future. | ||
|
|
||
|  | ||
|
|
||
| Run command is the equivalent to `tns run` in the NativeScript CLI. It lets you build, deploy and run your app on emulator/device directly from Visual Studio Code. | ||
|
|
||
| ## NativeScript CLI Version Detection | ||
|
|
||
| The extension is depending on a globally installed NativeScript CLI. It will show an error message if it can't find it. | ||
|
|
||
|  | ||
|
|
||
| > The extension requires a specific NativeScript CLI version and if you have another version installed, you will see a warning message. The extension is likely to work with the unsupported version but it is recommended that you update the NativeScript CLI or the VS Code extension. | ||
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.
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.
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.
Binary file added
BIN
+31.1 KB
img/visual-studio-code-extension/nativescript-not-found-error-message.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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something's wrong with the numbering here. This should work fine in the output but consider fixing the source.