What problem does it solve?
Accessing and manipulating the user's photo library requires choosing the right API, handling permissions, loading images efficiently, and supporting iCloud assets without degrading UX. This Skill consolidates patterns for picking media, fetching PHAsset collections, loading images at appropriate quality, caching thumbnails, observing library changes, and saving content safely.
Core Features & Use Cases
- PhotosPicker & PHPicker: Use PhotosPicker for SwiftUI apps and PHPickerViewController for UIKit to pick media without requesting full library permission.
- PHPhotoLibrary & Authorization: Request readWrite, addOnly, or handle limited access when you need programmatic browsing, saving, or observing.
- Image Loading & Caching: Use PHImageManager for single requests and PHCachingImageManager for scrolling grids; respect degraded callbacks and allow network access for iCloud.
- Observing & Saving: Register PHPhotoLibraryChangeObserver for incremental UI updates and use performChanges for creating assets.
- Privacy & Plist: Ensure NSPhotoLibraryUsageDescription and NSPhotoLibraryAddUsageDescription are present to avoid runtime failures.
Quick Start
Use the photokit skill to generate SwiftUI PhotosPicker code that selects images, loads high-quality previews with PHImageManager, and saves chosen photos to the library while handling authorization and Info.plist privacy keys.