On 9th September Apple revoked the restrictions for technologies that are allowed to be used for creating iPhoneOs (iOS) applications. This means that you can use Flash, Unity3D, Titanium Developer or any other tools to make an mobile application for Apple devices.
As a result of this decision Adobe will resume work on Packager for iPhone which has been on hold since April this year (as a result of sections 3 of iOS Developer Program license).
Latest version of the packager has been released on 11th October, so let’s give it a try.
This approach for developing iPhone / iPad / iPod applications is a great way to reuse you ActionScript code but there are some Flash features that are not available or are known not to work properly – see ‘Known Issues’ section and ‘Packager for iPhone developer guide’ on Adobe Labs to be aware of those limitations.
There are two ways of creating native iOS applications with Adobe Flash platform:
- using Adobe Flash CS5
- using Packager for iPhone from the command line
Create iPhone / iPod / iPad application – step by step
1. Download ‘Packager for iPhone’ (PFI). Flex SDK is also required.
2. PFI requires 32-bit Java runtime environment, be sure to have it installed.
3. Create and Adobe Air project using ActionScript, not MXML.
In FlashDevelop create ‘AIR AS3 Projector’ project.
In Flash Builder create ‘Flex Project’, but set the main application extension to ‘.as’.
4. Modify the Adobe Air application descriptor xml.
It should look something like this:
<?xml version="1.0" encoding="utf-8" ?> <application xmlns="http://ns.adobe.com/air/application/2.0"> <id>com.flashsimulations.mobile.ios.Hello</id> <version>1.0</version> <filename>HelloIOS</filename> <name>Hello iOS</name> <description>Just a test</description> <copyright>Piotr Koscierzynski</copyright> <initialWindow> <title>Hello iOS</title> <content>HelloIOS.swf</content> <systemChrome>standard</systemChrome> <transparent>false</transparent> <visible>true</visible> <minimizable>true</minimizable> <autoOrients>true</autoOrients> <resizable>true</resizable> <renderMode>gpu</renderMode> <fullScreen>true</fullScreen> <aspectRatio>portrait</aspectRatio> </initialWindow> <supportedProfiles>mobileDevice desktop</supportedProfiles> <iPhone> <InfoAdditions> <![CDATA[ <key>UIStatusBarStyle</key> <string>UIStatusBarStyleBlackOpaque</string> <key>UIRequiresPersistentWiFi</key> <string>NO</string> <key>UIDeviceFamily</key> <array> <string>1</string> <string>2</string> </array> ]]> </InfoAdditions> </iPhone> </application>
The descriptor is almost the same as the one for Android apps, but there are some differences
- iOS apps must use Air 2.0 (line 1), Android uses Air 2.5
- iOS apps use <version> not <versionNumber> for specifying version of application. But value should be in the same format – numbers only XX.XX.XX or XX.XX
- the information for operating system is defined between <iPhone> tag. This may look new, but those parameters are the same that can be found in Info.plist file when developing iOS apps in XCode. For full list of available options visit Information Property List Key Reference for UIKit e.g. UIDeviceFamily defines on which devices the application can run – 1 is for iPhone / iPod, 2 is for iPad.
5. Register in iPhone Developer Program. Get a certificate and provisioning profile from Apple ($99-$300 per year). You also need to convert the
certificate into a P12 certificate. See the “Obtaining developer files from Apple” section, page 4 of ‘Packager for iPhone developer guide’. This process could take few days or even a week (Apple needs to verify information you provided) and can be complicated.
There is a second – ‘non-Apple’ – way. Well, you don’t really need to buy anything, but you won’t be able to submit your application to AppStore and you won’t be able to test on the ‘non-jailbroken’ iOS device. All you have to do is to find a ’special’ certificate ‘.p12′ and ‘.mobileprovision’ files – Google will help you. Use those files to pack your application.
6. Configure and run the packaging batch ‘Package_iOS_Application.bat’ (if on Windows) or run the packager from the command line using this syntax:
pfi -package -target [ipa-test ipa-debug ipa-app-store ipa-ad-hoc] -provisioning-profile PROFILE_PATH SIGNING_OPTIONS TARGET_IPA_FILE APP_DESCRIPTOR SOURCE_FILES
7. Install you application on the device / submit to AppStore.
Adobe Air into native iOS – How does it work
The packager creates an native iOS application – it’s not Adobe Air application, because Apple forbids Just-In-Time compilation on their devices – that means no ActionScript Virtual Machine available – you won’t be able to run ActionScript code from external .swf files. Packager uses the LLVM compiler to translate ActionScript into Objective-C bytecode, it’s the same technology that’s behind Adobe Alchemy.