# Installation

## What the SDK includes

The SDK Mobile is made up of a set of **modular libraries (components)** that allow a biometric solution tailored to each client to be built.

***

## Dependency distribution

#### Configure credentials (`netrc`)

Add the repository to your file `netrc` by running from Terminal:

```sh
$ nano ~/.netrc
```

Include the following block at the end of the file (respect the indentation with **two spaces**):

```sh
machine facephicorp.jfrog.io
  login <USERNAME>
  password <TOKEN>
```

### Cocoapods

The SDK iOS libraries (components) are distributed via CocoaPods using a private Artifactory repository.

#### 1. Prepare the environment

To access Facephi's private repository, it is necessary to have **CocoaPods** installed on the machine.

The components of the SDK Mobile are distributed from a private repository that requires credentials, which you must request from the **Facephi Technical Support team**.

#### 2. Configure access to the private repository

**Install the Artifactory plugin**

```sh
sudo gem install cocoapods-art
```

> ⚠️ On computers with **M1 chip**, errors may occur during installation. If this happens, use the following command. If not, check the incidents section at the end of this page.
>
> `sudo arch -arm64 gem install ffi; sudo arch -arm64 gem install cocoapods-art`

Finally, add the repository that contains private dependencies:

```sh
pod repo-art add cocoa-pro-fphi 
"https://facephicorp.jfrog.io/artifactory/api/pods/cocoa-pro-fphi"
```

> If you have problems with the installation, completely uninstall CocoaPods and all its dependencies to perform a clean installation.

#### 4. Add repository and dependencies

In your `Podfile`, add the following settings:

```sh
plugin 'cocoapods-art', :sources => [
  'cocoa-pro-fphi’
]

source 'https://cdn.cocoapods.org/'

target 'Example' do
  pod 'FPHISDKMainComponent', '~> $VERSION'

   post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
      config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
      config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
    end
  end
end
...
end

```

#### 5. Update dependencies

Before running `pod install`, update the local repository:

```sh
pod repo-art update cocoa-pro-fphi
```

A *clean update* can also be done by deleting the repository first to make sure there are no cache issues. To do this, run:

```
pod repo-art remove cocoa-pro-fphi;
rm -rf $HOME/.cocoapods/repos/cocoa-pro-fphi; // $HOME usually refers to /Users/{username}
rm -rf $HOME/.cocoapods/repos-art/cocoa-pro-fphi;
```

And finally we add the private repository again:

```sh
pod repo-art add cocoa-pro-fphi 
"https://facephicorp.jfrog.io/artifactory/api/pods/cocoa-pro-fphi"
```

### SPM

The SDK iOS libraries (components) are distributed via SPM using private GitHub repositories.

#### 1. Prepare the environment

The repositories must be imported into the project in the *Package Dependencies* section of XCode.

They can be included using SSH and HTTPS. For security, the SSH method is always recommended.

#### 2. Configure GitHub connection to XCode with SSH

The best way to configure it is by connecting XCode with GitHub using an Ed25519-type SSH encryption key.

**Generate SSH key**

This step is optional and only needs to be done if you do NOT already have a key created.

We follow steps 1 to 3 of [Generating a new SSH key and adding it to the ssh-agent - GitHub Docs](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key).

**Add SSH key to the team key directory**

We follow steps 1 to 4 of [Generating a new SSH key and adding it to the ssh-agent - GitHub Docs](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent).

**Add SSH key to your GitHub account**

