With Adobe AIR 3.3, support for native iOS simulator would be available for application development.
Prior to this feature, the only way to test AIR applications on iOS was to have an actual device along with a developer certificate from Apple. With simulator support now available however, there is no need to obtain a developer certificate (which is a time consuming process) or to create a provisioning profile before starting to develop an AIR application. A p12 certificate, which can be created by the developer himself would be sufficient.
Native simulator for iOS is very helpful in testing and debugging AIR applications. Because support for this enhancement is currently not available in Flash tooling, one could use the following adt commands below to use this feature .
Simulator for iOS is based on x86 architecture and therefore two new targets have been added in ADT to support the same.
To package application for simulator in any of the above targets, execute either of the following commands:
Test Interpreter Target
adt -package -target ipa-test-interpreter-simulator -storetype pkcs12 -keystore Certificates.p12 -storepass password Sample_ipa_name sample_ipa-app.xml sample_ipa.swf -platformsdk <path to Simulator SDK > eg. /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk
Debug Interpreter Target
adt -package -target ipa-debug-interpreter-simulator -connect -storetype pkcs12 -keystore Certificates.p12 -storepass password Sample_ipa_name sample_ipa-app.xml sample_ipa.swf -platformsdk <path to Simulator SDK >
If you observe carefully, you will find that for debug target I have not specified any IP address . This is so because simulator will always be launched on the local machine and therefore there is no need to specify an IP address.
Also note that it is essential to provide the -platformsdk switch and the path to the external iOS simulator SDK, while packaging an application for the Simulator, as the runtime doesn’t contain the required binaries for the Simulator.
Now if you have packaged your application, it is time to install it by executing the command given below:
To install application in simulator
adt -installApp -platform ios -platformsdk (path to sdk) -device ios-simulator -package sample_ipa_name.ipa
NOTE: This feature doesn’t work well with Xcode 4.3.2 . The problem arises because the latest version of Xcode is installed as a .app and this feature requires mobile framework to be there in /developer directory. As a workaround you would need to install an older version of Xcode too or wait for the release version of AIR.
After installing the application, try to launch and run it on Simulator using the command given below:
To launch application in simulator
adt -launchApp -platform ios -platformsdk (path to sdk) -device ios-simulator -appid Sample_ipa_name
The application can be uninstalled from the simulator directly through UI or if you want to uninstall it using command line then use the command below.
To uninstall application in simulator
adt -uninstallApp -platform ios -platformsdk (path to sdk) -device ios-simulator -appid Sample_ipa_name
NOTE: if you uninstalled the application using ADT command then application will get purged but its icon still keeps on showing on simulator . It will goes away once you restart the simulator.
Native Extensions and Simulator
I have already mentioned above that simulator on iOS is based on x86 architecture. To support native extension on simulator, a new platform name (iPhone-x86) has been added in extension.xml. All the commands to mention ane are similar to that with device, so I am not mentioning the commands for packaging. However, please note that for packaging native extension library.a file required from XCode should be compiled for simulator target . A typical extension.xml for simulator ane would look like below:
<extension xmlns=”http://ns.adobe.com/air/extension/3.1“> <id>com.cnative.extensions</id> <versionNumber>1</versionNumber> <platforms> <platform name=”iPhone-x86″> <applicationDeployment> <nativeLibrary>library.a</nativeLibrary> <initializer>TestNativeExtensionsInitializer</initializer> <finalizer>TestNativeExtensionsFinalizer</finalizer> </applicationDeployment> </platform> </platforms> </extension>