I saw below question to use 'captureStillImageAsynchronouslyFromConnection' function in swift: How to convert code AVFoundation objective c to Swift?
When I try to use a AVFoundation function as following:
var stillImageOutput: AVCaptureStillImageOutput!
//...Initialize stillImageOutput
stillImageOutput.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: {(imageSampleBuffer, error) in
if imageSampleBuffer {
var imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageSampleBuffer as CMSampleBuffer) // I get error on this line saying: 'Use of module ' CMSampleBuffer' as a type'
self.processImage(UIImage(data: imageData))
}
})
I got the error on Xcode, which says 'Use of module ' CMSampleBuffer' as a type'. I tried to rewrite that same line multiple times with slightly different ways, but I could not figure out the solution.
Am I doing something wrong or is it possibly the shaky Xcode Beta is not working properly?
Thank you in advance.
@Jack and @Christian's solutions worked for me. I was not careful enough to import CoreMedia. I never used this framework before, and did not know if the problem was due to not having imported a correct framework. Thank you for your help!