PhotoKit

Work with image and video assets managed by the Photos app, including those from iCloud Photos and Live Photos.

Overview

In iOS and macOS, PhotoKit provides classes that support building photo-editing extensions for the Photos app. In iOS and tvOS, PhotoKit also provides direct access to the photo and video assets managed by the Photos app.

A diagram showing the types of requests your app can make through PhotoKit, to access photos stored in the user's photo library

Using PhotoKit, you can fetch and cache assets for display and playback, edit image and video content, or manage collections of assets such as albums, Moments, and Shared Albums.

Topics

Shared Photo Library

Browsing and Modifying Photo Albums

Help users organize their photos into albums and browse photo collections in a grid-based layout using PhotoKit.

Requesting Authorization to Access Photos

Prepare your app to ask for permission when accessing the user's photo library.

class PHPhotoLibrary

A shared object that manages access and changes to the user’s shared photo library.

Asset Retrieval

Fetching Objects and Requesting Changes

Get assets, asset collections, and collection lists matching a specified query.

class PHAsset

A representation of an image, video, or Live Photo in the Photos library.

class PHAssetCollection

A representation of a Photos asset grouping, such as a moment, user-created album, or smart album.

class PHCollection

The abstract superclass for Photos asset collections and collection lists.

class PHCollectionList

A group containing Photos asset collections, such as Moments, Years, or folders of user-created albums.

class PHObject

The abstract superclass for Photos model objects (assets and collections).

class PHFetchResult

An ordered list of assets or collections returned from a Photos fetch method.

class PHFetchOptions

A set of options that affect the filtering, sorting, and management of results that Photos returns when you fetch asset or collection objects.

Asset Loading

Loading and Caching Assets and Thumbnails

Request image, video, or Live Photos content, and cache for quick reuse.

class PHImageManager

An object that facilitates retrieving or generating preview thumbnails and asset data.

class PHCachingImageManager

An object that facilitates retrieving or generating preview thumbnails, optimized for batch preloading large numbers of assets.

class PHImageRequestOptions

A set of options affecting the delivery of still image representations of Photos assets you request from an image manager.

class PHVideoRequestOptions

A set of options affecting the delivery of video asset data that you request from an image manager.

class PHLivePhotoRequestOptions

A set of options affecting the delivery of Live Photo assets you request from an image manager.

Live Photos

Displaying Live Photos

Provide the same interactive playback of Live Photos as in the iOS Photos app.

class PHLivePhotoView

A view that displays a Live Photo—a picture that also includes motion and sound from the moments just before and after its capture.

class PHLivePhoto

A displayable representation of a Live Photo—a picture that includes motion and sound from the moments just before and after its capture.

Asset Resource Management

class PHAssetResource

An underlying data resource associated with a photo, video, or Live Photo asset in the Photos library.

class PHAssetCreationRequest

A request to create a new Photos asset from underlying data resources, for use in a photo library change block.

class PHAssetResourceCreationOptions

A set of options affecting the creation of a new Photos asset from underlying resources.

class PHAssetResourceManager

A resource manager for the data storage underlying a Photos asset.

class PHAssetResourceRequestOptions

A set of options affecting the delivery of underlying asset data that you request from the asset resource manager.

Photo Editing Extensions

Creating Photo Editing Extensions

Allow your app to edit assets directly within the Photos app.

protocol PHContentEditingController

A protocol your custom view controller class implements to provide a user interface for your Photos extension.

class PHEditingExtensionContext

An object that provides Photos editing extensions with access to the underlying project and photo library.

macOS Photos Project Extensions

Creating a Slideshow Project Extension for Photos

Augment the macOS Photos app with extensions that support project creation.

class PHProject

A representation of a Photos app project extension.

class PHProjectInfo

Information about the project extension.

class PHProjectExtensionContext

An object that provides Photos project extensions with access to the underlying project, as well as to the user's photo library for editing.

class PHProjectElement

The superclass for all element objects.

class PHProjectSection

A collection of content representing curated asset and text elements.

class PHProjectRegionOfInterest

A representation of a region of interest in a photo asset.

class PHProjectChangeRequest

A request to change asset data in a Photos project extension.

protocol PHProjectExtensionController

A protocol defining the life cycle and supported types of project extensions.

class PHCloudIdentifier

A cloud identifier for a Photos project extension.

struct PHProjectCategory

A representation of Photos project extension categories.