Home Page | Documentation & Guides | Showcase | API Reference | Developer Portal | My Lenses | Discord
Camera Kit brings the power of Snap's AR platform to your websites and mobile apps on iOS and Android. It has never been easier to create and deliver scalable, multi-platform AR experiences to meet your customers, wherever they are.
- Face Effects
- Body / Face / Hand Tracking
- World Tracking
- Background Segmentation
- Location AR
- and many more
- Integrate with AVCaptureSession, which allows to maintain full control over session configuration, management, and lifecycle
- Fetch and display your lenses
- Capture media
- Leverage Reference UI modules to quickly build Camera Kit based experiences
- Supports iOS 13.0+
- Setup your Camera Kit application using Developer Portal
- Integrate Camera Kit SDK into your iOS application
- Create AR experiences using Lens Studio and manage them using My Lenses site
A core module that handles AR experiences:
SCSDKCameraKit
A set of open-sourced, reusable UI components and utilities for easier development of Camera Kit based experiences:
SCSDKCameraKitReferenceUI
SCSDKCameraKitReferenceSwiftUI
Modules required for testing your in-development lenses (see Push-to-Device):
SCSDKCameraKitBaseExtension
SCSDKCameraKitLoginKitAuth
SCSDKCameraKitPushToDeviceExtension
- In Xcode, select "File" → "Add Package Dependencies…"
- Enter the repository URL:
https://github.com/Snapchat/camera-kit-ios-sdk.git
- Select the version and modules you want to use in your project
If you use CocoaPods to manage your dependencies, simply add the following to your Podfile
:
pod 'SCCameraKit'
If you'd like to use the Reference UI:
pod 'SCCameraKitReferenceUI'
pod 'SCCameraKitReferenceSwiftUI'
- Download the binaries from the Releases section
- Unzip and add the Camera Kit SDK .xcframework to your Xcode project
- In your target's "General" settings, add the framework to the "Frameworks, Libraries, and Embedded Content" section
You can find a more detailed tutorial here
Obtain an API token for your Camera Kit application on Developer Portal
import SCSDKCameraKit
let sessionConfig = SessionConfig(apiToken: "<YOUR_API_TOKEN>")
let lensesConfig = LensesConfig(cacheConfig: CacheConfig(lensContentMaxSize: 150*1024*1024))
let cameraKit = Session(sessionConfig: sessionConfig, lensesConfig: lensesConfig, errorHandler: self)
// Configure the camera preview view
let previewView = PreviewView()
previewView.automaticallyConfiguresTouchHandler = true
cameraKit.add(output: previewView)
// Configure the capture session
let captureSession = AVCaptureSession()
let input = AVSessionInput(session: captureSession)
let arInput = ARSessionInput()
cameraKit.start(input: input, arInput: arInput)
DispatchQueue.global(qos: .background).async {
input.startRunning()
}
You can find lens group IDs and specific lens IDs on My Lenses site
// Observe a particular lens
cameraKit.lenses.repository.addObserver(self, specificLensID: "<LENS_ID>", inGroupID: "<LENS_GROUP_ID>")
// Implement LensRepositorySpecificObserver to receive observed Lens object
extension MyViewController: LensRepositorySpecificObserver {
func repository(_ repository: LensRepository, didUpdate lens: Lens, forGroupID groupID: String) {
lensQueue.async { [weak self] in
guard let self = self else { return }
// Apply a lens, which makes it visible on previewView
self.cameraKit.lenses.processor?.apply(lens: lens, launchData: nil) { success in
if success {
print("\(lens.name ?? "Unnamed") (\(lens.id)) Applied")
} else {
print("Lens failed to apply")
}
}
}
}
func repository(_ repository: LensRepository, didFailToUpdateLensID lensID: String, forGroupID groupID: String, error: Error?) {
// Handle errors
}
}
We provide several sample apps that demonstrate different approaches to integrating the Camera Kit SDK:
- CameraKitBasicSample implements the bare minimum to show a single lens
- CameraKitSample contains a fully functioning camera capture with lenses and preview flow
- CameraKitAlternateCarouselSample demonstrates how to build your own carousel and preview screen
Camera Kit for iOS is available under a custom license. See the LICENSE file for more info.
We welcome contributions to the open-sourced parts of Camera Kit for iOS - Reference UI and Sample Apps. Feel free to open issues and submit PRs.
See CHANGELOG.md for details on each release.