IOS 5 | How-To Create and Configure an iCloud IOS 5 app

iCloud is one the new features of IOS 5 with a lot of promise and real user payback with the growing number of devices we are all using. iCloud allows a user to share and sync their data from various apps between devices. Basically data is uploaded to servers on the Internet and vice versa downloaded updated locally when a device is connected. Apps can also share data amongst themselves, something that was a bit tricky beforehand.

This tutorial will walk you through the process of setting up iCloud to be used in a document based app and to share a simple document.

Authors Note: You need an IOS Developer Program to do this tutorial. They can be purchased from the Apple Developer web site.

Step 1 : Create a Provisioning Profile


Each app that you deploy to a device or the App Store requires a Provisioning Profile, regardless if you want to use iCloud or not. We also need a Provisioning Profile because you can’t test iCloud on the XCode Simulators, you need to deploy to a device: iPad, iPhone or iPod Touch. You also need a Provisioning Profile to enable iCloud.

Navigate to the Apple Developer Portal and click on Member Center. Click on the IOS Provisioning Portal link and click on the App ID tab to setup your app.

Access Member Center
Access Member Center

Click on the New App ID button. Enter a name for your app following the instructions on the page. For this tutorial, I used quickDox as an app name. Also enter a Bundle identifier; something like com.kevlangdo.quickDox. Click on the Submit button to save the App ID.


Create IOS App ID
Create IOS App ID

At the bottom of the App ID Manage tab you see you app in a grid with thew Push Notifications and Game Center enabled as well as the InApp Purchases enable. To enable iCloud for your app, click on the Configure button under the Action heading.

In the Configure App ID page, enable the iCloud service and click on the Done button to save your changes. That is it for enabling iCloud in the Provisioning Portal.

Configure iCloud in the Push Notifications.
Configure iCloud in the Push Notifications.
Enable iCloud in the IOS Provisioning Page
Enable iCloud in the IOS Provisioning Page

Next we need a Provisioning Profile proper. The first part of this step was to create an App ID and enable iCloud for that app. Click on the Provisioning tab. Click on the New Profile button, enter a name for the Provisioning Profile like quickDox iCloud Test App; Select a certificate, select the App ID that you set up in the first part of this Step and finally select a device or devices that you will use to test your app. If no device is available, you will need to set one up.

Create a new Provisioning Profile
Create a new Provisioning Profile
Fill in the Provisioning Profile Page
Fill in the Provisioning Profile Page

Click the Submit button to save you changes.

Back at the Provisioning Profiles page, under Actions for your new app, a download button will appear after a few minutes. You may need to refresh your page a few times. Download the Provisioning Profile when ready. Double click on the file to add the Provisioning Profile to your XCode Organizer.

Add Provisioning Profile to XCode Organizer
Add Provisioning Profile to XCode Organizer

Step 2 : Create iCloud Enabled App


Once the Provisioning Profile is created and configure in XCode, it is time to create our app and enable iCloud.

Select the Page View Application
Select the Page View Application
Create the Page Based Project
Create the Page Based Project
Universal App Storyboards
Universal App Storyboards

Launch XCode and create a Page-Based application. Give your app the same name as the App ID you created in the IOS Provisioning Portal. Enter the same company identifier as in the IOS Provisioning Portal, add the optional prefix and select Universal for the Device Family. Click Next to create the project.

You will notice that XCode created two storyboards; one for each device type.

Select Project root to open the Targets page. Scroll to the bottom of the page to the Entitlements section. Enable the Entitlements by checking the appropriate checkbox. You will notice that the iCloud key/value pair gets filled in as well as iCloud containers and Access Key fields. You will also notice that a new file with the entitlements extension is created and placed in the project files path.

Enable Entitlements
Enable Entitlements

If you select the file, it will display the Entitlement configuration for your app.

Step 3 : Check for iCloud Availability

To be able to bow out gracefully when the device is not connected or otherwise unavailable, we will add some code to the AppDelegate implementation file in the didFinishLaunchingWithOptions method. So, click on the AppDelegate file, in my project it is kvlAppDelegate.m and add the following code to the didFinishLaunchingWithOptions method:

iCloud Availability Code
iCloud Availability Code

The URLForUbiquityContainerIdentifier method returns the container associated with the current app. If the iCloud service isn’t available, the application will catch the error and bow out gracefully. Specifying nil as a parameter returns the first container that is configured in the Entitlements file. You could specify a hard coded value here as well as a string for the Container ID.

Step 4: Test the iCloud service

Connect your device to your Mac and when XCode detects its presence, it will appear in the Scheme selector field.

Deploy to actual device
Deploy to actual device

Select the target device and launch the app. It will get deployed to the target device and launch. Open the log console and you will see the following message that iCloud service has accessed the local file system. The daemon transfers file to this directory on your target device. You can retrieve and or place files at this location for syncing.

Console Output
Console Output

In Summary

This is the steps in a nutshell to create the basic iCloud application. In the next tutorial I will show how to actually create documents or files and to sync them with the external iCloud service.

More by this Author


Comments 2 comments

Ramanan R R 2 years ago

"Give your app the same name as the App ID you created in the IOS Provisioning Portal." Product name needs to same or different ? Is that an issue if it differs Product name and App ID suffix ?


klanguedoc profile image

klanguedoc 2 years ago from Canada Author

No I don't believe so. It is more about asset management and organization.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working