Creating Mobile Apps with Appcelerator Titanium
上QQ阅读APP看书,第一时间看更新

Creating our project

Now that we have our module, we are finally ready to create our project. As with all of our previous projects, we need to set up a new project for our application. To do this, select the File | New | Mobile Project menu from Titanium Studio, and fill out the Wizard forms with the following information:

Project creation is covered in more detail in Chapter 1, Stopwatch (with Lap Counter); so, refer to this section if you want more information regarding project creation.

Adding the module to our project

Now that we have our newly created project and module downloaded, we can now make the two of them work together.

There are two ways in which we can install the modules, and depending on how you want to use it will determine the best setup that suits your needs. You can either:

  • Make the modules available to a single project
  • Make the modules available to all projects developed on a given machine

In our case, we want the module to be used with this project only. Therefore, we simply copy the module's archive file (ti.pageflip-iphone-X.X.X.zip) to our /Resources directory, and then build our project. From there, the Titanium build scripts will extract the module files and copy them to the appropriate directories within the project's hierarchy.

Another option is to extract the files ourselves and copy them at the root of our project. This will have the same effect as the previous method, without having to build the project. This is considered the old way of installing modules.

After the module is installed, we need to configure our application in order to actually use it. This is done by editing the <modules> XML section in our tiapp.xml file. We simply add the following line that identifies the module, its platform, as well as its version:

<modules>
    <module platform="iphone" version="1.8.2">ti.pageflip</module>
</modules>

Another more user-friendly way of configuring the application would be by using the dedicated graphical user interface from the tiapp.xml editor (by selecting the Overview tab). From there, we simply have to click on the plus sign (+) button and select the ti.pageflip module. The editor will then automatically detect the version and the supported platforms from the module's manifest.

Note

If the module installation was done by placing the archive (ZIP) file into the Resources directory, and then building the project, there is a very strong chance that the module will already be configured for you. The scripts are becoming more and more efficient with each new release. This is neat since it frees the developers from having "to guess" the required information.