# Getting Started | Swift AI Autocomplete Docs

> For the complete documentation index, see [llms.txt](https://ai-autocomplete.com/llms.txt). A markdown version of any page on this site is available by appending `.md` to its URL path — the homepage is at `/index.md`.

Getting Started guide for integrating the AI Autocomplete SDK with Swift. Code examples, setup, and API reference.

Source: https://ai-autocomplete.com/docs/swift/getting-started

---

Native iOS autocomplete for SwiftUI and UIKit. iOS 17+, Swift 5.10+, zero dependencies.

## Install with an AI agent

Let your AI coding agent set up the integration and walk you through the two browser steps.

Paste this into your agent. It will scaffold the integration and tell you exactly what to do in the browser to finish setup.

**Agent prompt**

```bash
Install AI Autocomplete using the instructions at https://ai-autocomplete.com/install/swift.md
```

Works with Claude Code, Cursor, Windsurf, GitHub Copilot, ChatGPT — any agent that can read URLs and run shell commands. [View the prompt](https://ai-autocomplete.com/install/swift.md)

## Install

Requires iOS 17+ and Swift 5.10+. In Xcode, choose File → Add Package Dependencies… and paste the repository URL:

**Package URL**

```bash
https://github.com/magicx-ai/ai-autocomplete-ios.git
```

Or add it to your Package.swift directly:

**Package.swift**

```swift
dependencies: [
    .package(
        url: "https://github.com/magicx-ai/ai-autocomplete-ios.git",
        from: "1.0.0"
    )
],
targets: [
    .target(
        name: "MyApp",
        dependencies: [
            .product(name: "AIAutocompleteSwiftUI", package: "ai-autocomplete-ios")
        ]
    )
]
```

The package ships three libraries — add the one that matches how you'll integrate:

-   AIAutocompleteSwiftUI — the SwiftUI views (AIAutocomplete, AIAutocompleteDropdown). Most apps want this one.
-   AIAutocompleteUIKit — the UIKit views (AIAutocompleteView, AIAutocompleteDropdownView) plus the appearance type.
-   AIAutocompleteCore — the headless @Observable controller, models, and networking. No UI.

## First use

Drop AIAutocomplete into a view. It fetches suggestions on appear, fills pills as the user types, and hands you the completed query in onSubmit.

**ContentView.swift**

```swift
import AIAutocompleteCore
import AIAutocompleteSwiftUI
import SwiftUI

struct ContentView: View {
    var body: some View {
        AIAutocomplete(configuration: .init(
            apiConfig: .apiKey(.init(apiKey: "pk_v1_your_public_key")),
            onSubmit: { result in
                print(result.query)           // "Create a report"
                print(result.rawQuery)        // "Create a {{TASK_1}}"
                print(result.completedParams) // [CompletedParam]
            }
        ))
        .padding()
    }
}
```

## Your key

The example hardcodes a public key (pk_v1_...) for clarity. Create yours on the [Keys page](https://ai-autocomplete.com/account/keys) — public keys are designed to ship in client apps.

Security

Only ever embed public keys (pk_v1_...) in the app. Never ship a secret key (sk_v1_...) in the binary — strings in an IPA are extractable. For production, mint short-lived access tokens from your own backend (see Authentication).

## Next steps

Integration tiers covers the SwiftUI and UIKit surfaces plus the headless controller. Styling covers the appearance tokens. Authentication covers the production access-token flow.
