How to access iOS simulator camera

IosIos SimulatorIos Camera

Ios Problem Overview


I am making a camera app. I need to test the app in the simulator but I can't access the iOS simulator camera.

If not possible in the simulator means I need to access my system camera. Whether it is possible?

I tried UIImagePickerController but it doesn't work.

The below the code I've tried.

self.imagePicker = [[UIImagePickerController alloc] init];	
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.usingPopover = YES;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
sourceType = UIImagePickerControllerSourceTypeCamera;
self.usingPopover = NO;
}
[self.imagePicker setSourceType:sourceType];
self.imagePicker.allowsEditing = NO;
self.imagePicker.delegate = self;
if (sourceType != UIImagePickerControllerSourceTypeCamera) {
self.popover = [[UIPopoverController alloc] initWithContentViewController:self.imagePicker];
self.popover.delegate = self;
[self.popover presentPopoverFromRect:popoverFrame inView:self.view  
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
} else {
[self presentModalViewController:imagePicker animated:YES];    
}

Ios Solutions


Solution 1 - Ios

It's not possible to access the camera of your development machine to be used as the simulator camera. Camera functionality is not available in any iOS version and in any Simulator. You will have to use a real device for camera testing purposes.

Solution 2 - Ios

Simulator doesn't have a Camera. If you want to access a camera you need a device. You can't test camera on simulator. You can only check the photo and video gallery.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionR MView Question on Stackoverflow
Solution 1 - IosSalman ZaidiView Answer on Stackoverflow
Solution 2 - IosChetanView Answer on Stackoverflow