Objective
In this section, you will about the testing and debugging tools provided as part of the Xcode environment.Contents
The iOS SDK provides various tools that are useful for debugging Objective-C based apps. There are fewer options for debugging your Titanium apps. In this section, we'll take a look at how to view log output within Xcode, view device logs, and view crash logs. We'll introduce, but not dig too deep into the Instruments tool. We'll cover it in more depth in another section.Viewing log output in Xcode
You can view log output within Xcode. This includes the same information output to the Titanium Studio console. Viewing the Xcode (gdb) console is useful if you build your Titanium app from within Xcode to set project-specific parameters, build options, and so forth. (Keep in mind that you lose Titanium's i18n string handling if you build via Xcode.) It would also be useful when debugging a native iOS module for Titanium.To view log output in Xcode:
- Build your project via Studio, then close the simulator
- Open yourproject/build/iphone/yourproject.xcodeproj (e.g. KitchenSink.xcodeproj) in Xcode.
- Build & run the project within Xcode. Log output is shown in the GDB (GNU DeBugger) pane, as illustrated in the following screenshot.
Viewing log output on a connected device
A more useful technique would be to view the logging messages that are generated by an app running on a USB-connected iOS device. You can do this via the Console view in the Xcode Organizer. The console displays Titanium logging messages, plus iOS system messages that might provide additional useful information.To view the console of a connected device:
- Connect your device.
- Build & deploy the app to the device using Studio.
- Sync using iTunes.
- Open XCode and display the Organizer window.
- Select the Devices tab, expand your device and select Console.
- Open your app and you'll be able to view Titanium logging messages among the other output in the console.
Viewing crash logs on a device
You can view crash logs generated when an app running on your device crashes. That data is not hugely useful for debugging Titanium apps because it will include native object related logging messages, not Titanium logging output. That crash data will be tied to the Titanium module (object) that was involved with running your code rather than your JavaScript. This sort of logging information would be most useful when debugging a native iOS module for Titanium.To view the crash log of a connected device:
- Connect your device.
- Open XCode and display the Organizer window.
- Select the Devices tab, expand your device and select Device Logs.
- In the list of available log files, select your app. There might be more than one file for your app, one for each time it has crashed.
This was truly awesome. thanks so much for this!! iOS Online Course
ReplyDelete