Generating Android and iPhone applications using FTL

Here we give a tutorial on how to:

This tutorial shows how EP can be used to describe a platform-variant family of applications. This is based on an infrastructure based on templates expressed in the Formal Template Language (FTL):

Importing the Example Project

Having installed Democles, download the LibraryBrowser example:

LibraryBrowser-example.zip

Import it into your workspace by choosing File→Import..., then selecting the General→Existing Project into Workspace option. After selecting the downloaded project archive and clicking Finish, the project will be available in the workspace.

Pre-generated Sources

We make pre-generated sources of this example project available for the benefit of those that want to try out the application or that want to see the generated ObjC resp. Java source code, without having to install Democles:

The LibraryBrowser

The LibraryBrowser application is a proof-of-concept mobile application that allows searching a virtual library. Using FTL-based code generation, it can be run on two popular mobile platforms:

Running the Android version

After the example project has been imported, follow these steps:

  1. Open the context menu of the LibraryBrowser project and choose Export.... Then choose Other→Democles Project using FTL. Click Next.

  2. Make sure the LibraryBrowser project is chosen, and the ANDROID target platform is selected:

    Click Next.

  3. Observe that for each Domain marked as a "Binding Domain", a corresponding template subcatalogue has been selected:

    Concepts in an EP Domain can only be mapped to implementations in their selected template subcatalogue. Click Next to proceed.

  4. The next wizard page shows the mapping of EP model concepts to template catalogue concepts:

    A working configuration is included with the example project. Choose a destination folder for the generated code, then click Finish.

    Note: The chosen destination folder should be located outside of your Eclipse workspace.

  5. Import the generated project into the workspace of an Eclipse installation configured with a working ADT (Android Development Tools) plugin and Android SDK using the File→Import...→Existing Projects into workspace wizard.

  6. Run the imported project by choosing Run As→Android Application from its context menu. The application's screens look as follows:

Running the iPhone version

After the example project has been imported, follow these steps:

  1. Open the context menu of the LibraryBrowser project and choose Export.... Then choose Other→Democles Project using FTL. Click Next.

  2. Make sure the LibraryBrowser project is chosen, and the IPHONE target platform is selected:

    Click Next.

  3. Observe that for each Domain marked as a "Binding Domain", a corresponding template subcatalogue has been selected:

    Concepts in an EP Domain can only be mapped to implementations in their selected template subcatalogue. Click Next to proceed.

  4. The next wizard page shows the mapping of EP model concepts to template catalogue concepts:

    A working configuration is included with the example project. Choose a destination folder for the generated code, then click Finish.

  5. Open LibraryBrowser.xcodeproj in the generated Xcode project on a system that has the iPhone SDK and Xcode installed.

  6. Choose Project→Set Active SDK→iPhone Simulator 3.x to set the used iPhone SDK version to one that is available on your system.

  7. Run the imported project by clicking Build and Go in Xcode's toolbar. The application's screens look as follows: