Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there Camera Device Simulation in iOS Simulators?

Android emulators can simulate Camera device (see screenshot) For example I can test how my video recording module works:

Android Emulator, camera simulation example

What about iOS-Simulators? When I try to run my app which uses camera I get the next error

Thread 5: Fatal error: Unexpectedly found nil while unwrapping an Optional value

at line

let videoDeviceInput = try AVCaptureDeviceInput(device: defaultVideoDevice!)

so no simulated devices are available for iOS-Simulators?

like image 207
user155 Avatar asked May 25 '18 07:05

user155


People also ask

Can we use camera in iOS simulator?

The Camera doesn't show on iOS simulator, but works on Android emulator ❓ #1045.

How do I simulate an iOS device?

For iOS, tvOS, and watchOS apps, you can choose a simulated device, under [Platform] Simulators, from the run destination menu next to the scheme menu in the toolbar. To add additional simulators of a product family running older versions of the operating system, choose Add Additional Simulators.

Does iOS simulator use GPU?

Simulator doesn't try to exactly simulate the GPU from the iOS or tvOS device you are simulating. For example, if you are simulating the iPhone XS, Simulator does not try to emulate the capabilities of an A12 GPU. Instead, Simulator translates any calls you make and directs them to the selected GPU on the host Mac.


2 Answers

According to Apple documentation, using camera with Simulator is not supported:

The following hardware is not supported in Simulator:

  • Ambient light sensor

  • Audio input, except for using Siri by choosing Hardware > Siri.

  • Barometer

  • Bluetooth

  • Camera

  • Motion support (accelerometer and gyroscope)

  • Proximity sensor

like image 171
Hassan Shahbazi Avatar answered Sep 30 '22 10:09

Hassan Shahbazi


There is one known workaround which could be useful sometimes: https://github.com/YuigaWada/iCimulator

But it does not work with 3-rd party libs like WebRTC though...

like image 28
Maxim Kholyavkin Avatar answered Sep 30 '22 09:09

Maxim Kholyavkin