Improve Your Corona SDK Setup

This post will show you how you can quickly switch between different Corona projects. Furthermore, you will learn how you can switch between simulated devices quickly.

The Corona SDK Simulator

The Corona SDK comes with a simulator. During development you will use it a lot, especially when you develop for different target platforms. Corona can simulate these devices:

  • iPhone
  • iPhone4
  • iPad
  • Droid
  • Nexus One
  • myTouch
  • Galaxy Tab

Per default the simulator is installed in /Applications​/CoronaSDK​/Corona Simulator​.app. You can use the Corona Simulator App to try the examples which come with Corona. However, when you develop your app, you should start the simulator as described below.

Simulator Script

Corona SDK Simulator Settings

Corona installs also a shell script for your convenience: /Applications​/CoronaSDK​/simulator. This is needed to start the simulator from within Terminal. This has the great advantage that you will see the error messages while you test your app.

When you start the simulator through the simulator command you can pass in a skin and a project. With the skin option you tell Corona which device it should simulate. With the project option you tell Corona which project you want to open in the simulator.

Simulator Shortcuts

If you want to switch between simulated devices quickly it is convenient to have some shortcuts in place. Add these lines to your .bashrc file:

  # Corona SDK Settings
  export PATH=/Applications/CoronaSDK/:$PATH
  export CORONA_PROJECTS=~/projects/corona
  alias coronasim='simulator -project $(dirname $(find $CORONA_PROJECTS -type f -name \*.lua -print0 | xargs -0 ls -t | head -n 1))'
  alias iphone='coronasim -skin iPhone'
  alias ipad='coronasim -skin iPad'
  alias iphone4='coronasim -skin iPhone4'

The .bashrc file can be found in your home directory. Please be aware that normally you cannot see files in Finder which start with a dot. These will be hidden by Finder. Therefore, we open the file with the following command in Terminal:

  open /Applications/ ~/.bashrc

This will start the TextEdit app and open the .bashrc file automatically. Make the changes and then save.

Please, do not forget to adopt the CORONA_PROJECTS path to your needs. I store all of my Corona projects in one folder called ~/projects/corona. Only the projects beneath the CORONA_PROJECTS folder will be found by the new command aliases.

When you added the above lines issue this command in Terminal to make the changes to your .bashrc file effective: . ~/.bashrc

Now you can try to run the simulator with the simple command iphone. This will automatically open the last project you were working on by looking at the modification date of the .luafiles found in the folder CORONA_PROJECTS.

If you need to switch to a different simulated device you can go to Terminal and enter control-c to stop the running simulator. Then start a new simulator session with, for example, ipad.

Code, follow me on Twitter, subscribe to my RSS feed, and then relax.

Jo's Profile ImageWritten by Jo Meenen who lives and works in Frankfurt building digital doodah. Stalk him on Twitter