Introduction to CloudKit

As it turns out, many young developers have never created applications in the iOS Developer Center. Showing how to do it seems like a good idea, so I decided to prepare presentation about CloudKit and kill two birds with one stone.
CloudKit for beginners
At the beginning, you need to dedicate a little time to the iOS Developer Center. You should:
- create an App ID for the new application
- add development Provisioning Profile
- create iCloud container.
App ID
We start by creating App ID, so go to https://developer.apple.com/account/ and there log in with your email and password. If you do not have a password you will need to create it and subscribe for a year for $100.
When you are logged in, select “Certificates, Identifiers & Profiles” and then from the left-sided menu: “App IDs”. Here you will see a list of all App IDs assigned to the account.
To create a new one you need to click plus icon, located above the top right corner of the table. On the next screen, you will need to submit application data:
- application name,
- bundle ID, that is the identifier of the application,
- services – we turn on iCloud.
You can choose the name and Bundle ID of the application.
Then turn on iCloud service, and, obviously, CloudKit support. Click Continue and then Register.
Your App ID is now created, but you can see that iCloud service displays a warning. That is because no Container is selected, but we will come back to that later on.
Provisiong profile
Now we need to create provisioning profile, which will enable us to develop application. It’s all very similar – click “Provisioning Profiles”, then “Development”, then plus icon. Select “iOS App Development” and click “Continue”.
On the next screen, select the previously created App ID, the certificate, the profile to be used, then the device, and at the end give a name to the profile. That is all you need to do in the iOS Developer Center.
We can move to XCode. From the top bar, select File -> New -> Project… -> Single View Application. You will now see a screen with several form fields: give the name, paste Bundle ID you created earlier, choose any language – Swift and the device, click “Next” and choose a place where Xcode is to create a project file.
Now you can create a container by going to Project -> Selecting the right target -> Capabilities, and turn on CloudKit. Xcode may have a problem with a container – if that happens click Fix the issue, that will create a container for you. If this does not help, you need to select Specify custom containers and click plus icon, type the name of the container and click OK – it will now be created.
That’s it for the introduction. In the next post, I will discuss classes and show you some code.