Sunday, July 8, 2012

How to edit and debug Corona SDK projects in Eclipse

If you develop Lua projects you can use a Koneki product called LDT (Lua Development Tools)  for debugging your code. LDT is a customized Eclipse which help you debug and trace the execution of your Lua scripts. You may know that debugging Corona SDK projects is always a problem because you have only a command line tool for debugging. However by using LDT you can easily debug your Corona SDK projects and define breakpoints to stop the execution in a simulator and easily watch the values of your local or global variables. Here are a few simple steps to follow:


1- Download binary version of LDT from here 
2- Create a shortcut to Corona.Debugger.exe (usually in C:\Program Files\Corona Labs\Corona SDK\)
3- Download and include these 2 Lua files in your projects
4- Add the following line to top of your source code:
    The code simply activate debugging mode only when you run the project in Corona simulator.


    if (system.getInfo("environment")=="simulator") then
require("debugger")()
    end



5- Now in LDT import your lua project. Open it from original folder. To do so please click on File->New->Lua Project then fill in the following dialog box:


6- After inserting the project you will see the project files like the following image:

7- From the LDT menu select Run->Debug Configuration and then complete the fields just similar to what I have done for my Multi-Touch project. After finishing click on the close.


8- Now you are ready to debug. Just open one of the Lua files and put a normal Eclipse breakpoint anywhere you want. For executing the project you need to click on the debugger shortcut you created in Step 2. After running Corona SDK debugger, three windows will apear. Switch to the debugger window and key in run and then press ENTER. your Lua app will execute and LDT will stop on the breakpoint you set.

I learnt the above steps from Benjamin's video on YouTube. Many thanks to him for bringing debugging facility into Lua and Corona SDK. He explained the whole steps there but I had some problems in understanding some summary parts. Here I tried to share my experience in more details and a step by step manner with you in Windows environment. Hope you have no problem debugging your Corona project.

No comments:

Post a Comment