Home > Articles > Programming > General Programming/Other Languages

This chapter is from the book

Looking Inside the iCloud Basics

Bundle identifiers and Apple IDs have been around for a long time, but now they have key roles to play in iCloud. Both of them are needed to gain access to a section of iCloud. This is the implementation of the app-based file structure described in Chapter 1.

You might expect to find standard log-in methods in the iCloud API that enable your app to present an Apple ID and a bundle ID to iCloud in order to gain access to the data. That’s not how it happens. Remember that there is no explicit iCloud API; beyond that, the notion of logging in to iCloud for an app isn’t what happens. (Users do log in to iCloud—often automatically with their settings in the iCloud pane of System Preferences.)

Your app interacts directly with a local copy of the iCloud data for the user and the app. This copy of the iCloud data for the user and app is stored locally in a ubiquity container. The ubiquity containers are stored on the local device, and their contents are synchronized by the local OS and its interaction with iCloud. Just as is the case with any other local data access, you can read and write as necessary, and you can expect (and even check on) the results of those read and write statements.

Because you are not reading and writing to the iCloud data directly in most cases, you can’t expect the changes that you have made to the local ubiquity data to be propagated to iCloud immediately. If you want to get into naming things, iCloud is an asynchronous and declarative implementation of cloud technology.

The key components of iCloud are

  • Apple ID
  • Bundle identifier
  • Entitlements and capabilities
  • Ubiquity container

The following sections cover the basics of what you need to know about them.

Apple ID

We’re now looking at iCloud runtime behavior. The Apple ID discussed here is the user’s Apple ID.

An Apple ID uniquely identifies . . . something. It started in 2000 as an account name on Apple’s early Internet service, iTools, which provided free email accounts as <accountname>@mac.com. Over time, <accountname>@mac.com became <accountname>@me.com (MobileMe) and then <accountname>@icloud.com. With the advent of the iTunes store, customers used an Apple ID for their purchases. The email account name served as the first Apple IDs, but, particularly after Apple began charging for email accounts, Apple IDs no longer consisted of me.com or mac.com addresses. Every Apple ID did have to have an email address associated with it (for verification if for no other reason) and, for purchases in iTunes Store, a credit card number.

The idea that an Apple ID uniquely identifies an individual person has long gone away. An Apple ID has a name, a password, an email address, an optional rescue email address (in case the primary address is unreachable), and, if used for purchases, it may have a credit card associated with it. Apple suggests that people not share Apple IDs, but we know that sometimes a family or even a small business will share one.

Apple suggests that people may like to have one Apple ID to identify themselves to iTunes and another to identify themselves for other purposes such as iCloud, FaceTime, and the like. Developers often have one or more Apple IDs for their personal life and another for their developer account. iBook authors need their own Apple ID, so a developer who is also an iBook author needs two right there.

There is a unique identifier underneath all the attributes, so email address, name, password, and credit card can all be changed without creating a new Apple ID. Every iOS device requires that the user has an Apple ID in order to gain access to downloads of the operating system as well as any purchased apps or music.

On OS X, although the installation process encourages it, you do not need an Apple ID. If you want to use iCloud, you do need an Apple ID. Apple has recognized the proliferation of multi-Apple ID individuals in OS X Mountain Lion (10.8) and later versions of OS X. Figure 2.4 shows part of the Users & Groups pane in System Preferences.

Figure 2.4

Figure 2.4 You can have multiple Apple IDs on OS X.

If you click Change, you see a list of the Apple IDs you have associated with this account. You can add or delete some and create a new one, as shown in Figure 2.5.

Figure 2.5

Figure 2.5 Switching Apple IDs on OS X

Most of the time, people don’t pay attention to their Apple ID when they set up a device beyond checking that their email works (if it uses the Apple ID). However, for ongoing support of your iCloud app, remember (and let your tech support people remember) that the Apple ID is a critical part of iCloud access. If someone in an office uses an OS X account for business and another for personal matters, the iCloud documents created under those two OS X accounts may be using different Apple IDs. A Pages document under one account will not be shared with the other, although you can do so with sharing commands implemented in Pages and other apps.

The Apple ID that a user has used to sign into iCloud is available to the operating system at runtime, and that is how the Apple ID part of the iCloud authentication takes place: you don’t do anything.

Bundle Identifier

