Building a Camera App With SwiftUI and Combine | Kodeco, the new raywenderlich.com

Learn to natively build your own SwiftUI camera app using Combine and create fun filters using the power of Core Image.


This is a companion discussion topic for the original entry at https://www.kodeco.com/26244793-building-a-camera-app-with-swiftui-and-combine

Nice to use SwiftUI and Combine to render the live video stream. But how efficient is this and how does this compare to the most efficient method?

This was a very nice tutorial, but with the latest stuff had to fix a couple of things.

  1. Had to change
    .compactMap { buffer in
    return CGImage.create(from: buffer)

to

.compactMap { buffer in
return CGImage.create(from: buffer!)

This was bugging out do to empty buffer for a bit, so had to do something like this

if buffer != nil
{
return createCGImage(from: buffer!)
}
else
{
return drawMyImage()
}
Where drawMyImage is a simple CGImage Creator that is needed until things spin up.

Also what is missing I think is
enum CameraError
{
case deniedAuthorization
case restrictedAuthorization
case unknownAuthorization
case cameraUnavailable
case cannotAddInput
case cannotAddOutput
case createCaptureInput
}

BUT THIS IS A VERY NICE TUTORIAL

Could you please add a dection of how to add a shutter button and sction the capture?