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.
- Step 1: Create an App Group
- Step 2: Provision your app
- Step 3: Add entitlements to your app
- Step 4: Add entitlements to your extension
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:
- Part 1: What are iOS Extensions?
- Part 2: How to list an AIR app in the iOS Share Menu
- Part 3: How to launch your AIR app from the iOS 8 Share Menu
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.
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:
If you are editing an existing App ID, the App Services list looks like this:
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.
When App Groups are enabled and configured for your app, you should see this when you open your App ID:
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:
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:
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
- Part 5: How to debug your iOS extension