What's New / App Services, Foundation & Diagnostics

What's new in Photos

+12 New~2 DeprecatediOS · macOS

Photos (PhotoKit) is Apple's framework for reading, writing, and managing the user's photo and video library, including assets, collections, and extension points for the Photos app.

The 27 SDK adds 12 APIs and deprecates 2. It adds the PHBackgroundResourceUploadJobExtension protocol, the uploadJobExtensionEnabled property with its setUploadJobExtensionEnabled setter, the PHBackgroundResourceUploadProcessingResult type, and the State, Type, and Action enums. Both deprecations are PHBackgroundResourceUploadExtension, the prior extension entry point the job extension replaces.

New

12
protocol

PHBackgroundResourceUploadJobExtension

NewiOSmacOS
public protocol PHBackgroundResourceUploadJobExtension : AppExtension
Declaration
public protocol PHBackgroundResourceUploadJobExtension : AppExtension {

    /// Request to initiate processing background upload jobs.
    /// - Returns: A result type of ``PHBackgroundResourceUploadProcessingResult`` based on the state of the processing task.
    func processJobs() async -> PHBackgroundResourceUploadProcessingResult

    /// Called by the host before suspending or terminating the extension process. Extension clients should use this to
    /// stop any in-progress work. When the extension is activated again, a new call will be made by the host.
    func willTerminate() async
}
extension

PHBackgroundResourceUploadJobExtension

NewiOSmacOS
extension PHBackgroundResourceUploadJobExtension
Declaration
extension PHBackgroundResourceUploadJobExtension {

    public var configuration: some AppExtensionConfiguration { get }
}
enum

PHBackgroundResourceUploadProcessingResult

NewmacOS
public enum PHBackgroundResourceUploadProcessingResult : Int
Declaration
public enum PHBackgroundResourceUploadProcessingResult : Int {

    /// the extension failed the processing task with an error
    case failure

    /// the extension has only partially completed its processing and still requires more time
    case processing

    /// the extension has completed all processing required and is up to date with the photos library
    case completed

    /// Creates a new instance with the specified raw value.
    ///
    /// If there is no value of the type that corresponds with the specified raw
    /// value, this initializer returns `nil`. For example:
    ///
    ///     enum PaperSize: String {
    ///         case A4, A5, Letter, Legal
    ///     }
    ///
    ///     print(PaperSize(rawValue: "Legal"))
    ///     // Prints "Optional(PaperSize.Legal)"
    ///
    ///     print(PaperSize(rawValue: "Tabloid"))
    ///     // Prints "nil"
    ///
    /// - Parameter rawValue: The raw value to use for the new instance.
    public init?(rawValue: Int)

    /// The raw type that can be used to represent all values of the conforming
    /// type.
    ///
    /// Every distinct value of the conforming type has a corresponding unique
    /// value of the `RawValue` type, but there may be values of the `RawValue`
    /// type that don't have a corresponding value of the conforming type.
    @available(macOS 27.0, iOS 26.1, macCatalyst 27.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    @available(visionOS, unavailable)
    public typealias RawValue = Int

    /// The corresponding value of the raw type.
    ///
    /// A new instance initialized with `rawValue` will be equivalent to this
    /// instance. For example:
    ///
    ///     enum PaperSize: String {
    ///         case A4, A5, Letter, Legal
    ///     }
    ///
    ///     let selectedSize = PaperSize.Letter
    ///     print(selectedSize.rawValue)
    ///     // Prints "Letter"
    ///
    ///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
    ///     // Prints "true"
    public var rawValue: Int { get }
}
extension

PHBackgroundResourceUploadProcessingResult

NewmacOS
extension PHBackgroundResourceUploadProcessingResult : Equatable
Declaration
extension PHBackgroundResourceUploadProcessingResult : Equatable {
}
extension

PHBackgroundResourceUploadProcessingResult

NewmacOS
extension PHBackgroundResourceUploadProcessingResult : Hashable
Declaration
extension PHBackgroundResourceUploadProcessingResult : Hashable {
}
extension

PHBackgroundResourceUploadProcessingResult

NewmacOS
extension PHBackgroundResourceUploadProcessingResult : RawRepresentable
Declaration
extension PHBackgroundResourceUploadProcessingResult : RawRepresentable {
}
func

setUploadJobExtensionEnabled

NewmacOS
open func setUploadJobExtensionEnabled(_ enable: Bool) throws

Enables or disables the background asset resource upload job feature.

You must call this function before you create PHAssetResourceUploadJob in the extension's host application.

To enable background uploads, you must have both full library access and register the extension with the extension point: "com.apple.photos.background-upload".

Parameters

enable
true allows calls to the extension's host application; you can fulfill that protocol to create PHAssetResourceUploadJob objects. false stops calls to the extension's host application.
error
if either enabling or disabling was unsuccessful, false is returned and an error is set on the error parameter.
var

uploadJobExtensionEnabled

NewmacOS
open var uploadJobExtensionEnabled: Bool { get }

A Boolean value that indicates whether background asset resource uploading is enabled.

The value is true if the extension is enabled and active, and is false otherwise.

The extension's host app uses this property to determine the background processing status. See PHAssetResourceUploadJob and ``PHAssetResourceUploadJobChangeRequest for more information.

enum

PHAssetResourceUploadJob.Action

NewmacOS
public enum Action : Int, @unchecked Sendable

An action to perform on an upload job.

Determine the available jobs for an action by calling the fetchJobsWithAction:options: method.

Declaration
public enum Action : Int, @unchecked Sendable {

