# Initial setup

### Integrating the SDK

**Native SDK**

The iOS SDK is a standard mergeable dynamic library, compatible with **iOS 15.0 and higher** (iOS 16.0 or higher for Mac Catalyst only). Xcode 26.1+ is required, but Batch will work with all Swift versions, along with Objective-C.

It supports the following architectures:

* x86\_64
* arm64 (both for iOS, and iOS Simulator on Apple Silicon)

Catalyst is supported.

The iOS SDK also supports visionOS in a restricted usage since:

* In-App messaging and mobile landings are unavailable.
* In-App rating is not supported on visionOS due to an OS limitation.

Integrating with:

{% tabs %}
{% tab title="Swift Package Manager" %}
Use Xcode's Swift Package Manager wizard to add

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

```
https://www.github.com/BatchLabs/Batch-iOS-SDK.git
```

{% endcode %}
{% endtab %}

{% tab title="CocoaPods " %}
*CocoaPods 1.15 required*

First, simply add this line to your `Podfile` to integrate Batch in your project:

{% code title="Podfile" %}

```
pod 'Batch', '~> 3.3'
```

{% endcode %}

Then, run `pod install` in your `Podfile` folder, and open the .xcworkspace that was created. You're ready to go! In order to update Batch SDK, simply run `pod update` in that directory.

If you don't have a `Podfile` or are unsure on how to proceed, see the [CocoaPods usage guide](http://guides.cocoapods.org/using/using-cocoapods.html).

{% hint style="warning" %}
**Note**: Due to CocoaPods limitations, the Batch Pod is *not* a mergable library and has no code signing. If you need one of those, please use SPM or manually integrate the XCFramework.
{% endhint %}
{% endtab %}

{% tab title="Carthage" %}
*Batch is only available on Carthage 0.30 and higher*

Simply add this line to your Cartfile to integrate Batch in your project:

```bash
github "BatchLabs/Batch-iOS-SDK"
```

*Do not add Batch to the "carthage copy-frameworks" script input/output.*

XCFramework distribution is supported since Batch 1.18.0 and Carthage 0.38.

{% hint style="warning" %}
Apple now requires Privacy Manifest that's not available with Carthage.
{% endhint %}
{% endtab %}
{% endtabs %}

### Your first start

Implement the Batch `startWithAPIKey:` method in your AppDelegate `application:didFinishLaunchingWithOptions:` method:

If you're making a SwiftUI app, you will need to add a delegate first.

{% tabs %}
{% tab title="Swift" %}

```swift
import Batch
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    BatchSDK.start(withAPIKey: "YOUR_API_KEY")
    [..]
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
@import Batch;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  // Start Batch SDK.
  [BatchSDK startWithAPIKey:@"MY_API_KEY"];

  return YES;
}
```

{% endtab %}

{% tab title="Swift UI" %}

```swift
import SwiftUI
import Batch


class MyAppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        BatchSDK.start(withAPIKey: "YOUR_API_KEY")

        return true
    }
}

@main
struct BatchApp: App {
    // Set an explicit delegate to integrate Batch in
    @UIApplicationDelegateAdaptor(MyAppDelegate.self) var delegate


    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
```

{% endtab %}
{% endtabs %}

`YOUR_API_KEY` is your SDK API Key. You'll find it in ⚙ Settings → General.

{% hint style="info" %}
This API key must not be mistaken for the APNS environment Batch will output to the Xcode logs when starting. The environment depends on the app's provision, not on the Batch API Key used.
{% endhint %}

### Testing your integration

*Congratulations on finishing the bulk of the integration!*

If you want to validate your implementation before proceeding with the Push setup, you can locate the log that Batch posts in the Xcode console.

```
[Batch] Installation ID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
```

Batch also provides a simple [debug tool](https://doc.batch.com/developer/sdk/ios/profile-data/debug) that allows you to test your integration (⚙ Settings → Debug) and a [profile view](https://doc.batch.com/getting-started/other/dashboard/01-userbase#profile-view) that shows all the data available for a specific user ID.
