Sharing files between apps or an AIR app and an iOS extension

Although this article is presented as Part 4 of our 5-part iOS 8 Share Menu Tutorial, it is applicable to any combination of apps or iOS extensions that need to share resources or use interprocess communication. Here we go through the steps necessary to provision your apps to do just that.

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
The source code for this tutorial, complete with build scriptsis available here.

Time

10-15 minutes

Wait, have you done this first?

To do this part of the tutorial you will need:

  • an AIR app
  • an iOS Extension (plugin) that lists your AIR app in the iOS 8 share menu

If you haven’t got them yet, you can follow the previous three parts of this tutorial:

Step 1: Create an App Group

An App Group allows multiple apps to access shared disk space and use interprocess communication. Without an App Group enabled you can’t easily pass files by path between apps or between an app and an iOS extension, for example.

In this tutorial an App Group will give access your Share Extension and your AIR app to a folder, where one can save images and the other can read them from.

To create an App Group, go to https://developer.apple.com and log in the Member Center with your Apple ID. Open Certificates, Identifiers & Profiles and under Identifiers on the left select App Groups.

Click the + to create a new App Group and give the group an ID. I have called mine group.com.diadraw.AIRApp.sharing.

create an app group

Step 2: Provision your app

Now you need to enable App Groups for your app ID and create a provisioning profile. Under Identifiers on the left select App IDs and find your app in the list or create a new App ID if you haven’t got one yet.

If you are creating a new App ID, you will be presented with a list of App Services which you can enable:

enable app groups for your app

If you are editing an existing App ID, the App Services list looks like this:

enable app groups for an existing app

After you enable App Groups, you will need to configure them. In other words, you need to select the groups in which your app will have part. Select the group you created in Step 1.

assign a group to your app

When App Groups are enabled and configured for your app, you should see this when you open your App ID:

app woth App Groups enabled

Step 3: Add entitlements to your app

Open your AIR app descriptor (your-app-name-app.xml) and add the App Group ID you created to the com.apple.security.application-groups entitlement key. This goes in the iPhone.Entitlements section of the descriptor:

Step 4: Add entitlements to your extension

You will need to do the same for your iOS extension: in Xcode open your extension target, go to the Capabilities tab and turn on App Groups, then add the group ID you created in Step 1 and tick its box:

enable App Groups for the iOS extension

 

You are done. The changes will take effect after you rebuild both your iOS extension and your app. AIR app and iOS extension will now have a folder which they are both allowed to access. The path to it will look something like this: /private/var/mobile/Containers/Shared/AppGroup/D4A4F193-4125-406F-9A85-2B301F233D7E

What’s next?

The source code for this tutorial, complete with build scriptsis available here.

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. 1. how to know the path( /private/var/mobile/Containers/Shared/AppGroup/D4A4F193-4125-406F-9A85-2B301F233D7E) at air app?

    2.Will the path change when I install both apps(air app and ios app)?

  2. 1. how to know the path( /private/var/mobile/Containers/Shared/AppGroup/D4A4F193-4125-406F-9A85-2B301F233D7E) at air app?

    2.Will the path change when I reinstall both apps(air app and ios app)?

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="">