We follow steps 1 to 9 of [Adding a new SSH key to your GitHub account - GitHub Docs](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account#adding-a-new-ssh-key-to-your-account).

**Create Personal Token**

1. We access [GitHub Settings → Developer Settings → Personal Access Tokens](https://github.com/settings/tokens/new).
2. We determine the expiration time and the permissions we want to give the new token. This section is very important because depending on how we are going to use our repositories with XCode we will need more or fewer permissions. **It is important to grant permissions strictly for what we need**.
3. We copy the generated token and store it securely in a tool of the *vault* type, such as Keeper.

**Connect XCode**

1. We open XCode → Settings → Source Control
2. We add a GitHub account
3. In the credentials, we enter our account name and the token we just generated.
4. We accept and when returning to the XCode settings view we click on the ![Info](https://facephicorporative.atlassian.net/gateway/api/emoji/327ed40d-1088-4122-8df3-ab0b3c942ddb/atlassian-info/path?scale=MDPI) on our new linked account.
5. We make sure that SSH and the reference to the key we generated in previous steps appear selected.

#### 3. How to add an SPM <a href="#como-anadir-un-spm-a-tu-proyecto" id="como-anadir-un-spm-a-tu-proyecto"></a>

SPMs are added at project level, not at target level as is the case in CocoaPods.

To do this, go to the root of our application → Project → Package Dependencies → +

<figure><img src="/files/3aef2f5335c292e9cfd5d869eb956527b2a6d243" alt=""><figcaption></figcaption></figure>

Then we copy the SSH URL of the remote repository:

<figure><img src="/files/6bf1d8ef348fa15f176cf3bf8549155e3cbbad04" alt="" width="375"><figcaption></figcaption></figure>

<figure><img src="https://media-cdn.atlassian.com/file/86700223-4823-4698-8e83-ef48334812d1/image/cdn?allowAnimated=true&#x26;client=2496a37b-bf8c-4ee3-a347-9deae0e25c51&#x26;collection=contentId-3812360243&#x26;height=125&#x26;max-age=2592000&#x26;mode=full-fit&#x26;source=mediaCard&#x26;token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIyNDk2YTM3Yi1iZjhjLTRlZTMtYTM0Ny05ZGVhZTBlMjVjNTEiLCJhY2Nlc3MiOnsidXJuOmZpbGVzdG9yZTpjb2xsZWN0aW9uOmNvbnRlbnRJZC0zODEyMzYwMjQzIjpbInJlYWQiXX0sImV4cCI6MTc3MjcxMTA4NywibmJmIjoxNzcyNzA4MjA3LCJhYUlkIjoiNjA0N2E4N2Y1MTQ3MWMwMDZhYjJhZjI2IiwiaHR0cHM6Ly9pZC5hdGxhc3NpYW4uY29tL2FwcEFjY3JlZGl0ZWQiOmZhbHNlfQ.YsCtEHq02P38kdq_2HpB2BQ-9d9-GXXiE2TSoNYk9hk&#x26;width=760" alt=""><figcaption></figcaption></figure>

***

The SPM contains and exposes *targets.* These targets are libraries that we must import into a target of our project in order to use them. To do this, we go to the target that we want to have this dependency and add the desired SPM module:

<figure><img src="/files/aaec3a2bb7ce8698b5e16768ae677075aa1dc94f" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/1fb9701484a58dd5c0df5be9cdfd28c25fa0ba60" alt="" width="375"><figcaption></figcaption></figure>

#### 4. Troubleshooting SPM <a href="#troubleshooting" id="troubleshooting"></a>

**The SPMs do not download and I cannot see the error**

When this happens, XCode sometimes does not tell us the error. To see it, we go to the terminal and run:

`$ xcodebuild -resolvePackageDependencies`

With that command we will be able to see the specific error and resolve it.

**Error due to RSA key**

[*git@github.com*](mailto:git@github.com)*:facephi/whatever\_library.git: An unknown error occurred. ERROR: You're using an RSA key with SHA-1, which is no longer allowed. Please use a newer client or a different key type.*

*Please see* <https://github.blog/2021-09-01-improving-git-protocol-security-github/> *for more information. (-20)*

This error occurs because of the use of an SSH key with RSA encryption, which is insecure for GitHub.

The solution is to configure the connection via SSH with a more secure key (Ed25519 is recommended). This can be done by following the steps in the first section of SPM.

***

## Support

If you have questions or problems during installation, contact **Facephi Technical Support**.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.facephi.com/docs.facephi-en/sdks/sdk-mobile/ios-sdk/instalacion.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
