Save time debugging hardware JS apis with RhoMobile 4.0 and Weinre

Version 1

    You may have started to look at our upcoming RhoMobile Suite 4.0 release now it beta form and see that we have a strong focus on Javascript as well as making our API set more consistent and less redundant when it comes to hardware level API's - whether you are writing consumer style apps or applications for the Enterprise. One area I have seen beta testers stumbling on is trying to get their JavaScript code running on a device. Usually they try and use the API's, like Barcode, on RhoSimulator or a OS Emulator and it just is not supported. Once this is realized, then then put their application on a device and start to try and sift through the Rholog.txt file. Well this log usually contains a whole bunch of other information from the System and Framework level and can get frustrating to look at if you just want to see your JavaScript specific messages and possible issues.


    The problem usually falls into the following categories

    Build Scenarios

    1) rhoapi-modules.js not properly inserted into their HTML/ERB views

    2) Not including the right combinations of build.yml settings. Did you know that the rhoapi-modules.js file is dynamically built based on your application settings and target operating system? For example, you may have expected the 'Sensor' API to be included in a default project setup, but you actually have to include 'Sensor' in your build.yml extensions list. If you did not include that, then the rhoapi-modules.js file will not include the Rho.Sensor object and you will get a lot of 'null references' JS errors.


    Coding Issues

    1) Improper use of the API - trying to access a method or callback parameter that does not exist

    2) An actual bug in our code - yes it is beta ;-)


    There is a much better to realize these issues as well as learn about the API's without having to write a lot of code - enter Weinre.


    Weinre allows you to use the web developer tools that you are most comfortable with for 'typical' web pages...but remotely from your laptop to your device.




    - Remote debugging of your application running on a real device

    - Check to make sure you have properly included the Rho JS APIs

    - Inspect objects that are returned from callbacks

    - Try any API you wish to make sure you have the syntax and expected returns right before you start your coding efforts


    Setup Overview:

    - Install Weinre

    - Create a basic project in RhoStudio

    - Add one line linking to the Javascript library on the Weinre server in ytour HTML or Layout.erb

    - Get your laptop and device on the same WiFi network

    - Launch your app on the device and remotely debug/inspect it from your browser running in your laptop.


    Watch the tutorial on how to use this tool in conjunction with RhoMobile 4.0