Monday, November 25, 2013

Setting Breakpoint Actions and Options

Setting Breakpoint Actions and Options

Specify what Xcode does when a breakpoint is triggered with the breakpoint editor.
  1. In the breakpoint navigator, Control-click the breakpoint, and choose Edit Breakpoint from the shortcut menu.
  2. Set the actions and the options for the breakpoint in the breakpoint editor.
    ../art/breakpoint-action-sound.jpg
    The screenshot shows a file line breakpoint that is ignored the first five times it is hit. Subsequent hits trigger the breakpoint, which causes Xcode to emit a sound and continue program execution.
Each breakpoint type has specific properties that define it, such as condition and ignore count (for file line breakpoints), symbol name (for symbolic breakpoints), and exception type (for exception breakpoints). But all breakpoint types share two properties:
  • Action: Specifies what actions Xcode performs when the breakpoint is triggered. You can have Xcode execute an AppleScript script or a shell or debugger command, log or speak a message, or emit a sound.
  • Options: Specifies additional breakpoint behavior, such as whether to continue program execution after performing actions.

OpenGL ES: Debugging a Frame on an iOS Device

OpenGL ES: Debugging a Frame on an iOS Device

Capture an OpenGL ES frame to analyze the OpenGL function calls that render the frame. Also view the OpenGL state at each OpenGL call.
  1. Run the app on an iOS device.
  2. In the debug bar, click the Capture Frame button.
    ../art/debugging_an_opengl_es_frame1_2x.png
  3. In the debug navigator, select an OpenGL ES call.
  4. In the content pane in the debug area, choose the type of OpenGL state information to list in the pane.
    ../art/debugging_an_opengl_es_frame4_2x.png
  5. Click the triangle to the left of the call.
  6. Examine the call stack to find the location of the call in the source code.
    ../art/debugging_an_opengl_es_frame6_2x.png

OpenGL ES: Previewing Changes to a Shader

OpenGL ES: Previewing Changes to a Shader

Preview changes to a shader program during a debug session.
  1. Run the app on an iOS device, and capture a frame.
  2. In the OpenGL call trace, select the OpenGL call you’re interested in.
  3. In an assistant editor jump bar, choose Bound GL Objects > Programs.
  4. From the first segment after the Programs segment in the assistant jump bar, choose the shader you want to modify.
  5. Modify the shader program code, and click Update Program.
    ../art/shader_code_change_2x.png
Making shader program modifications in a debug session lets you try several changes to find out which ones provide the best results. However, these changes are not reflected in the source code for the shader.
When you click Update Program, the GL objects reflect the effect of the change.
Resume app execution to see the effect of the change in the running app.
Use the OpenGL ES performance analyzer to measure the performance of the modified shader.

Install Android Developer Tools

 Install Android Developer Tools

3.1. Download packaged Android Developer Tools

Google provides a packaged and configured Android development environment based on the Eclipse IDE called Android Developer Tools. Under the following URL you find an archive file which includes all required tools for Android development: Getting the Android SDK.

Requirements for using a 64-bit Linux

2.2. Requirements for using a 64-bit Linux

The Android SDK is 32-bit, therefore on a 64-bit Linux system you need to have the package ia32-libs installed. For Ubuntu you can do this via the following command.

Requirements

 Requirements

2.1. System requirements

Development for Android can be done on a reasonably sized computer. For a nice experience a modern computer is recommended, for example, a 2.6 GHz CPU with at least 8 GB of memory. An SSD speeds up the start of the Android emulator significantly.

Thursday, November 21, 2013

1.3. Using CSS

The look and feel of a GWT application can be customized via CSS files. Each widget in GWT can be given a HTML "div" container and can therefore be individually styled by CSS. You use the Java method setStyle(String s) for this.

Modules, Entry Points and HTML pages

1.2. Modules, Entry Points and HTML pages

GWT applications are described as modules. A module "modulename" is described by a configuration file "modulename.gwt.xml". Each module can define one or more Entry point classes. An entry point is the starting point for a GWT application, similar to the main method in a standard Java program. A Java class which is an entry point must implement the interface "com.google.gwt.core.client.EntryPoint" which defines the method onModuleLoad().
The module is connected to a HTML page, which is called "host page". The code for a GWT web application executes within this HTML document.
The HTML page can define "div" containers to which the GWT application can assign UI components or the GWT UI components are simply assigned to the body tag of the HTML page.

