ios – Simple way to use device camera to take a photo in swift


I’m curious, is there a very simple, preferably SwiftUI-native, iOS/iPadOS API available that will allow the user to take a photo that will be used directly in my app (with no need to go to camera roll)? I’ve found Apple’s “tutorial” on Capturing and Saving a Photo, and I know there is at least one Stack Overflow answer in this area, but these are too convoluted compared to my expectations. I’m looking for an API like:

let pathToPhoto = CapturePhoto()

Maybe it would return something in RAM instead of on disk. Maybe there would be optional parameters. But the point is, for many use-cases, it ought to be this simple to get a photo from whatever camera is attached to the device. I don’t mind if the API has full control of my app’s main thread while the camera is active. I imagine something like the behaviour in the Messages app, when you choose “Camera” from the “+” button.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img