Here's an example code snippet to create a live camera preview in macOS using AVFoundation in Swift:
main.swift1087 chars38 lines
This code creates an AVCaptureSession and adds the built-in camera as a video input. It creates an AVCaptureVideoPreviewLayer to display the live camera feed in the view controller's view. Finally, it starts the capture session running.
gistlibby LogSnag