swiftui-avfoundation-camera-bridge

Bridge AVCaptureVideoPreviewLayer into SwiftUI with UIViewRepresentable.

Updated Dec 23, 2025
One-click install
npx skills add https://github.com/co-labs-co/context-harness-skills --skill swiftui-avfoundation-camera-bridge
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-avfoundation-camera-bridge
Source: https://github.com/co-labs-co/context-harness-skills/tree/main/skill/swiftui-avfoundation-camera-bridge
Command: npx skills add https://github.com/co-labs-co/context-harness-skills --skill swiftui-avfoundation-camera-bridge

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Bridges AVFoundation's live camera preview into SwiftUI, enabling real-time video capture inside SwiftUI views and simplifying camera UI integration.

Core Features & Use Cases

  • Bridge AVCaptureVideoPreviewLayer into SwiftUI using UIViewRepresentable
  • Handle orientation and device rotation with modern APIs
  • Support pinch-to-zoom and gesture-driven camera controls within SwiftUI

Quick Start

Create a SwiftUI view that displays a live camera preview using the swiftui-avfoundation-camera-bridge and start the camera session on appear.

Frequently Asked Questions about swiftui-avfoundation-camera-bridge

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I display a live AVCaptureVideoPreviewLayer inside SwiftUI?

Display a live AVCaptureVideoPreviewLayer inside SwiftUI by wrapping it in a UIViewRepresentable structure, bridging UIKit capture sessions into SwiftUI views for real-time video preview rendering.

How do I handle device orientation for an AVFoundation camera preview in SwiftUI?

Handle device orientation for an AVFoundation camera preview in SwiftUI using the iOS 17+ videoRotationAngle API, synchronizing capture session rotation with SwiftUI view lifecycle updates.

Can I add pinch-to-zoom and other gestures to a SwiftUI camera preview?

Yes, you can add pinch-to-zoom and gesture-driven camera controls to a SwiftUI camera preview by implementing the Coordinator pattern to manage gesture recognizers within the UIViewRepresentable bridge.

What is the best way to manage AVCaptureSession lifecycle in a SwiftUI view?

The best way to manage AVCaptureSession lifecycle in SwiftUI is starting the camera session on appear and using the Coordinator pattern to handle capture session initialization, updates, and teardown.

Does the SwiftUI camera bridge support iOS 17 orientation changes?

Yes, the SwiftUI camera bridge supports iOS 17 orientation changes by utilizing the modern videoRotationAngle API to correctly orient AVCaptureVideoPreviewLayer during device rotation.