ios – Simple way to use 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 = MyFramework_takePhoto()

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.

Having just checked a few third-party apps that take photos, I can see that they have a custom interface for taking photos, so I think I know what the answer is going to be, so far as Apple API is concerned. 🙁
But if Apple doesn’t supply such an API, is there a Swift Package that does?

I have looked in the Swift Package Index, and Camera Manager seems like it might be a decent choice. Any guidance in this area would be appreciated!

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img