1. Overview

1. Overview

1.1. Google Web Toolkit

The Google Web Toolkit (GWT) is a toolkit to develop Ajax web application with Java. The programmer writes Java code and this code is translated into HTML and Javascript via the GWT compiler.
The compiler creates browser specific HTML and JavaScript to support all the major browsers correctly. GWT supports a standard set of UI widgets, has build in support for the browser back button and a JUnit based test framework.
GWT provides two modes
  • Development Mode: allows to debug the Java code of your application directly via the standard Java debugger.
  • Web mode: the application is translated into HTML and Javascript code and can be deployed to a web server.

Wednesday, November 20, 2013

Low-power sensors

Low-power sensors


Sensor batching

Android 4.4 introduces platform support for hardware sensor batching, a new optimization that can dramatically reduce power consumed by ongoing sensor activities.
With sensor batching, Android works with the device hardware to collect and deliver sensor events efficiently in batches, rather than individually as they are detected. This lets the device's application processor remain in a low-power idle state until batches are delivered. You can request batched events from any sensor using a standard event listener, and you can control the interval at which you receive batches. You can also request immediate delivery of events between batch cycles.
Sensor batching is ideal for low-power, long-running use-cases such as fitness, location tracking, monitoring, and more. It can makes your app more efficient and it lets you track sensor events continuously — even while the screen is off and the system is asleep.
Sensor batching is currently available on Nexus 5, and we're working with our chipset partners to bring it to more devices as soon as possible.
 
Moves and Runtastic Pedometer are using the hardware step-detector to offer long-running, low-power services.

Step Detector and Step Counter

Android 4.4 also adds platform support for two new composite sensors — step detector and step counter — that let your app track steps when the user is walking, running, or climbing stairs. These new sensors are implemented in hardware for low power consumption.
The step detector analyzes accelerometer input to recognize when the user has taken a step, then triggers an event with each step. The step counter tracks the total number of steps since the last device reboot and triggers an event with each change in the step count. Because the logic and sensor management is built into the platform and underlying hardware, you don't need to maintain your own detection algorithms in your app.
Step detector and counter sensors are available on Nexus 5, and we're working with our chipset partners to bring them to new devices as soon as possible.

Storage access framework

Storage access framework


A new storage access framework makes it simple for users to browse and open documents, images, and other files across all of their their preferred document storage providers. A standard, easy-to-use UI lets users browse files and access recents in a consistent way across apps and providers.
 
Box and others have integrated their services into the storage access framework, giving users easy access to their documents from apps across the system.
Cloud or local storage services can participate in this ecosystem by implementing a new document provider class that encapsulates their services. The provider class includes all of the APIs needed to register the provider with the system and manage browsing, reading, and writing documents in the provider. The document provider can give users access to any remote or local data that can be represented as files — from text, photos, and wallpapers to video, audio, and more.
If you build a document provider for a cloud or local service, you can deliver it to users as part of your existing Android app. After downloading and installing the app, users will have instant access to your service from any app that participates in the framework. This can help you gain exposure and user engagement, since users will find your services more easily.
If you develop a client app that manages files or documents, you can integrate with the storage access framework just by using newCREATE_DOCUMENT or OPEN_DOCUMENT intents to open or create files — the system automatically displays the standard UI for browsing documents, including all available document providers.
You can integrate your client app one time, for all providers, without any vendor-specific code. As users add or remove providers, they’ll continue to have access to their preferred services from your app, without changes or updates needed in your code.
The storage access framework is integrated with the existing GET_CONTENT intent, so users also have access to all of their previous content and data sources from the new system UI for browsing. Apps can continue using GET_CONTENT as a way to let users import data. The storage access framework and system UI for browsing make it easier for users to find and import their data from a wider range of sources.
Most devices running Android 4.4 will include Google Drive and local storage pre-integrated as document providers, and Google apps that work with files also use the new framework.

Printing framework

Printing framework


