Corona on-device debugging with ZeroBrane Studio

ZeroBrane Studio has supported Corona SDK debugging for over a year, but one of the less known features of the integration is that it supports on-device debugging in addition to debugging in the simulator.

Since you can't initiate this process from the IDE, it requires slightly different steps:

1. You need to include the debugger component (mobdebug.lua) with your application code (to allow require 'mobdebug' command to execute successfully). You can find it under lualibs/mobdebug in ZeroBrane Studio folder.

2. You need to include require('mobdebug').start("IP-address-of-computer-running-ZBS") in your code. Note that with "regular" debugging you simply include require("mobdebug").start(), but in this case you need to provide a domain name or an IP address of the computer with the IDE as this is where the debugger in the application will connect to.

3. You need to start debugger server in the IDE by going to Project | Start Debugger Server.

4. If you do debugging on Android devices, you may need to add android.permission.INTERNET permissions to the build settings, as documented here.

If you open your Lua files in the IDE and you run your application on the device, you should see the message in the IDE that debugging has started. Most of debugging functions should work (stepping, breakpoints and the stack view), but any function that requires loadstring (remote console, watches, or value tooltips) won't work and will cause a run-time error in your application.

If you want to protect yourself from those run-time errors, you may run the following command in the local console ide.debugger.options = {noshell = true, noeval = true}; this will disable remote console and watches/tooltip evaluations to avoid using loadstring in the debugger. This configuration will be in effect for any debugging started remotely and will reset when you start any debugging from the IDE itself.

A better fix would be to allow Corona SDK to support loadstring during debugging; you may upvote this feature request that asks Corona to implement this.

You should get a copy of my slick ZeroBrane Studio IDE and follow me on twitter here.

Leave a comment

what will you say?