# Install in an iOS app

## Swift Package Manager

**Option 1: Xcode GUI (Recommended)**

1. Open your project in Xcode
2. Select File > Add Package Dependencies...
3. In the search field, enter: `https://github.com/zipyinc/zipy-ios-sdk.git`
4. Select the version you want to use
5. Click "Add Package"
6. Select your target and click "Add Package" again

**Option 2: Package.swift**

Add the following dependency to your `Package.swift`:

```swift
dependencies: [
    .package(url: "https://github.com/zipyinc/zipy-ios-sdk.git", from: "1.0.0")
]
```

> **Note:** Swift Protobuf will be automatically installed as a dependency when you add the ZipyiOS package.

## Zipy Initialization&#x20;

For optimal performance and complete session capture, initialize the SDK as early as possible in your app's lifecycle, typically in `AppDelegate` or `SceneDelegate`. While you can integrate the SDK at any point in your application, early initialization ensures the best results and most comprehensive data collection.

#### In AppDelegate:

```swift
import ZipyiOS

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Initialize Zipy SDK
        Zipy.initialize("YOUR_API_KEY")
        return true
    }
}
```

#### In SceneDelegate:

```swift
import ZipyiOS

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Initialize Zipy SDK
        Zipy.initialize("YOUR_API_KEY")
    }
}
```

<br>

<br>
