Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value of type '[AVCaptureDevice]' has no member 'compactMap' #4

Open
nirav-kotecha opened this issue Apr 12, 2018 · 7 comments
Open

Comments

@nirav-kotecha
Copy link

let cameras = session.devices.compactMap { $0 } - error on this line

screen shot 2018-04-12 at 11 36 09 am

@Jane930525
Copy link

Jane930525 commented Apr 18, 2018

Updated to Swift 4.1, error is gone but getting cameras as anempty array.

@vermotr
Copy link

vermotr commented May 3, 2018

Try to replace:

let session = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInDualCamera], mediaType: AVMediaType.video, position: .unspecified)

By:

let session = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .unspecified)

@sri1sri
Copy link

sri1sri commented May 26, 2018

Still getting the same error...

@sri1sri
Copy link

sri1sri commented May 26, 2018

Could someone one please help... THANKYOU in advance..

@raza08
Copy link

raza08 commented Jun 4, 2018

Try to use something like this.
let cameras = (sessions.devices.flatMap { $0 })

@erkandiken
Copy link

@sri1sri generic instance method compactMap seems to be supported from iOS 7.0+ and compatible with Xcode 9.3+ . What is the SDK version you are targeting and Xcode version you are using ?

@GodsEye-07
Copy link

Still getting the same error...

  1. Use as? [AVCaptureDevice] at the end of .compact { $0 }

  2. ` let session = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .unspecified)

         let cameras = session.devices.compactMap { $0 }
         guard !cameras.isEmpty else { throw CameraControllerError.noCamerasAvailable }`
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants