> For the complete documentation index, see [llms.txt](https://docs.talsec.app/freerasp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.talsec.app/freerasp/freerasp/integration/ios.md).

# iOS

{% hint style="success" %}
**Example**: <https://github.com/talsec/Free-RASP-iOS>
{% endhint %}

## 📝 Prerequisites

freeRASP requires a minimum **iOS** **13+**.

## 📦 Add the dependency

1. From GitHub, Copy [`Talsec` folder](https://github.com/talsec/Free-RASP-iOS/tree/master/Talsec) into your **Application** folder.
2. Drag & drop the **Talsec** folder to your `.xcworkspace`.
3. Add **TalsecRuntime** framework to **Target > Build Phases > Link Binary With Libraries**.
4. In the **General > Frameworks, Libraries, and Embedded Content** choose **Embed & Sign**.

Note: In case you are using **Carthage**, the zipped version of the framework is included in the [GitHub Releases](https://github.com/talsec/Free-RASP-iOS/releases).

***

## ⚙️ Setup the Configuration for your App

To ensure freeRASP functions correctly, you need to provide the necessary configuration. All required values must be filled in for the plugin to operate properly. Use the following template to configure the plugin. Detailed descriptions of the configuration options are provided [on the API page](/freerasp/freerasp/integration/ios/api.md).

In the `AppDelegate` import `TalsecRuntime` and add the following code (e.g., in the `didFinishLaunchingWithOptions` method.:

{% code title="AppDelegate.swift" %}

```swift
let config = TalsecConfig(
    appBundleIds: ["YOUR_APP_BUNDLE_ID"], 
    appTeamId: "YOUR TEAM ID", 
    watcherMailAddress: "your_email_address@example.com", 
    isProd: true
)
```

{% endcode %}

{% hint style="info" %}
It does not have to be AppDelegate, it can be anywhere. However, the recommended approach is to **start the SDK as soon as possible**.
{% endhint %}

{% hint style="info" %}
**Configuration Parameters**

* **`isProd`** - a boolean flag that determines whether the freeRASP integration is in the Dev or Release version. If you want to learn more about `isProd`, visit this [wiki section](/freerasp/freerasp/wiki/isprod-flag.md).
* **`watcherMail`** - By providing your watcherMail, you consent to receive security reports, product updates, and other essential communications from Talsec. [Learn more](/freerasp/freerasp/wiki/role-of-watchermail.md) about the role of `watcherMail`.
  {% endhint %}

***

## 👷 Handle detected threats

You can handle the detected events using **handlers**. For example, you can log the event, show a window to the user or kill the application. See the [Threat detection](/freerasp/freerasp/wiki/threat-detection.md) to learn more details about the performed checks and their importance for app security.

1. Anywhere in your project (e.g. in AppDelegate), add the following code as an extension:<br>

   <pre class="language-swift" data-title="AppDelegate.swift"><code class="lang-swift">import TalsecRuntime

   extension SecurityThreatCenter: SecurityThreatHandler {
       public func threatDetected(_ securityThreat: TalsecRuntime.SecurityThreat) {
           print("Found incident: \(securityThreat.rawValue)")
       }
   }
   </code></pre>

2. Use the code above for handling these types of events:<br>

   <pre class="language-swift" data-title="TalsecRuntime"><code class="lang-swift">public enum SecurityThreat: String, Codable, CaseIterable, Equatable {
       /// app integrity / repackaging / tampering
       case <a data-footnote-ref href="#user-content-fn-1">signature</a> = "appIntegrity"
       /// jailbreak
       case <a data-footnote-ref href="#user-content-fn-2">jailbreak</a> = "privilegedAccess"
       /// debugger
       case <a data-footnote-ref href="#user-content-fn-3">debugger</a> = "debug"
       /// runtime manipulation / hooks
       case <a data-footnote-ref href="#user-content-fn-4">runtimeManipulation</a> = "hooks"
       /// disabled passcode
       case <a data-footnote-ref href="#user-content-fn-5">passcode</a>
       /// [DEPRECATED] passcode change
       case passcodeChange
       /// simulator
       case <a data-footnote-ref href="#user-content-fn-6">simulator</a>
       /// missing Secure Enclave
       case <a data-footnote-ref href="#user-content-fn-7">missingSecureEnclave</a>
       /// device binding
       case <a data-footnote-ref href="#user-content-fn-8">deviceChange</a> = "device binding"
       /// changed deviceID
       case <a data-footnote-ref href="#user-content-fn-8">deviceID</a>
       /// unofficial store or Xcode build
       case <a data-footnote-ref href="#user-content-fn-9">unofficialStore</a>
       /// Detected system VPN
       case <a data-footnote-ref href="#user-content-fn-10">systemVPN</a>
       /// screenshot
       case <a data-footnote-ref href="#user-content-fn-11">screenshot</a>
       /// screen recording and screen mirroring
       case <a data-footnote-ref href="#user-content-fn-12">screenRecording</a>
       /// Time spoofing detected
       case timeSpoofing
   }
   </code></pre>

***

## 📱(Optionally) Add screenshot and screen capture blocking

To utilize active screen shot and screen capture (e.g. mirroring, screen recording) protection, you can use **Talsec.blockScreenCapture(enable: Bool, window: UIWindow)** with specific UIWindow on which it should be blocked. To receive whether the screen capture is blocked in the specific UIWindow, you can use the **Talsec.isScreenCaptureBlocked(in window: UIWindow).** For more details about all these screen capture methods, see [Screen Capture](/freerasp/freerasp/wiki/threat-detection/screen-capture.md).

## 👷(Optionally) Get information about state of check execution

You can use `RaspExecutionState` to get callback when are initial checks are finished:

{% code title="AppDelegate.swift" %}

```swift
extension SecurityThreatCenter: RaspExecutionState {
    public func onAllChecksFinished() {
        print("Initial checks done")
    }
}
```

{% endcode %}

## 🛡️ Start freeRASP

Invoke the following method right after setting up the `TalsecConfig` in previous steps.&#x20;

{% code title="AppDelegate.swift" %}

```swift
...
let config = TalsecConfig(...)
Talsec.start(config: config)
```

{% endcode %}

{% hint style="info" %}
For the version you’re integrating, you can find the specific **dSYMs** for debugging in [Releases](https://github.com/talsec/Free-RASP-iOS/releases).
{% endhint %}

***

## 🖥️ Check Talsec Portal

Check out [Data Visualisation Portal](/freerasp/freerasp/data-visualisation-portal.md) and register using your [watcherMail](/freerasp/freerasp/wiki/role-of-watchermail.md) to see your data. If you integrated the SDK successfully, the application will be present **after a few hours**. The visualisations will be active later due to the bucketing mechanism.

{% hint style="warning" %}
You have to use the **same email for the Portal** as you used for the **watcherMail** parameter.
{% endhint %}

[^1]: Learn more: <https://docs.talsec.app/freerasp/wiki/threat-detection/app-tampering-detection>

[^2]: Learn more: <https://docs.talsec.app/freerasp/wiki/threat-detection/detecting-rooted-or-jailbroken-devices>

[^3]: Learn more: <https://docs.talsec.app/freerasp/wiki/threat-detection/debugger-detection>

[^4]: Learn more: <https://docs.talsec.app/freerasp/wiki/threat-detection/hook-detection>

[^5]: Learn more: <https://docs.talsec.app/freerasp/wiki/threat-detection/passcode>

[^6]: Learn more: <https://docs.talsec.app/freerasp/wiki/threat-detection/emulator-detection>

[^7]: Learn more: <https://docs.talsec.app/freerasp/wiki/threat-detection/secure-hardware-detection-keystore-keychain-secure-storage-check>

[^8]: Learn more: <https://docs.talsec.app/freerasp/wiki/threat-detection/device-binding-detection>

[^9]: Learn more: <https://docs.talsec.app/freerasp/wiki/threat-detection/detecting-unofficial-installation>

[^10]: Learn more: <https://docs.talsec.app/freerasp/wiki/threat-detection/system-vpn-detection>

[^11]: Learn more: <https://docs.talsec.app/freerasp/wiki/threat-detection/screen-capture#screenshot-detection>

[^12]: Learn more: <https://docs.talsec.app/freerasp/wiki/threat-detection/screen-capture#screen-recording-detection>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.talsec.app/freerasp/freerasp/integration/ios.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
