iosicloudphotocloudkitphotokit

Do you need to enable CloudKit to access iCloud Photos?


I'm trying to find out if I need to enable CloudKit in order to access iCloud Photos, or does the PhotoKit handle everything?

Also I'm guessing it's probably a good idea to have a separate developer account when messing with iCloud photos, does Apple allow a separate account?


Solution

  • PhotoKit uses CloudKit behind the scenes, so it's using its own data containers (etc) and you don't need to create your own.

    If you're logged into an iCloud account with iCloud Photo Library enabled, PHAsset (and related) fetch methods will always return all the items "in your library", regardless of whether the photo/video data for those items is currently stored on your device. When you want to display or edit assets, use PHImageManager APIs to find out if data is in iCloud and respond to downloading.

    AFAIK, there's no "sandbox" for Photos content. If you want to test your app without giving it access to your "real" iCloud photo library, use a separate (free) iCloud account. (Note, however, that you don't have much to fear from a buggy dev build of your app running amok in your library — destructive operations in PhotoKit like deleting assets always pop an alert for user confirmation.)