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 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:
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.
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.
If you want to switch between simulated devices quickly it is convenient to have some shortcuts in place. Add these lines to your
# 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'
.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/TextEdit.app ~/.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 CORONAPROJECTS path to your needs. I store all of my Corona projects in one folder called
~/projects/corona. Only the projects beneath the CORONAPROJECTS 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:
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,
Posted on CuteMachine.