iOS quickstart
Get face liveness detection running in your iOS app in under five minutes.
Get face liveness detection running in your iOS app in under five minutes.
What you'll build
A single button that launches the iLive liveness verification flow —
camera preview, face detection, on-device analysis — and returns a
verdict (.pass / .fail / .retry) with confidence scores. All
inference runs on-device.
Requirements
| Requirement | Minimum |
|---|---|
| Xcode | 15.0+ |
| Swift | 5.9+ |
| iOS deployment target | 14.0 |
| CocoaPods | 1.14+ |
| Device | iPhone with front camera (arm64) |
Step 1: Install dependencies
Podfile:
Then run:
CocoaPods pulls in all transitive native dependencies automatically.
Step 2: Add camera permission
Info.plist:
Step 3: Add the SDK model assets
The SDK ships with a set of model files that need to be added to your app bundle. Add them to your Xcode target's Copy Bundle Resources build phase — your SDK distribution bundle includes the full list and expected sizes.
Model files are distributed separately from the SDK source. Your SDK
bundle ships a models/ directory — add every file inside it to your
app target's Copy Bundle Resources phase before building.
Step 4: Launch the liveness flow
Present the pre-built LivenessViewController:
Configuration
Passive mode vs challenge mode
| Mode | How it works | When to use |
|---|---|---|
Passive (passiveMode: true) | Camera captures frames silently for about 3 seconds, then runs anti-spoof, deepfake, face-consistency, and motion analysis. No user interaction. | Low-friction onboarding, background verification |
Challenge (passiveMode: false) | User completes 3–6 randomized challenges (blink, turn head, smile, etc.), then analysis runs. The challenge score is an additional verification layer. | High-security scenarios, regulatory compliance |
Both modes use the same underlying analysis pipeline. Passive mode redistributes the challenge weight across the other four layers.
LivenessResult fields
| Field | Type | Description |
|---|---|---|
sessionId | String | Unique session identifier (UUID) |
verdict | Verdict | .pass, .fail, or .retry |
confidence | Float | Weighted aggregate score (0.0–1.0) |
layerScores | [LayerScore] | Per-layer breakdown (anti-spoof, deepfake, consistency, motion) |
retryHint | String? | User-facing suggestion on retry |
failureReason | String? | Internal reason on fail |
icaoPhoto | Data? | JPEG passport photo (480×600) on pass |
photoQualityScore | Float? | Photo quality (0.0–1.0) |
attestation | Attestation? | HMAC-SHA256 signed payload (if key configured) |
encryptedFrameBundle | FrameBundle? | AES-256-GCM encrypted frames (if key configured) |
metadata | SessionMetadata | Duration, device, SDK version |
Security
Attestation (HMAC-SHA256 via CryptoKit):
Frame bundle encryption (AES-256-GCM via CryptoKit):
Device support check
SwiftUI integration
Face comparison
Compare the verified face against a reference photo (for example, an ID document):
For faster repeat comparisons, store the face embedding from the liveness result:
| Parameter | Default | Description |
|---|---|---|
threshold | 0.45 | Minimum similarity for a match (0.0–1.0) |
Troubleshooting
Missing module errors when building a framework target: The SDK's
native dependencies must be linked via an app host target — use
use_frameworks! :linkage => :static in your Podfile.
Pod install "statically linked binaries" warning: Safe to ignore. Some dependencies distribute static xcframeworks which trigger this warning but work correctly with static linkage.
Models not found at runtime: Ensure model files are in the Copy Bundle Resources build phase of your app target, not just added to the project navigator.
Face not detected: Ensure camera frames are in BGRA format
(kCVPixelFormatType_32BGRA) and portrait orientation. The face tracker
expects this format.
Low confidence scores: Verification performs best with even, front-facing illumination. Test in a well-lit environment.
Simulator not available: Build for device only with -sdk iphoneos
if your Xcode installation doesn't have simulator runtimes installed.
Platform comparison
| Feature | iOS | Android |
|---|---|---|
| Face tracking | On-device | On-device |
| Camera | AVFoundation | On-device |
| UI framework | SwiftUI + UIKit | Jetpack Compose |
| Crypto | CryptoKit (HMAC, AES-GCM) | javax.crypto |
| Package manager | CocoaPods | Gradle |
| Offline | Fully offline | Fully offline |