Skip to content

DeepARSDK/swift-deepar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d2dcc3b · Mar 18, 2025

History

50 Commits
Mar 18, 2025
Jul 3, 2023
Jul 18, 2023
Jul 17, 2023
Mar 18, 2025
Dec 21, 2023
Mar 18, 2025

Repository files navigation

DeepAR for iOS

Build rich Augmented Reality experiences for iPhone, iPad and Mac.

Overview

DeepAR is an augmented reality SDK used to integrate advanced, Snapchat-like face lenses in iOS, Android and Web apps.

DeepAR iOS framework supports:

  • Face filters and masks.
  • Glasses virtual try on.
  • Background replacement.
  • Background blur.
  • AR mini-games.

Support

  • iOS and iPad, minimum target version 12.4.
  • MacOS, minimum target version 10.15.

DeepAR is available as xcframework for:

  • iPhone.
  • iPhone simulator for x86_64 ARCH (arm64 support coming soon).
  • Mac for x86_64 ARCH (arm64 support coming soon).

DeepAR can be used in both Swift and ObjC projects.

Documentation

  • Visit official DeepAR docs for iOS SDK here.
  • See the official example here.

Install

DeepAR is available as xcframework through CocoaPods, Swift Package Manager and can be downloaded directly from DeepAR Developer Portal.

Swift Packages

Add swift package to your Xcode project from this GitHub URL:

https://github.com/DeepARSDK/swift-deepar

CocoaPods

To install DeepAR via CocoaPods, add this to your Podfile:

pod 'DeepAR'

If the pod install command fails, you may need to run pod install --repo-update. This is because the CocoaPods repos sometimes need a lot of time to sync.

Direct download

  1. Download the iOS package from DeepAR Developer Portal and unzip.
  2. With your project open in Xcode, select your Target. Under General tab, find Frameworks, Libraries, and Embedded Content and then click the + button.
  3. Click Add Other... and then Add files... button.
  4. Select the DeepAR.xcframework from the unzipped directory and click Open.

License key

In order to use the DeepAR SDK you need to set up a license key for your ios app on developer.deepar.ai.

  1. Create an account: https://developer.deepar.ai/signup.
  2. Create a project: https://developer.deepar.ai/projects.
  3. Add a ios app to the project. Note that you need to specify the bundle id of your app app.

Getting started

Import DeepAR.

import DeepAR

Create DeepAR object and set your license key.

var deepAR = DeepAR()
deepAR.setLicenseKey("your_license_key_here")

Add delegate for the DeepAR object to be notified of async events.

deepAR.delegate = ...

Create CameraController object:

var cameraController = CameraController(deepAR: deepAR)

Get the UIView that will display the camera preview and AR filters. Add it to your view hierarchy.

let arView = self.deepAR.createARView(withFrame: ...)
mainView.addSubview(arView)

Start the camera controller

cameraController.startCamera(withAudio: true)

Wait for the didInitialize delegate to be called.

Switch effects

AR filters are represented by effect files in DeepAR. You can load them to preview the effect.

Places you can get DeepAR effects:

Call switchEffect method to load an AR filter from a file. File can be placed in the app bundle or fetched from network and saved to device.

deepAR.switchEffect(withSlot: "effect", path: path)

Background blur

Blur the background with blur strength 5.

deepAR.backgroundBlur(true, strength: 5)

Background replacement

Also known as background removal or greenscreen effect.

deepAR.backgroundReplacement(true, image: UIImage(named: "sunny_beach.png"))

License

Please see: https://developer.deepar.ai/customer-agreement