This tutorial shows you how to get an AIR app to appear in the iOS 8 Share Menu, using an iOS app extension. Something to keep in mind before we begin: an iOS app extension is different from an ANE.
At the end of this tutorial you will have:
An AIR app for iOS that is extended to show in the iOS 8 Share Menu.
Note: The focus of this tutorial is to see how an iOS app extension can be integrated in an AIR app, rather than how to code it. For that purpose we have picked the simplest possible scenario and you will notice it won’t require you to write a line of native code. If you need something more elaborate, leave a comment below.
- Step 1: Have an AIR app ready
- Step 2: Trick Xcode with a native app
- Step 3: Create an iOS app extension
- Step 4: Embed the iOS extension in your AIR app
- Step 5: Check out your app in the Share Menu
Yeah, I know, you already have one. That’s why you are here.
For now just take a note of your app ID. Here is one I prepared earlier:
Xcode won’t let you create an iOS extension by itself. It needs to know about the app it will be extending. The good news is that you don’t need to do anything complicated here: create an app project in Xcode, give it the same app ID as your AIR app and that’s it.
Start Xcode and select File > New > Project…
In the wizard make your new project an iOS > Application > Single View Application:
Here is the most important thing you need to do: make sure your Xcode app has the same ID (Bundle Identifier) as your AIR app:
Not an AIR one. They should call them plugins really…
With your newly created Xcode project open select File > New > Target…
Tell the wizard you want an iOS > Application Extension > Share Extension for the purposes of this tutorial. Notice how this Application Extension option was not available earlier, before we had an app in the project?
In the next step of the wizard name your iOS Extension. Under Embed in Application you should be able to select the fake app you created earlier:
For this iOS extension to work you don’t need to do anything else, just tell Xcode to build it: Product > Build. This should produce an .appex (Application Extension) file:
First, locate the .appex file on the disk (you can right-click the .appex file under Products in Xcode and select Show in Finder):
Next, locate the folder where your AIR app will be packaged. If you are using Flash Builder to package it for you, this would be the bin-debug folder of your Flash Builder project.
Crucial detail: in your app packaging folder create a new folder, name it PlugIns and copy the .appex file in it:
Last, make sure the PlugIns folder is included in the IPA package. If you are using a build script you may need to modify it (or leave a comment below if you want me to send you one). If however you are packaging from Flash Builder (or a similar IDE), set this in your app’s Project > Properties > Flex Build Packaging > Apple iOS > Package Contents:
To have a look inside, rename your .ipa to .zip, unzip it, open the Payload folder that appears, right-click the package that’s inside it and select Show Package Contents. This should show you what your app is made of:
Why did I decide the .appex file should go in there? I euthanised and dissected a native app with an extension I made in Xcode and checked how iOS extensions are packaged in it.
On your iOS device go to a file you may want to share, for example a photo. Show the Share menu and tap the More button. Your AIR app should now appear in the list of apps for sharing. Enable it and tap Done. Your AIR app should now appear in the Share menu:
- Part 3: How to launch your AIR app from the iOS 8 Share Menu
- Part 4: Sharing files between an AIR app and an iOS Extension
- Part 5: How to debug your iOS extension