CameraKit Reference SwiftUI iOS

Overview

SCSDKCameraKitReferenceSwiftUI is an optional SDK that provides SwiftUI wrappers around the UIKit elements provided in SCSDKCameraKitReferenceUI. As with SCSDKCameraKitReferenceUI this SDK also provides a fully-functional Camera view to use that has CameraKit set up and working with sample lenses.

Usage Philosophy

In general, SCSDKCameraKitReferenceSwiftUI follows the same design and usage philosophy as SCSDKCameraKitReferenceUI. This means that the UI elements in SCSDKCameraKitReferenceSwiftUI are intended to be used out-of-the-box and they provide customizations to tailor the behavior slightly (eg. changing the recording duration of the camera button). While the elements in SCSDKCameraKitReferenceSwiftUI are intended to be used in a modular fashion (eg. using carousel, camera buttuon, and recorder but own video preview), the elements aren’t designed to be as extensible and changeable as they are in SCSDKCameraKitReferenceUI since the SwiftUI elements are mostly wrappers around the UIKit elements.

Getting Started

Requirements

SCSDKCameraKitReferenceSwiftUI requires Swift, a minimum of iOS 13 (although some elements like the carousel require 14), and a 64 bit processor.

Dependency Management

CameraKit currently supports CocoaPods and Swift Package Manager.

CocoaPods

Add this line to your Podfile: pod 'SCSDKCameraKitReferenceSwiftUI', :path => 'CameraKit/CameraKitReferenceSwiftUI' where :path points to the directory that contains the camera kit sdk, podspec, etc.

Run pod install and open up your xcworkspace.

Swift Package Manager

  • Drag and drop the CameraKit/CameraKitReferenceSwiftUI directory into your project or workspace.
  • Click the + button in the “Frameworks, Libraries, and Embedded Content” section, select SCSDKCameraKitReferenceSwiftUI, and add it as a dependency.

More detail can be found in Apple’s documentation.

Showing the Camera

At its most simplest form, SCSDKCameraKitReferenceUI contains a fully-setup camera that contains all UI elements (carousel, camera button, recorder, etc.) and hooks up to the core SCSDKCameraKit sdk to fetch and apply lenses to the camera. If you would like your app’s root view to be the camera, you can do so by doing the following in your app or scene delegate:

let cameraController = CameraController()
cameraController.groupIDs = ["5685839489138688"]
let view = CameraView(cameraController: CameraController)
let cameraViewController = UIHostingController(rootView: view)
window?.rootViewController = cameraViewController

where repoGroups is the list of group IDs added in Lens Scheduler to show in the carousel.