# iOS SDK
URL: https://www.quiltt.dev/connector/sdk/ios
Description: Integrate Quiltt Connector into your iOS application with our iOS Swift SDK. Learn how to install the package and get started with quick examples.
Navigation: connector → sdk → ios
Tags: Connector, SDKs

The [Quiltt iOS SDK](https://github.com/quiltt/quiltt-sdks/tree/main/packages/ios) provides Components for seamless integration of the Quiltt Connector into your iOS app.

Info - Documentation:
For full documentation, additional examples and the source code, see [Quiltt iOS SDK on
  GitHub](https://github.com/quiltt/quiltt-sdks/tree/main/packages/ios#readme).

## Install

### Swift Package Manager

1. Open your project in Xcode.
2. Select `File` > `Add Package Dependency...`.
3. Enter [the URL of the Quiltt Connector Swift SDK repository](https://github.com/quiltt/quiltt-sdks), select the latest version and click `Add Package`.
4. The Quiltt Connector Swift SDK is now integrated into your project. You can import it in your Swift files with `import QuilttConnector`.

## Setting up OAuth

Quiltt always prioritizes OAuth-based connections, which require your user to provide consent on their institution's website or app, and then be redirected back to your app. This means that your application needs to be able to gracefully handle this redirect by returning them to the Connector flow in your app.

For production Environments, you must always pass a `https://` URL to `appLauncherUrl`. This URL must be a valid Universal Link that can launch your app, like `https://app.mydomain.com/connect_bank`.

Please see the [iOS Universal Links guide](https://developer.apple.com/documentation/xcode/supporting-universal-links-in-your-app) for more information.

For local development, you can use `http://`. We recommend using a tunneling service like Ngrok.

Plaid OAuth Note:

## Usage

After importing `QuilttConnector`, you can use its classes and methods in your code. Here's a basic example:

```swift

struct ConnectorView: View {
    @Binding var showHomeView: Bool
    @Binding var connectionId: String
    var body: some View [WebView(showHomeView: $showHomeView, connectionId: $connectionId)]
}

struct WebView: UIViewRepresentable {
    @Binding var showHomeView: Bool
    @Binding var connectionId: String
    @State var config = QuilttConnectorConnectConfiguration(
        connectorId: "<CONNECTOR_ID>",
        appLauncherUrl: "<YOUR_HTTPS_UNIVERSAL_LINK>",
        institution: "<OPTIONAL_INSTITUTION_SEARCH_TERM_TO_PREFILL_INSTITUTION>",
        themeMode: "auto"
    )

    func makeUIView(context: Context) -> WKWebView {
        // Initialize QuilttConnector
        let quilttConnector = QuilttConnector.init()

        // Authenticate the Connector
        // See https://www.quiltt.dev/authentication/issuing-session-tokens
        quilttConnector.authenticate(token: "<SESSION_TOKEN_FROM_SERVER>")

        // Launch the Connector
        let webview = quilttConnector.connect(config: config,
                                              onEvent: [eventType, metadata in
                                                print("onEvent \(eventType), \(metadata)")],
                                              onExitSuccess: { metadata in
                                                print("onExitSuccess \(metadata)")
                                                if let newConnectionId = metadata.connectionId [connectionId = newConnectionId]
                                                showHomeView = true
                                              },
                                              onExitAbort: [metadata in
                                                print("onExitAbort \(metadata)")
                                                showHomeView = true],
                                              onExitError: [metadata in
                                                print("onExitError \(metadata)")
                                                showHomeView = true])
        return webview
    }

    func updateUIView(_ uiView: WKWebView, context: Context) [// Use this method to update the WKWebView with new configuration settings.]
}

#Preview [ConnectorView(showHomeView: .constant(false), connectionId: .constant("connectionId"))]
```