Android apps can now print any type of content over Wi-Fi or cloud-hosted services such as Google Cloud Print. In print-enabled apps, users can discover available printers, change paper sizes, choose specific pages to print, and print almost any kind of document, image, or file.
Android 4.4 introduces native platform support for printing, along with APIs for managing printing and adding new types of printer support. The platform provides a print manager that mediates between apps requesting printing and installed print services that handle print requests. The print manager provides shared services and a system UI for printing, giving users consistent control over printing from any app. The print manager also ensures the security of content as it's passed across processes, from an app to a print service.
You can add printing support to your apps or develop print services to support specific types of printers.
Printer manufacturers can use new APIs to develop their own print services— pluggable components that add vendor-specific logic and services for communicating with specific types of printers. They can build print services and distribute them through Google Play, making it easy for users to find and install them on their devices. Just as with other apps, you can update print services over-the-air at any time.
Client apps can use new APIs to add printing capabilities to their apps with minimal code changes. In most cases, you would add a print action to your Action Bar and a UI for choosing items to print. You would also implement APIs to create print jobs, query the print manager for status, and cancel jobs. This lets you print nearly any type of content, from local images and documents to network data or a view rendered to a canvas.
For broadest compatibility, Android uses PDF as its primary file format for printing. Before printing, your app needs to generate a properly paginated PDF version of your content. For convenience, the printing API provides native and WebView helper classes to let you create PDFs using standard Android drawing APIs. If your app knows how to draw the content, it can quickly create a PDF for printing.
Most devices running Android 4.4 will include Google Cloud Print pre-installed as a print service, as well as several Google apps that support printing, including Chrome, Drive, Gallery, and QuickOffice.

OpenGL ES: Previewing Changes to a Shader

OpenGL ES: Previewing Changes to a Shader

Preview changes to a shader program during a debug session.
  1. Run the app on an iOS device, and capture a frame.
  2. In the OpenGL call trace, select the OpenGL call you’re interested in.
  3. In an assistant editor jump bar, choose Bound GL Objects > Programs.
  4. From the first segment after the Programs segment in the assistant jump bar, choose the shader you want to modify.
  5. Modify the shader program code, and click Update Program.
    ../art/shader_code_change_2x.png
Making shader program modifications in a debug session lets you try several changes to find out which ones provide the best results. However, these changes are not reflected in the source code for the shader.
When you click Update Program, the GL objects reflect the effect of the change.
Resume app execution to see the effect of the change in the running app.
Use the OpenGL ES performance analyzer to measure the performance of the modified shader.

OpenGL ES: Analyzing Rendering Performance

OpenGL ES: Analyzing Rendering Performance

Find performance issues in your OpenGL ES code.
  1. Run the app on an iOS device.
  2. In the debug navigator, select the FPS indicator to display the OpenGL ES performance analyzer.
  3. In the performance analyzer, click Analyze Performance.
The OpenGL ES performance analyzer shows GPU utilization and frame-rendering time information. It also provides guidance that helps you ensure that your app exhibits the desired FPS rate.
The analyzer lists the OpenGL calls involved in some of the performance issues it finds. Using an assistant editor, you can get to the function-call site to make the necessary changes.
Click the circled arrow that appears to the right of a call when you place the pointer on the call to view the corresponding GL object in the GL object viewer.
The screenshot shows the analyzer providing general guidance and ways to solve particular performance issues.
../art/performance_analyzer_with_issues_2x.png

Suspending a Thread

Suspending a Thread

Suspend a thread to prevent it from running during your debugging session. You might suspend a thread if the thread is about to crash or if you want to prevent it from doing work that could interfere with the rest of your application.

  1. Pause your application’s execution, or wait for it to hit a breakpoint.
  2. In the Debug navigator, Control-click the desired thread.
  3. In the contextual menu, choose Suspend Thread.

    ../art/debug_navigator-suspending_thread-a_2x.png
A suspended thread does not run when you step through your code or continue execution. The debug navigator places a red status icon next to suspended threads.

../art/debug_navigator-suspending_thread-b_2x.png

To resume a thread that is currently suspended, Control-click it and select Resume Thread from the contextual menu.


Related Articles

Focusing on Relevant Threads and Stack Frames

Focusing on Relevant Threads and Stack Frames

Filter threads and symbols to remove extraneous information and focus on your own code during a debugging session.
  1. Pause your application’s execution or wait for your code to stop at a breakpoint.
  2. Use the thread filter button to hide threads that are not relevant to debugging.
  3. Use the call stack slider to adjust the amount of detail shown for each thread.
