Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implements photo picking, camera capture, image loading, video recording, and media permissions in iOS apps using PhotoKit and AVFoundation.
Use this skill ↓86% 86%0 ptsof test cases passed
Passed 19 of 22 test cases with the skill, and 19 of 22 without it.
3 of 3 safety checks passed
Patterns for AVCaptureSession setup, photo capture, video recording, and camera features in SwiftUI. Treat all snippets below as operations on one dedicated serial capture executor. Configuration, startRunning(), and stopRunning() must never race or be split between @MainActor and unstructured detached tasks. UI state is published on the main actor only after the capture operation completes.
Every configuration transaction must balance even on early exit:
session.beginConfiguration()
defer { session.commitConfiguration() }
guard session.canAddInput(input) else { throw CameraError.cannotAddInput }
session.addInput(input)
Use an actor backed by a serial executor or a dedicated serial dispatch queue for the complete controller. Do not copy the older Task.detached fragments in isolation; migrate their bodies onto that controller's executor and update observable state after completion.
A full-featured camera model with photo capture using the delegate pattern.
import AVFoundation
import UIKit
@available(iOS 17.0, *)
Next to this one in the catalogue, plus more from the same author.