How to use iCloud API to store images and get public urls for sed images.

Scott
4 min readMay 25, 2024

--

Create your project.

  1. Go to Apple Developer website, and the identifiers section.
Tap on the blue plus sign.

3.

Select iCloud Containers

4. The description is opitonal. Give it an identifier, and copy it for later!

5. Continue

Type continue.

6. You may need to go back. Sometimes the view doesn’t change. You can see your id in the list though, you may need to scroll.

7. Tap identifiers again.

8. Tap the App IDs option.

9.

10. Then continue.

Scroll down, and select iCloud.

11. Fill out the form.

12. The iCloud container identifier and your app’s bundle identifier are related but serve different purposes and do not need to be the same.

Understanding Bundle Identifier and iCloud Container Identifier

Bundle Identifier

  • Definition: The Bundle Identifier is a unique string that identifies your app in the Apple ecosystem. It follows the reverse-DNS format, such as com.yourcompany.yourapp.
  • Purpose: It is used by the operating system and various Apple services to uniquely identify your app.

iCloud Container Identifier

  • Definition: The iCloud Container Identifier is a unique string that identifies a container for storing data in iCloud. It also follows the reverse-DNS format, typically prefixed with iCloud., such as iCloud.com.yourcompany.yourapp.
  • Purpose: It is used by CloudKit to separate and manage your app’s data stored in iCloud.

Example

  • Bundle Identifier: com.yourcompany.yourapp
  • iCloud Container Identifier: iCloud.com.yourcompany.yourapp

13. On the right hand top, you should see a menu you can toggle that will let you see different types of ids. You should see one id in the iCloud containers. And the other in the app ids.

14. Okay next we need to Add the iCloud Container to Your App ID, tap on your id in the list. It should take you to a view like this. Scroll down until you see the edit next to icloud.

Make sure your icloud identifier is selected and tap continue.

You may see this warning.

You don’t have to worry about provisioning profiles, if you have automatic signing enabled.

15. Now go to Xcode. Go to your signing and capabilities, add a capability with the “+ Capability” and then choose iCloud. It should look something like this tap CloudKit, and make sure the identifier matches for the containers.

16. Next go to cloudkit console.

17. Tap Cloudkit database.

18. You can select Development or Production. you can still make publicly accessible urls with development, however it will be a separate storage from production.

19. On the left side bar, you should see a section called “Schema”, under that: “record types”.

Make sure you see Image listed.

20. Tap Container Permissions.

--

--