Lessons from building an iPhone camera app: AVFoundation behaviors that aren't documented
I shipped Better Camera today after 6 months of solo work, and I wanted to share some of the AVFoundation quirks that took the longest to figure out. Maybe useful if you're building any kind of camera/video app.
Stack: Swift 6, SwiftUI, AVFoundation, Metal, AVCaptureVideoDataOutput → MetalCameraRenderer pipeline.
A few things that surprised me:
1. Virtual multi-camera devices don't support manual controls.
`builtInTripleCamera`, `builtInDualWideCamera`, etc. give you nice seamless zoom transitions, but they explicitly do NOT support `setExposureModeCustomWithDuration:ISO:`, manual focus, or manual white balance. Try and you get cryptic errors. If you need manual controls, you have to use physical devices (`builtInWideAngleCamera`, etc.) and handle the cross-device switches yourself.
I ended up with a viewport-scoped blur transition (100ms ease-out, clears on first new frame) when switching physical lenses. Looks like Apple's seamless zoom but works with manual exposure.
2. Silent session death is the worst AVFoundation failure mode.
`mediaserverd` can wedge `AVCaptureVideoDataOutput` without firing any error. Your delegate just stops getting frames. Reactive recovery (watching for missing frames and trying to restart) is fragile. Proactive approach worked better: release pixel buffer state on background, recreate the video data output with a fresh delegate on resume. Solved 95% of "camera freeze" reports from beta testers.
3. Apple's JPEG pipeline normalizes manual settings.
ISO and shutter speed reach the sensor correctly (verified via RAW comparison), but JPEG output normalizes regardless of your manual values. Same scene at ISO 800 and ISO 100 with shutter compensation produces nearly identical JPEGs because the ISP "fixes" exposure on the way out. The workaround: capture from the video frame pipeline (`AVCaptureVideoDataOutput`) instead of using `AVCapturePhotoOutput.capturePhoto`. Video frames go through a different (less aggressive) processing path.
This was the most surprising one — for a "manual" camera app, the standard photo capture API silently overrides your manual exposure. Most other manual camera apps probably hit the same wall.
4. Building Shutter Priority / ISO Priority requires a converge-before-lock pattern.
iPhone doesn't expose priority modes natively. You have to:
-
Set EV bias to user's compensation value
-
Switch to `continuousAutoExposure`
-
Poll `exposureTargetOffset` until it's stable (`abs(offset) < 0.25` for two consecutive 50ms samples)
-
Lock `.custom` with the user-fixed leg and the device-converged free leg
Without the converge step, the lock happens at whatever the device was metering before the bias took effect — usually 1-2 stops off.
Stack used:
- Swift 6 / SwiftUI / u/Observable / MVVM
- AVFoundation for capture
- Metal for the render + grain shader
- Core Image for LUT processing (`CIColorCubeWithColorSpace`)
- StoreKit 2 for IAP
App is Better Camera App Store
Happy to go deeper on any of these.
Posted Jun 1, 2026, 12:45 AM UTC