Auto-Update SDK

Enable automatic update checks and installations for internal iOS builds using the Sentry Auto-Update SDK.

The Sentry Auto-Update SDK enables your internal iOS builds to automatically check for and install newer versions distributed through Sentry's Build Distribution. This is particularly useful for distributing nightly, alpha, or beta builds to your internal teams. It is not required to use the Sentry crash reporting SDK to use the iOS Auto-Update SDK.

The SDK can only be installed using Swift Package Manager.

You'll also need an internal integration token with Build Distribution permissions.

To use the Auto-Update SDK, you need to create an internal integration token with the appropriate permissions:

  1. Navigate to Settings > Custom Integrations in your Sentry organization

  2. Click Create New Integration

  3. Select Internal Integration and click Next

  4. Give your integration a name (e.g., "Build Distribution")

  5. Under Permissions, select Read next to the Distribution scope.

  6. Click Save Changes

  7. Scroll down to the Tokens section and click New Token

  8. Save the generated token, you'll need it to integrate the SDK

Add a dependency on the SentryDistribution target contained in the sentry-cocoa package (https://github.com/getsentry/sentry-cocoa)

Package.swift
Copied
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "9.6.0"),

.target(name: "MyTarget", dependencies: ["SentryDistribution"]),

Use the SDK by calling Updater.checkForUpdate(params: ). In addition to the access token, provide your Sentry org and project slug in the CheckForUpdateParams. For example:

MyView.swift
Copied
import SentryDistribution
import SwiftUI

struct MyView: View {
  var body: some View {
    Button("Check For Update") {
      let params = CheckForUpdateParams(
        accessToken: "MY_TOKEN",
        organization: "___ORG_SLUG___",
        project: "___PROJECT_SLUG___")
      Updater.checkForUpdate(params: params) { result in
        handleUpdateResult(result: result)
      }
    }
  }
  
  static func handleUpdateResult(result: Result<UpdateCheckResponse, Error>) {
    guard case let .success(releaseInfo) = result else {
        // Handle error
        return
    }
    
    guard let releaseInfo = releaseInfo.update else {
      print("Already up to date")
      return
    }
    
    guard let url = Updater.buildUrlForInstall(releaseInfo.downloadUrl) else {
      return
    }
    DispatchQueue.main.async {
      Updater.install(url: url)
    }
  }
}

  • Internal Use Only: Never ship the auto-update SDK in production builds destined for public app stores
  • Token Security: The distribution token is embedded in the app and can be extracted by reverse engineering. Use tokens with only the distribution read permission which is the minimum required permission for the auto-update SDK.
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").