This document describes how to debug Titanium applications using an Emulator or Simulator.
To Debug on Android Emulator or iOS Simulator
- Create a new project (or import an existing one).
- Open up your project's
app.js
file by expanding "Resources" and double clicking on the filename. - Set some breakpoints in your app.js by double clicking in the left margin of the text editor (See Adding a breakpoint).
- Make sure your project is selected in the Project Explorer view.
- In the global tool bar, select Debug from the Launch Mode drop-down list.
- Select the Android emulator or iOS simulator you want to launch your project on in the Target drop-down list.
- Click the Launch button.
- When Studio prompts you to switch to the Debug perspective, click Yes.
Any breakpoints you set should be hit when the app loads (or if they are in event listeners or separate files, when those execute). Some other things you should be able to do:
- Edit variables by clicking their values while inside a breakpoint.
- Add expressions to the Expressions view to see the value of free form JavaScript code (See Using the Expressions View).
- Set conditions on breakpoints by going to the "Breakpoints" view, right clicking on the breakpoint, clicking on "Properties", and hit the checkmark next to "Enable Condition".
- Click on various frames in the stack trace to see values of other variables in your call stack (See Using the Debug View).
To Debug a Specific Run Configuration
By specifying a run configuration, you can choose the iOS version of the emulator or simulator to test in, the screen size, and other options.
- Make sure your project is selected in the Project Explorer view.
- In the global tool bar, select Debug from the Launch Mode drop-down list.
- Select Debug Configurations... from the Target drop-down list.
- Select the OS or SDK version and device type or screen size you want to run on.
- Select a logging level. Log messages are only generated for the selected level and higher. For example, if Info is selected, no Debug level messages are generated.
- Click Debug to launch the debug session.