The debug navigator sports two controls for filtering extraneous threads and program symbols: the thread filter and the call stack slider.
The thread filter button shows or hides threads that may not be relevant to debugging your code right now. Examples of such threads include the heartbeat and dispatch management threads and any threads that are idle and not currently executing any specific application code. Hiding these threads allows you to focus on the threads that are doing actual work for your application.
For each thread, the call stack slider dynamically collapses or expands the list of symbols displayed by that thread. Collapsing the list helps you focus your debugging efforts by hiding calls that are far removed from your code. (The presence of hidden symbols is indicated by a dotted line in the stack frame.) Expanding the list lets you see the precise set of calls that occurred to reach the current stopping point.
The screenshots show the debug navigator in two states. The screenshot on the left shows the debug navigator with the thread filter turned off and the call stack slider set to show all stack frames. The screenshot on the right shows it with the thread filter turned on and the call stack slider set to show only the most relevant stack frames.
../art/debug_navigator-filter_showcase_2x.png

Tuesday, November 19, 2013

Xcode 4.0 Developer Preview 5 Release Notes

Xcode 4.0 Developer Preview 5 Release Notes

New Features

General

  • The build action in the scheme dialog allows you to choose which targets should be built for each scheme action. 8025069
  • Each scheme action specifies the build configuration to use when Xcode performs that action as part of a build. Setting up a scheme with scheme actions that use particular build configurations allows you to, for example, set up a scheme that runs the product with the Debug configuration but profiles it with the Release configuration. 8090845
  • The Build and Archive command archives the products of the targets selected in the active scheme for archival, including their dSYM files. You submit your products to iTunes Connect using these archives. You can also use them to symbolicate crash logs. 7696041
  • The post-action scripts of archive scheme actions have access to information about the just-built archive in their environment:
    • ARCHIVE_PATH: The path to the archive.
    • ARCHIVE_PRODUCTS_PATH: The installation location for the archived product.
    • ARCHIVE_DSYMS_PATH: The path to the product’s dSYM files. 8423449
  • Xcode detects and enforces implicit build dependencies between targets when you build a scheme. You can turn this off per scheme in a scheme’s build action. 7879553
  • When the active scheme is a unit-test scheme, clicking Run in the toolbar produces an unknown error dialog.
    To run unit tests, choose Product > Test. 8642393
  • Fix-it is not supported in iOS application projects created using the new project dialog. The iOS project templates have the compiler set to LLVM-GCC, which does not support Fix-it.
    After creating an iOS project, set the compiler to LLVM 2.0. 8607314

Editing Core Data Models

  • You can create NSManagedObject subclasses from entities in a Core Data data model. 7484772

Refactoring

  • The Extract transformation is supported. 7711619

Compiling: LLVM 2.0

  • Blocks:Goto statements within blocks are allowed when the target is within the block. 7549164
  • Objective-C: Fixes bugs in exception handling present in LLVM 1.5. 8160285
  • You can declare instance variables in class implementations and extensions (iOS and 64-bit OS X). 7538989

Analyzing OpenGL ES Performance

  • The OpenGL ES Performance Detective identifies graphics bottlenecks in your iOS applications. It is located in <Xcode>/Applications/Graphics Tools. 8208239
  • Runs of the OpenGL ES Analyzer instrument can be saved in Instruments traces. 7993423
  • The OpenGL ES Analyzer instrument supports extended filtering of the OpenGL ES trace. 7976717
  • The OpenGL ES Analyzer instrument provides single-frame navigation, which allows you to focus all instruments on a specific OpenGL frame, and to step backward and forward in the trace frame by frame. 8552970

Enhancements

General

  • You can access the values of the build settings of the target being built through environment variables and launch arguments. When you create custom executables (by changing the value of the Executable setting in Run and Profile scheme actions), you can specify the target against which to expand the environment variables and launch arguments. 7546808

Editing Nib Files

  • Xcode suggests key path completions in the bindings inspector as you type. To take advantage of this feature, specify the class of object being managed by your controller in the attributes inspector.
    Xcode uses the project’s symbol index to generate the key path completions. 8176168

