When you use ionic serve
to run your application in the browser, your browser’s DevTools can be used to debug your app. You can:
When testing a Debug build of your app on emulators, simulators or real devices with ionic cordova run ios|android
or similar (like ionic cordova emulate
or after distributing a test version built with ionic cordova build
via a third party beta distribution service), your app is not running directly in a browser any more. It is executed in the WebView of Cordova.
Fortunately, you can set up development devices for remote debugging with your desktop browser to use the debugging functionality as well.
Remote Debugging for Android happens with the Chrome DevTools you are already familiar with from usage on desktop. It can be used with a physical Android device or Android emulator.
Chrome of course works on all platforms like Windows, macOS or Ubuntu Linux.
android-tools-adb
package with apt-get
Settings > Developer Options > Enable USB Debugging
Settings > System (Android 8+ only) > About phone > Tap Build number 7 times
.Now Chrome on your desktop machine should discover your device and the WebView inside your app:
⠇> More tools > Remote devices
in a running DevTool instance)By clicking “inspect” next to your WebView you can now open the DevTools for your app and use all its usual functionality. You will also see a “Screencast” of your app next to the DevTools panels for navigating your app and selecting elements.
Your first stops will probably be the “Console” and “Network” tabs to look for warnings or errors that can tell you why your app is not looking or behaving like it should.
macOS offers Safari Web Inspector as the tool to remote debug iOS apps on physical iOS devices but also simulators. You use the Safari Develop menu to find your app and start the debugging session.
Safari is unfortunately only available for macOS and can not be installed on Windows or Ubuntu Linux.
Settings › Safari › Advanced
on your iOS device and enable the Web Inspector.Preferences › Advanced
in Safari on your Mac. Check “Show Develop menu in menu bar” option at the bottom.Window > Devices and Simulators > Devices
).Now Safari on your Mac should be able to see your app running on your device:
Develop
menu in Safari, and select your device:
It will open a Web Inspector window for your app, showing the usual developer tools functionality, hovering over elements in the “Elements” view will highlight them on the device.
Your first stops will probably be the “Console” and “Network” tabs to look for warnings or errors that can tell you why your app is not looking or behaving like it should.