Plaid Link for iOS

repository·master·Indexed 41 days ago

https://github.com/plaid/plaid-link-ios

An SDK for integrating Plaid's financial connection flow into iOS applications. Supports Swift, SwiftUI, and Objective-C. LinkKit 7.x introduces a session-based API with specialized sessions for Standard Link, Layer, Headless, and Embedded flows, native SwiftUI support, and a reduced SDK footprint. Distributed via Swift Package Manager (SPM).

Tokens
5.2K
Snippets
8
Records
19
Agent score
51%

What's inside Plaid Link iOS

  1. Benefits of upgrading to LinkKit 7.x

    master

    Upgrading to LinkKit 7.x provides several improvements over versions 5.x/6.x:

    • Reduced SDK Footprint: The LinkKit executable size has been reduced from ~6.4MB to ~2.5MB.
    • Native SwiftUI Support: Includes native modifiers like .plaidLink(isPresented:token:...), removing the need for UIViewControllerRepresentable wrappers.
    • Improved Reliability: Enhanced internal logging for session failures and higher reliability for LinkEvent delivery.
    • Better UX Control: Supports pre-initializing Link in the background so you can control exactly when the UI is presented, avoiding jarring loading states.
  2. How Session-based models work

    master

    The SDK uses specialized Session objects to enforce strict boundaries between different Plaid implementations. Each session type requires a specific link-token generated for that exact product.

    Important Constraints:

    • Token Mismatch: You cannot use a standard Link token to initialize a Layer or Headless session. Doing so will cause the session to fail immediately with an ExitError.
    • No Process Resumption: LinkKit 7 removes the ability to resume an in-progress flow after the host app process has been terminated. If the app relaunches, you must create a new session using a fresh or still-valid link token.
    • Objective-C Support: The core LinkKit module is Swift-only. To use Plaid in Objective-C, you must explicitly import the LinkKitObjC module.
  3. Privacy Manifest in LinkKit 5.0

    master
    LinkKit 5.0 includes a Privacy Manifest to comply with Apple's iOS 17 privacy practices. It discloses the approved usage of Apple's UserDefaults API (categorized under "required reasons API"). This addition is intended to prevent privacy transparency issues in your app and typically requires no action from developers.
  4. Migrate from CocoaPods to Swift Package Manager

    master

    Starting with LinkKit 7.x, CocoaPods is no longer a supported distribution method. To ensure your project remains secure and up-to-date, you must migrate to Swift Package Manager (SPM). This change aligns with the official CocoaPods retirement plan, where the central repository will become read-only on December 2nd, 2026.

    You can find the official SPM repository here: https://github.com/plaid/plaid-link-ios-spm.

    # Use Swift Package Manager (SPM) instead of CocoaPods for LinkKit 7.x
  5. Configure LinkDemo sample projects

    master

    The repository includes sample applications for Swift+UIKit, Swift+SwiftUI, and Objective-C.

    Important: Before building and running these demo projects, you must replace any Xcode placeholder strings (e.g., <#GENERATED_LINK_TOKEN#>) with a real Link token generated from your Plaid API. These placeholders are marked with compile-time warnings to help you identify them.

  6. Install Plaid Link via Swift Package Manager

    master

    You can install Plaid Link using Swift Package Manager (SPM). It is strongly recommended to use the plaid-link-ios-spm repository instead of the main plaid-link-ios repository. The main repository contains full git history (~1 GB), whereas the SPM repository is a lightweight pointer (< 500kb) to the precompiled XCFramework (~15MB), making downloads significantly faster.

    Using the Xcode Interface

    1. In Xcode, select File → Add Packages...
    2. Enter the URL: https://github.com/plaid/plaid-link-ios-spm.git

    Using Package.swift

    Add the following dependency to your Package.swift file:

    .package(url: "https://github.com/plaid/plaid-link-ios-spm.git", from: "7.0.0")

    Objective-C Integration

    For Objective-C projects, use the LinkKitObjC product from the plaid-link-ios-spm repository and import the LinkKitObjC module.

  7. Migrate from Handler-based to Session-based API

    master

    LinkKit 7.x introduces a breaking change by replacing the single Handler API with specialized Session objects. Instead of calling Plaid.create, you must now use specific methods for each flow (Standard Link, Layer, Headless, or Embedded).

    Key Changes:

    • Specialized Sessions: Use Plaid.createPlaidLinkSession, Plaid.createPlaidLayerSession, Plaid.createHeadlessSession, or Plaid.createEmbeddedLinkView depending on your implementation.
    • Configuration: onLoad is now a standard property within the LinkTokenConfiguration struct rather than a separate parameter.
    • Retention: You must explicitly retain the returned Session object (e.g., as a @State or class property) to prevent it from being deallocated during the flow.
    • Error Handling: New session creation methods throw errors if setup fails, requiring do-catch blocks instead of handling a Result type from Plaid.create.
    // New Way: Using specialized session creation
    do {
      let session = try Plaid.createPlaidLinkSession(configuration: configuration)
      // Must retain session!
      self.linkSession = session
      session.open(using: .viewController(self))
    } catch {
      print(error)
    }
  8. Validate plaid-link-ios-spm package authenticity

    master
    When using plaid-link-ios-spm, the downloaded LinkKit.xframework will not be visible in the Xcode project navigator. To verify the package is authentic, check that the Package.swift file within the dependency references a binary XCFramework hosted at https://github.com/plaid/plaid-link-ios/releases.