The bundle identifier is set in your app’s target settings in Xcode (in the General tab of the target). As you step through the process of creating a new project, you are asked for information, including the product name and the company identifier. You provide the product name, and the company identifier is editable (it actually is sticky—you start with the last company identifier you used).

The bundle identifier that Xcode starts with is the combination of the company identifier (which is usually your reverse domain name) and the product name, as in com.yourcompany.yourproductname.

If you look at the Info tab of your project, as shown in Figure 2.6, you’ll see that the bundle identifier is set to your product name. The product name is also used as the target name, so you begin with identical values for your target and the last component of your bundle identifier. You can change your target name in the left side of the project editor: just double-click and type in a new name. You’ll see that the last component of the bundle name also changes, because, as you see in Figure 2.6, it is picking up the product name.

Figure 2.6

Figure 2.6 Editing the bundle identifier in Info

However, you can edit the bundle identifier itself in the General tab. As initially set up, it is set to com.yourcompany.${PRODUCT_NAME:rfc1034identifier. If you trace through the various settings, you’ll see that product name (in the Packaging section of Build Settings) is set to $(TARGET_NAME). This means that if you change the target name, the product name will change, and because it’s used as the last component in the bundle identifier, that, too, will change. Anywhere along the line, you can double-click to edit the setting. If you change Product Name to be MyProject instead of $(TARGET_NAME), you will change the product name, and indirectly, the last component of the bundle identifier. Generally, the best place to edit a bundle identifier is in the General tab of the project itself rather than in the Info tab. That is because the Info tab sets up the naming structure with placeholders such as $(TARGET_NAME) and the General tab lets you type in the actual name that you want to use, which overrides the placeholders.

Most of the time, the default settings are fine, and you don’t have to worry about them. However, they come into play with iCloud when you need a ubiquity container that is shared among several apps. (Perhaps most commonly, one is a Mac app and the other is an iOS app.)

Entitlements and Capabilities

Entitlements specify what your app can do. The Capabilities tab shown in Figure 2.7 lets you configure the capabilities and the related entitlements and other settings. As you can see, there’s a simple switch for each capability—iCloud, Game Center, Passbook, In-App Purchase, and more (still more are likely to come in the future).

Figure 2.7

Figure 2.7 Turn capabilities on and off.

If a given capability is off, turning it on will also open the disclosure triangle to show you what additional steps you and/or Xcode must take, as you see in Figure 2.7.

When you turn a capability on, you’ll be asked to choose a development team to use in provisioning, as you see in Figure 2.8.

Figure 2.8

Figure 2.8 Choose a development team.

The steps that need to be taken, as shown in Figure 2.7, are checked off or, if a problem occurred, you are usually given an opportunity to have Xcode fix it, as you see in Figure 2.9.

Figure 2.9

Figure 2.9 Managing Capabilities

Beginning in Xcode 5, this process replaces the manual configuration that you had to do in the past on developer.apple.com. You can still do that, and that is still the best place to actually see the details of your identities, provisioning profiles, and app IDs, but for many if not most of your transactions, Xcode will take care of those tasks. Also note that Xcode sets up the appropriate entries in your project’s plist.

As you can see in Figure 2.9, when you enable iCloud, you’ll be able to choose the entitlements file, but Xcode will begin by naming one for you. If you want to use a key-value store, you can enable it here: that is the topic of Chapter 8, “Using Key-Value Coding (KVC).” For documents (that is, data other than KVC data), you use a ubiquity container. You may have more than one, but the first one is always assumed to be the main one. If you are using KVC without documents, you don’t need a ubiquity container.

Ubiquity Container

As you can see in Figure 2.9, you can specify ubiquity containers for your app. The first one you create has a default name set by Xcode, and it has a special role to play. (You can change the default name if you want, and in some cases, you must, as you’ll see in the next paragraph.) The first ubiquity container is the primary ubiquity container. On OS X, its contents are displayed in the open and save dialogs available in NSDocument. (On iOS, you create your own interface to display documents in iCloud if you use them.)

The default name for the primary ubiquity container is the bundle identifier. In cases where you want to share a ubiquity container among several apps (such as an OS X version and an iOS version), change one of the ubiquity container names to the other one so it is shared. As you will see in Chapter 18, “Completing the Round Trip,” the shared ubiquity container may have any name you want. In Chapter 18, the two apps have bundle identifiers of com.champlainarts.ColbyiOS and com.champlainarts.ColbyOSX. The shared ubiquity container is com.champlainarts.colby.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020