How to list an AIR app in the iOS Share Menu?

Opt In Image
Early bird offer on the ANE eBooks

 

Buy any Easy Native Extensions 2nd Edition package and get our $99 iOS + Android ANE Template completely free before the end of June 2015.

 

 

  • step-by-step guide to making your iOS extension in under an hour
  • library for data conversion between ActionScript and native code
  • tutorials
  • infographics
  • code included

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.

For an explanation of what an iOS app extension is and how it’s different from an ANE, have a look at the introduction to this tutorial: iOS App Extensions (plugins) for AIR apps

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.

Time

15-20 minutes

Step 1: Have an AIR app ready

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:

Step 2: Trick Xcode

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:

create an empty app in Xcode

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:

give your Xcode app the same id as your AIR app

Step 3: Create an iOS extension

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?

create a new Xcode target

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:

name your iOS extension

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:

the build iOS extension

Step 4: Embed the iOS Extension in your AIR app

First, locate the .appex file on the disk (you can right-click the .appex file under Products in Xcode and select Show in Finder):

copy the iOS extension from the Xcode project

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:

copy the iOS extension into your app packaging folder

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:

include the iOS extension in your AIR app package

When your IPA is packaged, it should contain the PlugIns folder with the .appex file inside it.

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:

inside the AIR app

 

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.

Step 5: Check out your app in the Share Menu

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:

your AIR app appears in the iOS 8 Share Menu

Note: As the purpose of this tutorial is to see how we can integrate an iOS app extension into an AIR app, we will keep things simple and stop here. To handle the file share you will need to add a bit of code to your app extension. Apple’s Share tutorial shows you how.

What’s next?

.


Warning: count(): Parameter must be an array or an object that implements Countable in /home/easyna6/public_html/easynativeextensions_wp/wp-includes/class-wp-comment-query.php on line 399

Comments

  1. Tom

    First, thanks for the tutorial!
    I can’t get it work though – after I added the .appex to the PlugIns folder the .ipa won’t install on my device anymore – error: “application verification failed”

    Do I need to sign the .appex with a provision profile or something?
    I never used Xcode before so I might be possible that I missed something ovious?

    • Radoslava

      Hi Tom,

      In my experiment I left the appex target set to “Don’t code sign”.

      Could you try the following and see if you can get more details on your issue: with your iOS device plugged in open Window > Devices in Xcode. Select your device on the left. In the right pane you should see information about your device, a list called Installed Apps (which may be empty) and a log at the bottom. If the log is not visible, open it by clicking the little button with the arrow in the bottom left. Try installing your app on the device by clicking the + sign under Installed Apps and see what comes out in the log. It may make it easier if you clean the log just before you attempt the install, so you don’t have to comb through tonnes of system messages.

      Let us know what you find out,
      Radoslava

  2. Michael

    Great one!
    Can you please upload the source files (Xcode / AIR), I would really like to check them out.
    Maybe that way I can get it to work for my app. :-)

    Cheers
    Michael

  3. Steven

    Superb tutorial, thanks!
    Can you please make another one on how to invoke an iOS AIR app from the Share Menu?
    Currently I only get the small iOS default share dialog to show up.

    Many thanks
    Steven

  4. Arti

    Hi,

    I’m trying to make this work, I’ve followed your steps accurately, however I couldn’t make it work so far, it just wont appear as an option in the share menu. I got no errors though, but it just wont show up.

    Any ideas of what I could be doing wrong?. Do you happen to have an example code or something like that so I can check?.

    Thanks.

  5. Leo

    Hi,

    I followed the tutorial to the letter. But the app is not showing on the “Share” menu or on the … screen. However, if I simply run the “fake” app that we had to create in order to trick XCode, then I do get my app extension to display properly.

    Is there any compiler flags, or Plist additions or InfoAdditions that I need to add in order to make this work?

    Any help is much appreciated.

    p.s. I’m trying in iOS 10.0.2…Compiling with XCode 8.1 beta 2. And as mentioned, if I compile the fake App, I do get the correct result.

Trackbacks

  1. […] 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.For an explanation of what an iOS app extension is and how it’s different from an ANE, have a look at the introduction to this tutorial: iOS App Extensions (plugins) for AIR apps  […]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">