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

# iOS SDK

> Native Swift SDK for privacy-preserving transactions on iOS

# iOS SDK

The Privacy Boost iOS SDK is a native Swift framework that wraps the Rust core via UniFFI. It exposes idiomatic Swift APIs (`async throws`, structs, enums with associated values) for shielding, unshielding, and private transfers.

## Features

* Native Swift framework — no JavaScript bridge, no WebView
* `async`/`await` everywhere — works with Swift Concurrency and SwiftUI
* Strongly-typed `SDKError` enum with associated values for pattern matching
* Optional default delegate implementations for Keychain and Passkey
* Wallet-agnostic — implement `WalletDelegate` once for any signer
* Identical core to the TypeScript / Android / React Native SDKs (same proofs, same network protocol)

## Installation

Add the SwiftPM package to your project. See the [installation guide](./installation) for full details.

```swift theme={null}
// Package.swift
.package(url: "https://github.com/sunnyside-io/privacy-boost-ios", from: "0.2.0"),
```

Then import:

```swift theme={null}
import PrivacyBoost
import PrivacyBoostDefaults  // optional delegate helpers
```

## Quick Example

```swift theme={null}
import PrivacyBoost

let config = PrivacyBoostConfig(
    serverUrl: "https://optimism.sepolia.privacyboost.io",
    chainId: nil,                    // discovered from server
    shieldContractAddress: nil,      // discovered from server
    wethContractAddress: "0x4200000000000000000000000000000000000006",
    teePublicKey: nil,
    appId: "app_abc123xyz",
    persistenceStorage: nil,
    persistenceUnlock: nil
)

let sdk = try PrivacyBoost(config: config)

// Authenticate with a WalletDelegate you implement
let result = try await sdk.authenticate(
    wallet: myWalletDelegate,
    keySource: .walletDerived,
    tokenProvider: nil
)

switch result {
case .authenticated(let login):
    print("Privacy address:", login.privacyAddress)
case .credentialRequired(let challenge):
    // Prompt user for PIN/biometric, then call sdk.submitCredential(...)
    break
case .mnemonicGenerated(let mnemonic):
    // First-time user — display mnemonic, then call sdk.proceedAfterMnemonic(...)
    break
case .recoveryRequired:
    // Vault is in a recovery state — see Authentication concepts
    break
}

// Shield 1 ETH-equivalent of WETH
let amount = try sdk.parseAmount("1.0", decimals: 18)
let shielded = try await sdk.shield(
    tokenAddress: "0x4200000000000000000000000000000000000006",
    amount: amount
)
print("Shield tx:", shielded.txHash)
```

## Core Operations

| Method                                                   | Purpose                                |
| -------------------------------------------------------- | -------------------------------------- |
| `sdk.shield(tokenAddress:amount:)`                       | Deposit tokens into the shielded pool  |
| `sdk.unshield(tokenAddress:amount:recipient:)`           | Withdraw to a public address           |
| `sdk.send(tokenAddress:amount:recipientPrivacyAddress:)` | Private transfer                       |
| `sdk.getBalance(tokenAddress:)`                          | Single-token shielded + wallet balance |
| `sdk.getAllBalances()`                                   | All tracked balances                   |
| `sdk.getTransactionHistory(...)`                         | Paginated history                      |
| `sdk.resolveIdentity(identifier:)`                       | Look up a privacy address              |

## Documentation

### Getting Started

* [Installation](./installation)
* [Getting Started](./getting-started)

### Guides

* [Deposits](./guides/deposits)
* [Withdrawals](./guides/withdrawals)
* [Transfers](./guides/transfers)
* [Balances](./guides/balances)
* [Transactions](./guides/transactions)
* [Multi-Chain](./guides/multi-chain)
* [Wallet Integration](./guides/wallet-integration)
* [Session Storage](./guides/session-storage)
* [Error Handling](./guides/error-handling)

### Advanced

* [Performance](./advanced/performance)
* [Error Handling Patterns](./advanced/error-handling)

### Reference

* [API Reference](./api-reference)

## Requirements

* iOS 14+ (iOS 16+ required for Passkey delegate helpers)
* Swift 5.7+
* Xcode 14+

## Related

* [Multi-Chain Concepts](/sdk/concepts/multi-chain) — architecture overview
* [Authentication Concepts](/sdk/concepts/authentication) — auth flow details
* [Quickstart](/sdk/quickstart/ios) — 5-minute integration