Editing Source Code

  • There’s an additional gesture to jump to a symbol definition in the source editor: holding down the Command key. When you hold down Command, Xcode represents the symbol under the pointer as a hyperlink; you can move the pointer between symbols until Xcode highlights the one you want to act on. You can then click the symbol to jump to its definition. Other modifies keys behave as expected. 8459719

Task Information and Alerts

  • The activity viewer presents more detailed information about scheme-related tasks, such as building a product. 7982481

Changes

Editing Nib Files

  • Hidden views are invisible in the Interface Builder canvas (they used to be partially visible in Interface Builder 3, part of Xcode 3).
    To work with these views, select them in the jump bar or the outline view. 8059339

Building: xcodebuild

  • The xcodebuild -activetarget option is no longer supported. 8361726

Resolved Issues

General

  • In General preferences, you can specify that Xcode ask you where to open a file you click or double-click while holding down an modifier key in a navigator. 8476034
  • Xcode automatically creates schemes for all targets in a project when you open an Xcode 3.x–based project. It doesn’t skip targets that other targets depend on.
    You can delete or hide schemes you don’t need in the manage schemes dialog. 8016676
  • Setting General preferences > Build Location > “Shared subfolder” to an absolute path doesn’t generate an assertion failure when opening projects. 8368913

Editing Nib Files

  • Many performance problems with making connections are resolved. In particular, the performance of connecting to the First Responder has been drastically improved. 8280101
  • You can create an Interface Builder–to–source connection even the target source code is folded. 8472539

Editing Core Data Model Files

  • When you create NSManagedObject subclasses from entities in a Core Data data model, Xcode ask for confirmation before overwriting existing files. 8506607

Editing Source Code

  • Breakpoints and message bubbles appear in the source editor even when code is folded above them. 7192871

Compiling: LLVM 2.0

  • C++: Several bugs related to using blocks are fixed. 6182276

Analyzing OpenGL ES Performance

  • API statistics in the OpenGL ES Analyzer instrument are computed correctly. 8549379

Help and Documentation Content

  • The list of help topics in a help book appears, as expected, when accessing help books in the documentation organizer. 8430699

New Issues

Comparing Versions of a File

  • After you create a branch and switch to it in the repositories organizer, using the commit dialog or the version editor causes an assertion failure.
    Restart Xcode after creating a branch and switching to it. 8383245

Known Issues

General

  • Interface Builder files with explicit Xcode 3 file types open in the source editor instead of in Interface Builder.
    Set the file type of the Interface Builder file in the Identity and Type inspector to “Default,” deselect it in the project navigator, and select it again. 8028406
  • The task log viewer is empty when you select the last build task of a project or workspace in the log navigator and the viewer is set to show only recent operations.
    Set the task log viewer to show all operations. 8350930

Editing Nib Files

  • Xcode cannot edit OS X–type Interface Builder documents comprised of objects from frameworks other than AppKit.
    You can compile and run these documents, however. 7470836
  • Refactoring: Xcode does not refactor Cocoa bindings. 8423815

Searching

  • Search navigator: Xcode may crash in the replace preview dialog of the search navigator when all the found instances are selected and you click Replace. 8091532

Refactoring

  • Xcode does not create a snapshot of your workspace before performing a refactoring transformation.
    Create manual snapshots before performing refactoring transformations. 7816256
  • Editing nib files: The Rename transformation may not work properly action methods in Interface Builder documents when the action’s target is the first responder or the method is declared in a category, protocol, or a superclass of the given class. 8500272

Source Control and Snapshots

  • Xcode doesn’t recognize SCP-based URLs for Git repositories in the Repositories organizer.
    Use the SSH-based URLs. For example, instead of git@example.com:/myrepositoryname.git usessh://git@example.com/myrepositoryname.git. 8044145

Building

  • Xcode doesn’t use a new build location after you change General preferences > Build Location.
    Close and reopen open projects and workspaces after changing the build location. 7965261

Help and Documentation Content

  • These help books are not listed on the Xcode Application Help page (Help > Xcode Application Help): Interface Builder Help, Task and Session Log Viewer Help, Symbol Navigator Help, and Xcode Concepts.
    Search for these titles in the Help menu or in the search navigator in the documentation organizer.