> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobileboost.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup

> Set up the MobileBoost SDK with your XCUI test suite

The MobileBoost SDK for XCUI integrates directly with `XCUIApplication`, adding self-healing and AI commands to your native iOS tests.

## Installation

Add the [`gptd_swift`](https://github.com/MobileBoostHQ/gptd-swift) package to your Xcode project's UI testing target via **Swift Package Manager**:

1. In Xcode, go to your project settings
2. Select your **UI test target**
3. Click **Add Dependencies**
4. Enter the package URL: `https://github.com/MobileBoostHQ/gptd-swift`

## Configuration

### Native XCUITest

Import the package and initialize `GptDriver` in your test's `setUp` method:

```swift theme={null}
import XCTest
import gptd_swift

@MainActor
final class DemoUITests: XCTestCase {

    var app: XCUIApplication!
    var gptDriver: GptDriver!

    override func setUpWithError() throws {
        continueAfterFailure = false

        app = XCUIApplication()
        app.launch()

        gptDriver = GptDriver(
            apiKey: "<YOUR_API_KEY>",
            nativeApp: app
        )
    }

    override func tearDownWithError() throws {
        app = nil
    }
}
```

## Caching

To optimize execution time, enable caching so AI is only used when the test definition or app changes.

| Mode                 | Description                                                               |
| -------------------- | ------------------------------------------------------------------------- |
| `NONE`               | No caching                                                                |
| `FULL_SCREEN`        | Cache hit only if the full screen matches a previous successful execution |
| `INTERACTION_REGION` | Cache hit if the interaction region matches (recommended)                 |

Set caching in the constructor:

```swift theme={null}
gptDriver = GptDriver(
    apiKey: "<YOUR_API_KEY>",
    nativeApp: app,
    cachingMode: CachingMode.interactionRegion,
    testId: self.name
)
```

You can also override the caching mode per step for fine-grained control.
