You can debug NativeScript-Vue applications using the standalone version of Vue DevTools.
To simplify the integration, you can use the nativescript-vue-devtools
plugin which takes care of connecting your app to Vue DevTools.
Run the following command:
$ cd <project-folder>
$ npm install --save @vue/devtools nativescript-toasty nativescript-socketio nativescript-vue-devtools
nativescript-vue-devtools
plugin in your appTo connect your application to the Vue DevTools, you need to modify main.js
(or main.ts
).
In your code, import nativescript-vue-devtools
and tell NativeScript-Vue about it using Vue.use()
.
import VueDevtools from 'nativescript-vue-devtools'
import Vue from 'nativescript-vue'
Vue.use(VueDevtools)
Make sure you import devtools before Vue, otherwise it might not work as expected.
If you are using a real device instead of an emulator, set the host
configuration option to point to the IP of your development machine. Otherwise, your device will not be able to connect to your host machine.
Vue.use(VueDevtools, { host: '192.168.1.42' })
Run the following command in a new terminal to launch Vue DevTools:
$ npx vue-devtools
A window should open. Instructions shown in this window are not required in a NativeScript-Vue application, so please ignore them.
Run the following commands:
$ rm -rf platforms
$ tns run android
$ # or
$ tns run ios
If your machine and app are configured properly, you should see a few components in the component tree of Vue DevTools.
On Android API level 28 and above, cleartext traffic is disabled by default. In order to connect to Vue DevTools you will have to add android:usesCleartextTraffic="true"
to the App_Resources/Android/src/main/AndroidManifest.xml
file:
<application
<!-- ... -->
android:usesCleartextTraffic="true"
<!-- ... -->
</application>
After making the change, delete the platforms
folder, and rebuild the app. Vue DevTools should now connect automatically.