I want to create an iPhone/iPad applications using Corona SDK. But they should be compiled as 2 separate apps (for iPhone and iPad separate) – while keeping the same code base.
In Objective C I just created 2 separate targets for iPhone and iPad, defined a set of constants for both of them, added different images to each of the targets.
I would like to get the same behavior in Corona application. Is this possible? And how to do this?
I don’t know of any built-in way to do it but it’s fairly easy to create an IsTargetIPad() call and test against that in your code.
A slightly more advanced approach is to build a very primitive preprocessor where you run a script against your main files and set it to remove code blocks based on target. It adds the advantage of letting you put in all kinds of target-specific flags with no overhead. The process is simple: you code in one directory using special tokens that the preproc can catch and then to test/build you just run the preproc and have it copy the files out to two (or however many you want) folders dedicated to each target. You can do this with pretty much any basic scripting language.