-1

I'm writing a small program to take as photo on macOS using the iSight camera. I'm trying to follow along Apple's development documentation, but I'm getting stuck on the very first step: I can't declare the variable AVCapturePhotoOutput.

I've searched the error on Google, StackOverflow, and Apple's documentations and haven't found anything helpful.

import Cocoa
import AVFoundation

class ViewController: NSViewController, AVCapturePhotoCaptureDelegate {

    var captureSesssion : AVCaptureSession!
    var cameraOutput : AVCapturePhotoOutput!

I get errors saying,

'AVCapturePhotoCaptureDelegate' is unavailable
1. 'AVCapturePhotoOutput' has been explicitly marked unavailable here (AVFoundation.AVCapturePhotoOutput)

In my Build Settings, it says I'm using Swift 4.2 with Xcode version 10.1. On the Apple website, it says AVCapturePhotoOutput is for macOS 10.15 (beta). I just updated my os to this version, but I'm still getting these errors.

humanlikely
  • 315
  • 3
  • 10
  • @ElTomato I'm not. I'm going off of this person's [implementation](https://stackoverflow.com/a/41723819/9761536), which works if I replace the object with `AVCaptureStillImageOutput`, and the docs say " The AVCapturePhotoOutput class includes all functionality of (and deprecates) the AVCaptureStillImageOutput class." – humanlikely Aug 18 '19 at 08:00
  • Where in the code above says `AVCaptureStillImageOutput`? Where in the doc says `AVCapturePhotoCaptureDelegate` is available for macOS? – El Tomato Aug 18 '19 at 08:09
  • You have the macOS tag. The topic you are referring to has the iOS tag, not macOS. So which development platform are you working on, iOS or macOS? – El Tomato Aug 18 '19 at 08:12
  • @ElTomato I'm developing for macOS, as the tag and my post indicate. Like I said, I have it working with `AVCaptureStillImageOutput`, but Apple documentations says it will be deprecated in version macOS 10.15. It also literally says on the official AVCapturePhotoCaptureDelegate [documentation](https://developer.apple.com/documentation/avfoundation/avcapturephotocapturedelegate), on the right-hand side `macOS 10.15` under SDK. You're not being helpful at all. – humanlikely Aug 18 '19 at 09:07

1 Answers1

1

I think you need to use Xcode 11 with Swift 5.1 and target macOS 10.15.

Romain
  • 3,718
  • 3
  • 32
  • 48
  • Thank you, the error stopped after upgrading to Xcode 11, but manage to skate by with Swift 4.2. Is there somewhere I should have seen instructions to upgrade to beta? – humanlikely Aug 18 '19 at 16:29
  • @humanlikely If you install beta software as an Apple developer, it’s usually to target these new systems. Apple releases beta SDKs for its platforms (macOS, iOS, etc.) along with newer versions of developer tools such as Xcode and Swift. Since you’re not using the latest features of Swift 5.1 in this particular example you can still compile in Swift 4.2, however to build for the newest beta platforms you still need the appropriate Xcode beta software. There’s a mention of Xcode 11 for Catalina beta development here: https://developer.apple.com/macos/ ; I’m sure there are other pages as well. – Romain Aug 18 '19 at 16:47