Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Photokit

ASecurity

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.

3 stars
0 votes
0 copies
0 views
Added 9/28/2026
developmentphpswiftapidocumentation

Works with

api

Security Analysis

A100/100

Scanned 9/28/2026

Install to Claude Code

$npx -y skills add thiennc-tesoglobal/ios-skills --skill photokit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Photokit?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Photokit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/thiennc-tesoglobal-photokit/badge)](https://www.skillsdirectory.com/skills/thiennc-tesoglobal-photokit)

More formats (shields.io, HTML) on the badges page.

Files
SKILL.md
---
name: photokit
description: "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."
---

# PhotoKit

Build media selection, camera capture, photo library queries, and image caching workflows with `PhotosUI` (`PhotosPicker`), `PhotoKit` (`PHPhotoLibrary`), and `AVFoundation`. Targets Swift 6.3 / iOS 26+.

## Contents

- [Picker Selection Strategy](#picker-selection-strategy)
- [Privacy and Permissions](#privacy-and-permissions)
- [Image Loading and Caching](#image-loading-and-caching)
- [Camera Capture Boundaries](#camera-capture-boundaries)
- [Route by Task](#route-by-task)
- [Common Mistakes](#common-mistakes)
- [Review Checklist](#review-checklist)
- [References](#references)

## Picker Selection Strategy

| 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.

## Privacy and Permissions

When accessing `PHPhotoLibrary` directly, request authorization and handle `.limited` access:

```swift
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`.

## Image Loading and Caching

Use `PHCachingImageManager` for fast grid thumbnail generation:
1. **Prepare caching**: Call `startCachingImages(for:targetSize:contentMode:options:)` when scrolling into view.
2. **Reuse options**: Use `PHImageRequestOptions` with `deliveryMode = .opportunistic` for quick thumbnails followed by high-res data.
3. **Cancel obsolete requests**: Cancel pending request IDs when cells scroll out of viewport.

## Camera Capture Boundaries

For custom camera viewfinders using `AVCaptureSession`:
- Configure sessions on a dedicated serial background queue, never on `@MainActor`.
- Balance every transaction with `session.beginConfiguration()` and `defer { session.commitConfiguration() }`.
- Embed viewfinders in SwiftUI using `UIViewRepresentable` backed by `AVCaptureVideoPreviewLayer`.

## Route by Task

- For SwiftUI `PhotosPicker` single/multi-selection and media filtering recipes, read [PhotosPicker Recipes](references/photokit-patterns.md).
- For complete camera controllers, photo capture, video recording, and barcode scanning, read [Camera Capture Patterns](references/camera-capture.md).
- For asset fetching, thumbnail caching with `PHCachingImageManager`, and memory management, read [Image Loading and Caching](references/image-loading-caching.md). For format conversion and compression, read [Image Formats and Compression](references/image-formats-compression.md).
- For video playback, custom player UI, and AVPlayer integration, read [AV Playback Reference](references/av-playback.md).

## Common Mistakes

- Requesting full photo library permissions when `PhotosPicker` would suffice without any permissions.
- Hardcoding `.highQualityFormat` on `PHImageRequestOptions` for fast-scrolling grids, causing dropped frames.
- Running `AVCaptureSession.startRunning()` or configuration changes on `@MainActor`.
- Forgetting to handle `.limited` photo library access on iOS 14+.
- Loading full-resolution `UIImage` into memory for multiple items simultaneously without downsampling.

## Review Checklist

- [ ] `PhotosPicker` preferred over custom library enumeration where appropriate
- [ ] `NSPhotoLibraryUsageDescription` provided when using `PHPhotoLibrary`
- [ ] `NSCameraUsageDescription` provided when using `AVCaptureSession`
- [ ] `.limited` photo library authorization handled gracefully
- [ ] `PHCachingImageManager` used with preheating for asset collections
- [ ] `AVCaptureSession` configured and started on a serial background queue
- [ ] Photo picker item loading handles cancellation and errors asynchronously
- [ ] Image assets downsampled to target display size to prevent memory spikes

## References

- [PhotoKit patterns and picker recipes](references/photokit-patterns.md)
- [Camera capture and AVCaptureSession reference](references/camera-capture.md)
- [Image loading, caching, and downsampling](references/image-loading-caching.md)
- [Image formats and compression](references/image-formats-compression.md)
- [AV Playback reference](references/av-playback.md)
- [PhotoKit documentation](https://sosumi.ai/documentation/photokit)
- [PhotosUI documentation](https://sosumi.ai/documentation/photosui)

Attribution

thiennc-tesoglobalthiennc-tesoglobal
View sourceMore from thiennc-tesoglobal →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

284972 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2222 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

10311 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →