Importing the Knomi S Face SDK to a Project

To begin integrating Knomi S Face SDK into your project, you will need to import the framework into your project.

Select File -> “Add Files to <ProjectName>…”. Navigate to the folder where you have extracted the SDK files. Inside the “lib” folder are three sub-folders corresponding to the Swift version that you need (Swift 5.1 is forwards compatible). Inside of that folder, go to the sub-folders until you find FaceLiveness.framework and select that. Check “Copy items if needed”. In the “Add to targets” section select the target that will be using the framework. Press “Add” to the FaceLiveness.framework to the Project Navigator list.

Click the project name in the Project Navigator to open your project settings. Go to the “General” tab. Scroll down to the “Frameworks, Libraries, and Embedded Content” section. The FaceLiveness.framework framework should be selected as “Embed & Sign”.

Head to the “Build Settings” tab, be sure to select “All” settings with “Combined”. In the “Build Options” category disable bitcode by setting “Enable Bitcode” to “No”. Scroll down until you see the section titled “Apple Clang - Preprocessing”. Add “__IOS__” to the “Preprocessor Macros” setting in both “Debug” and “Release”.

In the source file containing your UIViewController add the following to get access to FaceLiveness:

import FaceLiveness

Inside of your UIViewController class add:

@IBOutlet private weak var faceLiveness: FaceLiveness!

Handle clearing memory in your deinit by assigning the faceLiveness object to nil:

deinit { self.faceLiveness = nil }

To use the FaceLiveness framework add its view to your storyboard in order to view the camera preview. Open your Main storyboard. In one of your scenes add a UIView. In the “Identity Inspector” tab change its custom class and module to “FaceLiveness”. In the “Connections Inspector” link this FaceLiveness view to your previously defined IBOutlet “faceLiveness”.

You can now access the FaceLiveness API. See the manual for additional details.