Builds or reviews photo-library picking, image loading, camera capture, and video recording with PhotoKit, PhotosPicker/PHPicker, and AVFoundation. Use for photo or camera permissions, media selection, capture sessions, library changes, caching, or media export.
88%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Build media selection, camera capture, photo library queries, and image caching workflows with PhotosUI (PhotosPicker), PhotoKit (PHPhotoLibrary), and AVFoundation. Targets Swift 6.4 / iOS 26+.
| Approach | UI Framework | Permissions Needed | Use Case |
|---|---|---|---|
PhotosPicker | SwiftUI | None (runs out-of-process) | User selects photos/videos for import |
PHPickerViewController | UIKit | None (runs out-of-process) | UIKit equivalent of PhotosPicker |
PHPhotoLibrary | Direct API | NSPhotoLibraryUsageDescription | Custom gallery, background sync, asset deletion |
AVCaptureSession | Custom UI | NSCameraUsageDescription | Real-time camera viewfinder, photo/video capture |
Prefer PhotosPicker for standard media selection. It preserves user privacy and eliminates permission friction.
When accessing PHPhotoLibrary directly, request authorization and handle .limited access:
let status = await PHPhotoLibrary.requestAuthorization(for: .readWrite)
switch status {
case .authorized:
// Full photo library access granted
case .limited:
// User selected specific photos (present PHPhotoLibrary.shared().presentLimitedLibraryPicker)
case .denied, .restricted:
// Direct user to Settings
case .notDetermined:
break
@unknown default:
break
}Include NSPhotoLibraryUsageDescription (read/write) or NSPhotoLibraryAddUsageDescription (write-only save) in Info.plist.
Use PHCachingImageManager for fast grid thumbnail generation:
startCachingImages(for:targetSize:contentMode:options:) when scrolling into view.PHImageRequestOptions with deliveryMode = .opportunistic for quick thumbnails followed by high-res data.For custom camera viewfinders using AVCaptureSession:
@MainActor.session.beginConfiguration() and defer { session.commitConfiguration() }.UIViewRepresentable backed by AVCaptureVideoPreviewLayer.PhotosPicker single/multi-selection and media filtering recipes, read PhotosPicker Recipes.PHCachingImageManager, and memory management, read Image Loading and Caching. For format conversion and compression, read Image Formats and Compression.PHAssetResource.originalFilename is incorrectly non-nullable. Use the new nullable filename property and handle nil.Sources: https://sosumi.ai/documentation/ios-ipados-release-notes/ios-ipados-27-release-notes
PhotosPicker would suffice without any permissions..highQualityFormat on PHImageRequestOptions for fast-scrolling grids, causing dropped frames.AVCaptureSession.startRunning() or configuration changes on @MainActor..limited photo library access on iOS 14+.UIImage into memory for multiple items simultaneously without downsampling.PhotosPicker preferred over custom library enumeration where appropriateNSPhotoLibraryUsageDescription provided when using PHPhotoLibraryNSCameraUsageDescription provided when using AVCaptureSession.limited photo library authorization handled gracefullyPHCachingImageManager used with preheating for asset collectionsAVCaptureSession configured and started on a serial background queuethienqo/ios-skills
6bf8b62
Canonical home
since May 23, 2026
Also appears in
on Oct 29, 2026
since May 22, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.