> 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-de-documentos.md).

# Document Capture

## Introduction

This component is responsible for the **capture and analysis of identity documents**, allowing structured information to be extracted and processed images of the document to be obtained.

Its main features are:

* Internal camera and permission management.
* Guided assistance for capturing the **front and back** of the document.
* Automatic data extraction using OCR.
* Obtaining processed images of the document and associated elements (face, signature, etc.).
* High level of configuration: countries, languages, document types and models.

***

## Dependencies

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

### **CocoaPods**

* Facephi libraries are distributed remotely through dependency managers. 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 **SelphID**, add the corresponding dependency in the `Podfile` of the project.

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

### Swift Package Manager (SPM)

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

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

To install the component **SelphID**, include it in the project modules.

<pre class="language-swift"><code class="lang-swift"><strong>//HTTPS
</strong>https://github.com/facephi-clienters/SDK-SelphidComponentLight.git
//SSH
git@github.com:facephi-clienters/SDK-SelphidComponentLight.git
</code></pre>

***

## 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**                      |
| ----------------- | ------------------------------------ |
| SelphIDController | Main document recognition controller |

***

## Error handling <a href="#recepcion-del-resultado" id="recepcion-del-resultado"></a>

*finishStatus*: which will indicate whether the operation has completed successfully. Possible values:

```swift
FinishStatus.STATUS_OK
FinishStatus.STATUS_ERROR
```

*errorType*: Widget-specific errors.

In iOS, if interpolated directly, it will show `SELPHID_TIMEOUT`. In iOS there is no `TIMEOUT` without prefix.

To serialize the error, the following must be used:

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

This returns `SPD_TIMEOUT` whether the enum is `SDK_TIMEOUT` or `SELPHID_TIMEOUT`.

#### Timeout behavior

In a timeout, the result has:

* `finishStatus`: `STATUS_ERROR`
* `data`: `nil` (a `SelphIDResult`)
* `errorType`: `.SELPHID_TIMEOUT(UIImage?, UIImage?)`

The case `SELPHID_TIMEOUT` retains, when available, the raw document images captured before the timeout (`rawFrontDocument` and `rawBackDocument` from the widget). That information **do** is part of `data` nor is it returned as `rawFrontDocument` / `rawBackDocument` from the success result; it can only be read on iOS by pattern matching on `errorType`:

```swift
if case .SELPHID_TIMEOUT(let frontRaw, let backRaw) = sdkResult.errorType {
    // frontRaw, backRaw: UIImage? (may be nil)
}
```

If it arrives as `SELPHID_TIMEOUT`, the associated images may be `nil` when the timeout occurs through the widget error path (`FWMETimeout`) instead of the delegate `captureTimeout()`.

In iOS, properties such as `timeoutDiagnostic` or `captureProgress` **do** are included in the `SdkResult` error. The component uses `captureProgress` internally to show the diagnostic screen message when `showDiagnostic` it is active.

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 cross-platform contract errors; some do not occur on iOS (for example, `SPD_MOVE_FAIL`).

* SPD\_APPLICATION\_CONTEXT\_ERROR: The required application context is null.
* SPD\_BAD\_EXTRACTOR\_CONFIGURATION\_ERROR: Widget: Incorrect extractor configuration
* SPD\_CAMERA\_PERMISSION\_DENIED: The user has denied permissions.
* SPD\_CANCEL\_BY\_USER: The user has canceled the process.
* SPD\_CANCEL\_LAUNCH: A general SDK cancellation has been performed.
* SPD\_COMPONENT\_LICENSE\_ERROR: The component license is not valid.
* SPD\_CONTROL\_NOT\_INITIALIZATED\_ERROR: Widget: Initialization error
* SPD\_EMPTY\_LICENSE: The license string is empty.
* SPD\_EXTRACTION\_LICENSE\_ERROR: Widget: License error
* SPD\_HARDWARE\_ERROR: Widget: Hardware error
* SPD\_INITIALIZATION\_ERROR: Initialization error.
* SPD\_MOVE\_FAIL: The user has not moved as specified in the process.
* SPD\_NO\_DATA\_ERROR: The input data is null.
* SPD\_OPERATION\_NOT\_CREATED: There is no operation in progress.
* SPD\_RESOURCES\_NOT\_FOUND: The resources zip was not found
* SPD\_SETTINGS\_PERMISSION\_ERROR: Widget: Permission error
* SPD\_TIMEOUT: Timeout in the process `SELPHID_TIMEOUT` of the enum).
* SPD\_UNEXPECTED\_CAPTURE\_ERROR: Widget: Capture error
* SPD\_UNKNOWN\_ERROR: Unknown error
* SPD\_WIDGET\_RESULT\_DATA\_ERROR: Error in the widget output data
