> 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).

# Face Capture

## Introduction

Face Capture is performed through the **Selphi Component**.

This component is responsible for capturing a selfie of the user and extracting their main facial features. It includes the following processes:

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

***

## Dependencies

To avoid conflicts and compatibility issues, if the project contains old versions of Facephi libraries (Widgets), they must be completely removed before installing the components of **SDKMobile**.

### CocoaPods

The Facephi libraries are distributed remotely through dependency managers. On iOS, **CocoaPods**. The dependencies **required** that must have been previously installed (by adding them to the project's Podfile file) are:

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

To install the component **Selphi**, add the corresponding dependency in the `Podfile` of the project, together with the mandatory SDK dependencies.

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

### Swift Package Manager (SPM)

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

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

To install the component **Selphi**, include it in the project 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, it is necessary to include the following element in the file **Info.plist**:

```
It is necessary to allow use of the camera (Privacy - Camera Usage Description)
```

## Available controllers

| **Controller**   | **Description**                    |
| ---------------- | ---------------------------------- |
| SelphiController | Main Facial Recognition controller |

***

## Error handling

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

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

*errorType*: Widget-specific errors.

In iOS, `errorType` is a `ErrorType` from the SDK. In a Timeout, the Swift enum can be `.SELPHI_TIMEOUT(LivenessDiagnostic?)` or, if it is interpolated directly, `SELPHI_TIMEOUT`. In iOS there is no `TIMEOUT` without prefix.

To serialize the error, the following must be used:

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

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

#### Timeout behavior

In a timeout, the result has:

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

The case `SELPHI_TIMEOUT` keeps, when available, the widget's liveness diagnostic. That information **do** is part of `data`; it can only be read on iOS using pattern matching on `errorType`:

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

If it arrives as `SELPHI_TIMEOUT`, the associated diagnostic can be `nil` when the timeout occurs through the widget error path (`FWETimeout`) instead of the delegate `extractionTimeout()`.

For native iOS integrations, the serialized value must be treated as `SPI_TIMEOUT` (includes `SELPHI_TIMEOUT` of the enum).

If `showDiagnostic` it is active. `output` is not invoked at the moment of the timeout: the diagnostic screen is shown first and the result is delivered when close is pressed. With `showDiagnostic` disabled, the callback runs 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 has denied permissions.
* SPI\_CANCEL\_BY\_USER: The user has canceled the process.
* SPI\_COMPONENT\_LICENSE\_ERROR: The component license is not valid.
* SPI\_EMPTY\_LICENSE: The license String is empty.
* SPI\_EXTRACTION\_LICENSE\_ERROR: Widget: License error.
* SPI\_ACTIVE\_LIVENESS\_ERROR: Widget: Error in 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: Input data are null.
* SPI\_OPERATION\_NOT\_CREATED: There is no operation in progress.
* SPI\_RESOURCES\_FILE\_NOT\_FOUND: The resources zip was not found.
* SPI\_SETTINGS\_PERMISSION\_ERROR: Widget: Permission error.
* SPI\_TEMPLATE\_ERROR:
* SPI\_TIMEOUT: Timeout in the process (`SELPHI_TIMEOUT` of 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.