    /// A job that requires acknowledgement.
    ///
    /// An acknowledgeable job has a ``PHAssetResourceUploadJob/state`` of `succeeded` or `failed`
    /// and hasn't been acknowledged.
    ///
    /// Call ``PHAssetResourceUploadJobChangeRequest/acknowledge`` to acknowledge a job
    /// and free queue capacity for new uploads.
    @available(macOS 10.11, *)
    case acknowledge = 1

    /// A job to retry processing.
    ///
    /// A retryable job has a ``PHAssetResourceUploadJob/state`` of `failed` and hasn't previously been retried.
    ///
    /// Call ``PHAssetResourceUploadJobChangeRequest/retryWithDestination:`` to retry the job.
    @available(macOS 10.11, *)
    case retry = 2

    /// A job to process.
    ///
    /// A processable job has a ``PHAssetResourceUploadJob/state`` of `registered` or `pending`.
    @available(macOS 10.11, *)
    case process = 3
}
enum

PHAssetResourceUploadJob.State

NewmacOS
public enum State : Int, @unchecked Sendable

The states of an upload job.

Declaration
public enum State : Int, @unchecked Sendable {

    /// The job has been registered.
    @available(macOS 10.11, *)
    case registered = 1

    /// A request has been made to send the asset resource to the destination, but has not yet been fulfilled.
    @available(macOS 10.11, *)
    case pending = 2

    /// The job has failed to send over.
    @available(macOS 10.11, *)
    case failed = 3

    /// The job has sent over successfully.
    @available(macOS 10.11, *)
    case succeeded = 4

    /// The job has been cancelled.
    @available(macOS 10.11, *)
    case cancelled = 5
}
enum

PHAssetResourceUploadJob.Type

NewmacOS
public enum `Type` : Int16, @unchecked Sendable

The types of an upload job

Declaration
public enum `Type` : Int16, @unchecked Sendable {

    /// An upload job type (will download the resource from iCloud if required. then upload)
    @available(macOS 10.11, *)
    case upload = 0

    /// A download job type (will download the resource from iCloud if required)
    @available(macOS 10.11, *)
    case downloadOnly = 1
}
typealias

PHBackgroundResourceUploadProcessingResult.RawValue

NewmacOS
public typealias RawValue = Int

The raw type that can be used to represent all values of the conforming type.

Every distinct value of the conforming type has a corresponding unique value of the RawValue type, but there may be values of the RawValue type that don't have a corresponding value of the conforming type.

Deprecated

2
protocol

PHBackgroundResourceUploadExtension

DeprecatediOS
public protocol PHBackgroundResourceUploadExtension : AppExtension
DeprecatedAdopt PHBackgroundResourceUploadJobExtension instead
Declaration
public protocol PHBackgroundResourceUploadExtension : AppExtension {

    /// Request to initiate processing background upload jobs.
    /// - Returns: A result type of ``PHBackgroundResourceUploadProcessingResult`` based on the state of the processing task.
    func process() -> PHBackgroundResourceUploadProcessingResult

    /// This notification will be called if the host is going to suspend/terminate the current execution. Extension clients should
    /// use this to stop the current execution. When the extension is activated, a new call will be presented by the host.
    func notifyTermination()
}
extension

PHBackgroundResourceUploadExtension

DeprecatediOS
extension PHBackgroundResourceUploadExtension
DeprecatedAdopt PHBackgroundResourceUploadJobExtension instead
Declaration
extension PHBackgroundResourceUploadExtension {

    public var configuration: some AppExtensionConfiguration { get }
}

No APIs match your filter.

← More in App Services, Foundation & Diagnostics