Photos Library and Editing Workflow
Purpose
Guide PhotosUI selection and PhotoKit library work while requesting the narrowest access, preserving typed asset/resource identity, and keeping image processing and video pipelines with their owning frameworks.
When To Use
- Use for
PhotosPicker,PHPickerViewController,PHPhotoLibrary, assets, fetches, collections, image/resource requests, changes, creation, albums, or nondestructive editing. - Prefer PhotosUI when the app only needs media the user explicitly selects.
- Use PhotoKit authorization only for concrete library read, add, observe, organize, or edit behavior.
Single-Path Workflow
- Classify the request:
- user-selected image/video through PhotosUI
- add-only save
- read/write or limited-library browse
- asset/collection fetch and change observation
- image, video, Live Photo, data, or resource request
- iCloud-backed delivery, progress, cancellation, or caching
- asset/album creation or transactional change
- content-editing input/output and adjustment data
- privacy, lifecycle, or correctness repair
- Apply the Apple docs gate:
- read current PhotosUI, PhotoKit, SwiftUI, and Core Transferable documentation for the platform
- state the documented behavior relied on
- check API/platform availability before making macOS, iOS, iPadOS, or visionOS claims
- Choose the narrowest access:
- use
PhotosPickerorPHPickerViewControllerfor explicit user selection when broad library access is unnecessary - use
.addOnlywhen the app only saves into Photos - use
.readWriteonly for fetch, limited-library, organization, observation, or edit requirements - handle
.notDetermined,.restricted,.denied,.authorized, and.limiteddistinctly - require
.authorized, not merely.limited, before fetching, creating, or modifying user albums and provide a picker, selected-assets, or settings fallback when full-library organization is unavailable
- use
- Preserve typed identity and lifecycle:
- keep
PhotosPickerItem,PHPickerResult,PHAsset,PHAssetCollection,PHFetchResult,PHAssetResource, request IDs, placeholders, and adjustment data typed - attach asynchronous results to the current selection, asset local identifier, request ID, fetch result, or edit generation
- cancel obsolete loads and ignore stale callbacks
- keep
- Perform changes transactionally:
- create
PHAssetCreationRequest, asset/collection change requests, and placeholders only insidePHPhotoLibrary.performChanges - surface transaction errors and fetch created objects after commit when needed
- create
- Return documented behavior, picker-versus-library decision, authorization/purpose-string policy, asset/resource identity, request/cancellation and iCloud policy, transactional/editing plan, diagnostics, validation, and handoffs.
Inputs
request: Photos selection, library, resource, save, or edit task.photos_goal:pick,add,browse,fetch,observe,request,resource,create,album,edit, orrepair.platform_context: Apple platform, deployment target, UI framework, and Photos availability.privacy_context: required access level, user explanation, metadata policy, network/iCloud policy, retention, and export behavior.
Outputs
status:success,handoff, orblocked.path_type:primaryfor PhotosUI/PhotoKit,fallbackfor image decode/process, video, UI architecture, or execution.output: documented behavior, access decision, identity/lifecycle, request/change/edit plan, diagnostics, validation, and handoffs.
Guards and Stop Conditions
- Do not request PhotoKit read/write authorization when a system picker or add-only access fulfills the feature.
- Do not treat
.limitedas fully authorized or as denial; operate on the visible library and provide the documented management path when appropriate. - Do not promise album browsing or organization under
.limited; require full.authorizedread/write access before fetching, creating, renaming, deleting, or changing user albums. - Do not mirror the entire library into app-owned state or introduce a Photos repository when
PHFetchResult, local identifiers, change details, and picker bindings express the requirement. - Do not assume a picker item, asset, or resource is local; model iCloud/network delivery, progress, cancellation, and failure explicitly.
- Do not treat degraded or opportunistic image callbacks as final, and do not let stale request callbacks overwrite a newer selection.
- Do not silently substitute adjusted content for original resources, flatten Live Photos, discard RAW/paired resources, or copy metadata without an explicit policy.
- Do not claim a library change succeeded before
performChangescompletes successfully. - Do not destructively replace edited content when PhotoKit's content-editing and adjustment-data contract requires nondestructive output.
- Stop when authorization, selected item, resource identity, network policy, or required runtime evidence is unavailable.
Fallbacks and Handoffs
- Recommend
apple-image-representation-workflowfor Image I/O decode/encode, metadata inspection, thumbnails, and image representations. - Recommend
core-image-processing-workflowfor image effects, color, RAW processing, masks, and rendering. - Recommend
avfoundation-media-pipeline-workflowfor video assets, playback, export, reader/writer, and transcode pipelines. - Recommend
video-codec-processing-workflowfor low-level compression/decompression or pixel-buffer behavior. - Recommend
swiftui-app-architecture-workfloworappkit-app-architecture-workflowfor broader UI ownership while keeping direct picker bindings and PhotoKit state here. - Recommend
xcode-build-run-workflowfor purpose strings, target integration, build, run, physical-library testing, logging, or profiling. - Recommend
xcode-testing-workflowfor authorization matrices, picker/load fakes, resource fixtures, change-detail tests, and edit round trips. - Recommend
explore-apple-swift-docsfor current PhotosUI or PhotoKit research.
References
references/photosui-selection-and-authorization.mdreferences/assets-fetches-requests-resources-and-changes.mdreferences/creation-collections-and-nondestructive-editing.md- Recommend
references/snippets/apple-xcode-project-core.mdfor reusable Xcode-project policy.