Now that you've installed Studio and at least one of the native platform SDKs, you're ready to create and run an application on a device or simulator.
Create a project
The first step is to create a new Mobile App Project and select a starting template. The Titanium SDK supports two project types: Alloy and Classic. Alloy is an MVC framework that lets you develop applications in less time and with less code than is possible in a Classic project. In general, it's recommended you use Alloy for your projects.
To create a new project:
- In Studio, either:
- Press ⌘+N (Mac) or Ctrl+N (Windows) to open the project wizard dialog.
- Or from the menu bar, select File > New > Mobile App Project.
- Select Mobile App Project as the wizard type and click Next.
- On the Project Template page, select Default Alloy Project as the template type. Click Next.
- On the Project Location page, enter the following information:
- In the Project Name field, enter Hello.
- In the App ID field, enter com.example.hello. This format is called reverse domain notation. You must use your own domain before publishing your application to market, but for testing purposes a temporary domain is fine.
- Select one or more Deployment Targets. By default, Studio selects all available targets platforms that you have installed.
- Disable enable Axway Appcelerator Platform Services (defaults to enabled)
as we won't use this service for this app.
- Click Finish to create the project. By default, the application's configuration
file called
tiapp.xml
opens up in the TiApp Editor. You can close that file. - In the Project Explorer view, open index.xml located in the app/views folder.
When developing an app in Alloy, you create your UI declaratively using XML elements that, during compilations, are mapped to standard Titanium SDK objects. For instance, the default Alloy template includes a
<Label>
element that corresponds to a Label object. - In
index.xml
, change the text inside the<Label>
element fromHello, World
toHello, Titanium
. - Save your changes. Now we're ready to run the application.
Running the application
To run the application you select a target simulator, emulator, or device, and click Run. The targets available for you to test with depends on which native SDKs you previously installed. For this example, it's assumed you've installed XCode and are targeting an iOS simulator. If you are targeting Android, select an appropriate simulator, emulator or device from the Target menu.
- Select the project in Project Explorer.
- Make sure Run is selected in the Launch Mode drop-down.
-
From the Target drop-down, select an iOS simulator.
- Click Run. Your application will compile and launch in the iOS Simulator. Click
the Hello, Titanium label text. An alert dialog appears.
If you run into problems running your application, see Studio Troubleshooting.