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

# Installation

> How to install and set up the Stytch B2B SDK in your iOS application.

> [!NOTE]
>
> This guide is for our new Kotlin Multiplatform SDK which is in **Public beta**. If you are instead looking for the stable version, please see [stytch-ios](https://github.com/stytchauth/stytch-ios) and the usage docs [here](https://stytchauth.github.io/stytch-ios/latest/StytchCore/documentation/stytchcore/).

For a full walk-through of how to get up and running with a sign-up and login flow using Stytch, check out our [Quickstart Guide](/docs/get-started/quickstart.md).

**1. Add the package**

Add the Stytch iOS package via Swift Package Manager. In Xcode, go to **File → Add Package Dependencies** and enter the repository URL:

```
https://github.com/stytchauth/stytch-ios-sdk
```

Select the **StytchB2BSDK** product and add it to your target.

**2. Configure URL scheme**

To handle magic links, register a custom URL scheme in your app's `Info.plist`:

```xml theme={null}
<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>your-app-scheme</string>
        </array>
    </dict>
</array>
```

Then pass this scheme as the `loginRedirectUrl` and `signupRedirectUrl` when starting magic link flows, and handle the incoming URL in your `AppDelegate` or `SceneDelegate` by calling `stytch.authenticate(url:)`.

**3. Create the Stytch client**

Initialize the Stytch client with your Project's `public_token` from the [Project Overview](https://stytch.com/dashboard) of the Stytch Dashboard.

```swift theme={null}
import StytchB2BSDK

let stytch = createStytchB2B(configuration: .init(publicToken: "public-token-test-1234"))
```

The client is a singleton — subsequent calls to `createStytchB2B` return the same instance.

**4. Observe authentication state**

Subscribe to `authenticationStateFlow` to react to sign-in and sign-out events:

```swift theme={null}
Task {
    for await state in stytch.authenticationStateFlow {
        // state is B2BAuthenticationState.Authenticated, Unauthenticated, or Loading
    }
}
```
