How to access iOS simulator camera [duplicate]
Asked Answered
H

2

166

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];    
}
Herat answered 25/8, 2014 at 12:34 Comment(1)
Try with this repo: github.com/YuigaWada/iCimulator. Best RegardsDurarte
H
256

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.

Hyetography answered 25/8, 2014 at 12:38 Comment(7)
Wow, that's pathetic, Apple. And this was never changed since 2014 either?Diminished
Apple is really stupid with this notion, Android's simulator allows me to either use my webcam or just offer a simulated image, you guys can't come up with that and instead ask me to use a real device? Just shows it's all about money and not developers when it comes to Apple.Becoming
I should stop getting surprised by Apple making developers' lives hard. But I still get caught off-guard every time.Underwood
wasted a day pro max plus ultra on this. thank you for clarifying this and now I need to get a used device.Hamrick
Until now, I still can't believe this. Good job apple, keep going.. hahaAutomaton
lool I really can't believe this, is 2023, how in the earth is possible to that you have to pass over all their process to export the app (which is super hard) to simply test your camera ?Phonologist
I'm frustrated too because I too wanted to test with it, but I think I see the reasoning... an attacker could use an iOS simulator's camera to sneak up on you. I'm not judging if this is sensible or not, but between them not doing it out of technical incompetence or privacy concerns (they built the machine and the simulator you're running it on), I'd stick with the former.Striker
G
88

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.

Geometrize answered 25/8, 2014 at 12:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.