Exception Support in iOS Native Extensions

Up to AIR 3.3, it was not possible to handle exceptions inside the Cocoatouch Static Library in an ANE. AIR 3.4 onwards, it is possible to use the Objective C @try-@catch-@finally syntax inside one’s native library. The native developer can now also use C++ try-catch blocks successfully. The only thing to keep in mind while using exceptions in native code on iOS is that the exceptions should be handled inside the ANE itself. The AIR runtime will not catch the exceptions thrown by extensions.

You can download the latest AIR SDK with support for handling exceptions in a Native Extension  from  http://labs.adobe.com/technologies/flashplatformruntimes/

Installing/Uninstalling iOS AIR applications on iOS devices using ADT

With AIR 3.4, it would be possible to use ADT to install AIR applications on the iOS devices (i.e iPod, iPhone and iPad) from both desktop operating systems (i.e MAC and Windows). Prior to AIR3.4,  developers have to use iTunes, XCode etc to install the iOS AIR applications and that was a cumbersome process.

This new capability will make the install/uninstall process a lot more seamless. To install/uninstall an iOS AIR application on the device, simply follow the following instructions:

First of all, we need to know the number of devices, along with their device-id’s, which are attached to the machine. This can be done using the following ADT command.

adt -devices -platform ios
List of attached devices:
Handle	DeviceClass	DeviceUUID					DeviceName
   22	iPhone  	24d9b6fd...................a861117a7866510	myiPhone
   23	iPod    	24d9b6fd...................a861117a7866510	myIpod

The handle in the output of the above command is the device-id to be used to install/uninstall application in that particular device.

Once, we have the information about the devices attached to the machine we can use the following command to install the application on the device.

adt -installApp PLATFORM-OPTION PLATFORM-SDK-OPTION? DEVICE-OPTION? -package 
eg. adt -installApp -platform ios -device  <device-id>  -package /path/to/my.ipa

In case only one device is attached, there is no need to specify -device argument.

adt -installApp -platform ios -package /path/to/my.ipa

Similarly to uninstall the application from the ios device, use the following command line

adt -uninstallApp   PLATFORM-OPTION PLATFORM-SDK-OPTION? DEVICE-OPTION? -appid 
eg. adt -uninstallApp -platform ios -device <device-id>   -appid com.adobe.myapp

In case only one device is attached, there is no need to specify -device argument.

adt -uninstallApp -platform ios -appid com.adobe.myapp

NOTE:
<app-id> is specified in the application descriptor file (app.xml) within the <id> tag . If you create your project using Flash Builder, by default it would be the same as your app name.

Silencing audio on iOS with Ambient Audio Playback Mode

The aural experience of an application is just as impactful as the visual or gestural experiences. A good background score and sound control can be the making of a runaway hit, just as a bad one can ruin a perfectly great application. As a result, it’s very important to get the audio accompaniments of your application just right. In Adobe AIR, the SoundMixer.audioPlaybackMode property gives some control over the behavior of audio output. Now, in the upcoming Adobe AIR 3.4, the application developer has another option to fine tune audio output – the new Ambient AudioPlaybackMode. You can download Adobe AIR 3.4 beta from Adobe Labs.

Upto Adobe AIR 3.3, there were only two modes: Media and Voice. Both these modes play sound in a manner assuming that the sound is central to the operation of the application. In these modes, sound continues to play even when the application is in the background or if the screen is locked. Most importantly, sound played in these modes does not obey the hardware silent switch on iPhones and iPads.

The new Ambient AudioPlaybackMode in Adobe AIR 3.4  fills in the requirement for a sound that is just an accompaniment to your application, not its main purpose. On iOS, Ambient mode allows the user to silence your application by flipping the silent switch or locking the screen. To use Ambient mode, simply set the audioPlaybackMode property of the SoundMixer class to AudioPlaybackMode.AMBIENT.

import   flash.media.AudioPlaybackMode;
import   flash.media.SoundMixer;
SoundMixer.audioPlaybackMode  =  AudioPlaybackMode.AMBIENT;

Continue reading…

Xcode template for authoring ANEs

It just became easier to author AIR Native Extensions for iOS. An open source contribution has been made by someone that allows easier authoring of ANEs for iOS. The application is actually a template for Xcode that gives you a head start on ANE creation.

Make sure to try it out. Head over to project and documentation.

AOT or Interpreter

Traditionally, computer programs can be executed in three possible ways – interpreted, static (ahead-of-time) compilation and Just In time (JIT). In interpreted mode, the code is translated from high-level language to low level language during execution whereas in ahead-of-time compilation the high-level language code is converted to low-level machine code before hand. JIT (Just in time) compilation is a hybrid approach of the two. Here the code translation into native code occurs during the execution time and the translated code is cached so that this conversion need not be done every time. Obviously there is a small penalty when compared to ahead-of-time compilation as there is a cost associated with this translation.

After this brief introduction lets get into the Adobe AIR world and what is there in it for an iOS AIR developer. SWF content on all platforms other than iOS is JIT compiled, whenever possible. The swf is downloaded locally and JIT compiled where possible. Continue reading…