> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/products/idv-suite/flujos-and-integraciones/configuracion-tecnica-del-cliente/sdk-mobile/ios-sdk/modulos/captura-facial.md). Agents can also search and read this documentation through its [MCP server](https://docs.facephi.com/~gitbook/mcp).

# Face Capture

This component requires iOS 13 or later.

## Introduction

Facial capture is performed using the **Selphi Component**.

This component captures a selfie of the user and extracts their key facial features. It includes the following processes:

* Internal camera and permission management.
* Assistance during facial capture.
* Generation of facial templates and the user's image.

***

## Dependencies

To avoid conflicts and compatibility issues, if the project contains older versions of Facephi libraries (Widgets), remove them completely before installing the **SDKMobile**.

### CocoaPods

Facephi libraries are distributed remotely through dependency managers. On iOS, **CocoaPods**is used. The **required** dependencies must be installed beforehand (by adding them to the project's Podfile):

```swift
  pod 'FPHISDKMainComponent', '~> $VERSION'
```

To install the **Selphi**component, add the corresponding dependency to the project's `Podfile` along with the SDK's required dependencies.

```swift
  pod 'FPHISDKSelphiComponent', '~> $VERSION'
```

### Swift Package Manager (SPM)

If you use **SPM**, make sure the SDK's required dependencies are installed first.

```sh
//HTTPS
https://github.com/facephi-clienters/SDK-SdkPackage-SPM.git
//SSH
git@github.com:facephi-clienters/SDK-SdkPackage-SPM.git
```

To install the **Selphi**component, include it in the project's modules.

```swift
//HTTPS
https://github.com/facephi-clienters/SDK-Selphi_component-SPM.git
//SSH
git@github.com:facephi-clienters/SDK-Selphi_component-SPM.git
```

***

## Permissions

In the client application where the components will be integrated, add the following entry to the **Info.plist**:

```
Camera access must be allowed (Privacy - Camera Usage Description)
```

## Available controllers

| **Controller**   | **Description**                    |
| ---------------- | ---------------------------------- |
| SelphiController | Main facial recognition controller |

***

## Error handling

*finishStatus*: Indicates whether the operation completed successfully. Possible values:

<pre class="language-swift"><code class="lang-swift"><strong>FinishStatus.STATUS_OK
</strong>FinishStatus.STATUS_ERROR
</code></pre>

*errorType*: Errors specific to the widget.

On iOS, `errorType` is an `ErrorType` from the SDK. In the event of a timeout, the Swift enum may be `.SELPHI_TIMEOUT(LivenessDiagnostic?)` or, if interpolated directly, `SELPHI_TIMEOUT`. On iOS, there is no case `TIMEOUT` without a prefix.

To serialize the error, use:

```swift
sdkResult.errorType.toString(addComponentPrefix: "SPI_")
```

This returns `SPI_TIMEOUT` whether the enum is `SDK_TIMEOUT` or `SELPHI_TIMEOUT`.

#### Timeout behavior

On timeout, the result has:

* `finishStatus`: `STATUS_ERROR`
* `data`: `nil` (a `SelphiResult`)
* `errorType`: `.SELPHI_TIMEOUT(LivenessDiagnostic?)`

The case `SELPHI_TIMEOUT` preserves the widget's liveness diagnostic when available. This information **is not** part of `data`; it can only be read on iOS by pattern matching on `errorType`:

```swift
if case .SELPHI_TIMEOUT(let diagnostic) = sdkResult.errorType {
    // diagnostic: LivenessDiagnostic? (may be nil)
}
```

If it arrives as `SELPHI_TIMEOUT`, the associated diagnostic may be `nil` when the timeout occurs through the widget's error path (`FWETimeout`) rather than the delegate `extractionTimeout()`.

For native iOS integrations, treat the serialized value as `SPI_TIMEOUT` (includes `SELPHI_TIMEOUT` from the enum).

If `showDiagnostic` is enabled, the `output` is not invoked at the moment of the timeout: the diagnostic screen is displayed first, and the result is delivered when Close is tapped. With `showDiagnostic` disabled, the callback is executed immediately.

The following list includes errors from the cross-platform contract; some do not occur on iOS.

* SPI\_APPLICATION\_CONTEXT\_ERROR: The required application context is null.
* SPI\_BAD\_EXTRACTOR\_CONFIGURATION\_ERROR: Widget: Incorrect extractor configuration.
* SPI\_CAMERA\_PERMISSION\_DENIED: The user denied the permissions.
* SPI\_CANCEL\_BY\_USER: The user canceled the process.
* SPI\_COMPONENT\_LICENSE\_ERROR: The component license is invalid.
* SPI\_EMPTY\_LICENSE: The license String is empty.
* SPI\_EXTRACTION\_LICENSE\_ERROR: Widget: License error.
* SPI\_ACTIVE\_LIVENESS\_ERROR: Widget: Error during the active liveness process.
* SPI\_HARDWARE\_ERROR: Widget: Hardware error.
* SPI\_INITIALIZATION\_ERROR: Initialization error.
* SPI\_MANAGER\_NOT\_INITIALIZED: The managers are null.
* SPI\_NO\_DATA\_ERROR: The input data is null.
* SPI\_OPERATION\_NOT\_CREATED: There is no operation in progress.
* SPI\_RESOURCES\_FILE\_NOT\_FOUND: The resources zip file was not found.
* SPI\_SETTINGS\_PERMISSION\_ERROR: Widget: Permission error.
* SPI\_TEMPLATE\_ERROR:
* SPI\_TIMEOUT: Timeout during the process (`SELPHI_TIMEOUT` from the enum).
* SPI\_UNEXPECTED\_CAPTURE\_ERROR: Widget: Capture error.
* SPI\_UNKNOWN\_ERROR: Unknown error.
* SPI\_WIDGET\_RESULT\_DATA\_ERROR: Error in the widget's output data.
