Skip to content

[ios] Use runtime camera checks on simulator for camera availability#3724

Open
kmagiera wants to merge 1 commit intomrousavy:mainfrom
kmagiera:fix/ios-runtime-camera-checks-simulator
Open

[ios] Use runtime camera checks on simulator for camera availability#3724
kmagiera wants to merge 1 commit intomrousavy:mainfrom
kmagiera:fix/ios-runtime-camera-checks-simulator

Conversation

@kmagiera
Copy link
Copy Markdown

What

Replace the unconditional simulator camera block with a runtime AVCaptureDevice availability check so simulator fallbacks only apply when no runtime video device exists.

Changes

  • Replace the unconditional #if targetEnvironment(simulator) throw in configureDevice(...) with a simulator-only runtime check.
  • Keep throwing device/camera-not-available-on-simulator when AVCaptureDevice.default(for: .video) is unavailable.
  • Allow the normal camera configuration path when a runtime video device is present.
  • Clarify the inline simulator comment to describe the runtime source-availability behavior.

Tested on

  • Run example app on Simulator and iPhone, verified the error is thrown on Simulator and the normal code path works as expected on the device.

Related issues

## What
Replace the unconditional simulator camera block with a runtime `AVCaptureDevice` availability check so simulator fallbacks only apply when no runtime video device exists.

## Changes
- Replace the unconditional `#if targetEnvironment(simulator)` throw in `configureDevice(...)` with a simulator-only runtime check.
- Keep throwing `device/camera-not-available-on-simulator` when `AVCaptureDevice.default(for: .video)` is unavailable.
- Allow the normal camera configuration path when a runtime video device is present.
- Clarify the inline simulator comment to describe the runtime source-availability behavior.

## Tested on
- Code-path validation in this checkout (manual review only; no device/simulator runtime execution in this environment).

## Related issues
- Inspired by [expo/expo#44159](expo/expo#44159).
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 24, 2026

@kmagiera is attempting to deploy a commit to the mrousavy's Team Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant