Skip to content

Commit ed600f4

Browse files
committed
feat: Add iOS auto-update SDK
1 parent fc78960 commit ed600f4

File tree

8 files changed

+112
-19
lines changed

8 files changed

+112
-19
lines changed

docs/platforms/android/build-distribution/auto-update.mdx

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,7 @@ Make sure your Sentry Java version is at least 8.27.0 and you have the [Sentry A
2121

2222
You'll also need an [internal integration token](#create-an-integration-token) with Build Distribution permissions.
2323

24-
## Create an Integration Token
25-
26-
To use the Auto-Update SDK, you need to create an internal integration token with the appropriate permissions:
27-
28-
1. Navigate to **Settings > Custom Integrations** in your Sentry organization
29-
2. Click **Create New Integration**
30-
![Create New Integration =800x](./images/create-new-integration.png)
31-
32-
3. Select **Internal Integration** and click **Next**
33-
![Internal Integration =600x](./images/internal-integration.png)
34-
35-
4. Give your integration a name (e.g., "Build Distribution")
36-
![Name token =800x](./images/name-token.png)
37-
5. Under **Permissions**, select **Read** next to the **Distribution** scope.
38-
![Set Permissions =800x](./images/set-permissions.png)
39-
6. Click **Save Changes**
40-
7. Scroll down to the Tokens section and click **New Token**
41-
![Create New Token =800x](./images/create-auth-token.png)
42-
8. Copy the generated token to your CI secrets as an environment `SENTRY_DISTRIBUTION_AUTH_TOKEN`
24+
<Include name="build-distribution/create-integration-token" />
4325

4426
## Installation
4527

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: Auto-Update SDK
3+
sidebar_title: Auto-Update SDK
4+
sidebar_order: 10
5+
description: Enable automatic update checks and installations for internal iOS builds using the Sentry Auto-Update SDK.
6+
---
7+
8+
<Include name="feature-available-for-user-group-early-adopter" />
9+
10+
<Alert level="warning">
11+
12+
The Auto-Update SDK is designed for **internal builds only** and should never be used in production builds distributed through the App Store.
13+
14+
</Alert>
15+
16+
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.
17+
18+
## Pre-requisites
19+
20+
The SDK can only be installed using Swift Package Manager.
21+
22+
You'll also need an [internal integration token](#create-an-integration-token) with Build Distribution permissions.
23+
24+
<Include name="build-distribution/create-integration-token" />
25+
26+
## Installation
27+
28+
Add a dependency on the `SentryDistribution` target contained in the sentry-cocoa package (https://github.com/getsentry/sentry-cocoa)
29+
30+
```swift {filename:Package.swift}
31+
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "{{@inject packages.version('sentry.cocoa') }}"),
32+
33+
.target(name: "MyTarget", dependencies: ["SentryDistribution"]),
34+
```
35+
36+
## Usage
37+
38+
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:
39+
40+
```swift {filename:MyView.swift}
41+
import SentryDistribution
42+
import SwiftUI
43+
44+
struct MyView: View {
45+
var body: some View {
46+
Button("Check For Update") {
47+
UpdateUtil.checkForUpdates()
48+
}
49+
}
50+
}
51+
52+
enum UpdateUtil {
53+
static func checkForUpdates() {
54+
let params = CheckForUpdateParams(
55+
accessToken: "MY_TOKEN",
56+
organization: "MY_ORGANIZATION",
57+
project: "MY_PROJECT")
58+
Updater.checkForUpdate(params: params) { result in
59+
handleUpdateResult(result: result)
60+
}
61+
}
62+
63+
static func handleUpdateResult(result: Result<UpdateCheckResponse, Error>) {
64+
guard case let .success(releaseInfo) = result else {
65+
if case let .failure(error) = result {
66+
print("Error checking for update: \(error)")
67+
}
68+
return
69+
}
70+
71+
guard let releaseInfo = releaseInfo.update else {
72+
print("Already up to date")
73+
return
74+
}
75+
76+
guard let url = Updater.buildUrlForInstall(releaseInfo.downloadUrl) else {
77+
return
78+
}
79+
DispatchQueue.main.async {
80+
Updater.install(url: url)
81+
}
82+
}
83+
}
84+
```
85+
86+
## Security Considerations
87+
88+
- **Internal Use Only**: Never ship the auto-update SDK in production builds destined for public app stores
89+
- **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.
90+
91+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Create an Integration Token
2+
3+
To use the Auto-Update SDK, you need to create an internal integration token with the appropriate permissions:
4+
5+
1. Navigate to **Settings > Custom Integrations** in your Sentry organization
6+
2. Click **Create New Integration**
7+
![Create New Integration =800x](./images/create-new-integration.png)
8+
9+
3. Select **Internal Integration** and click **Next**
10+
![Internal Integration =600x](./images/internal-integration.png)
11+
12+
4. Give your integration a name (e.g., "Build Distribution")
13+
![Name token =800x](./images/name-token.png)
14+
5. Under **Permissions**, select **Read** next to the **Distribution** scope.
15+
![Set Permissions =800x](./images/set-permissions.png)
16+
6. Click **Save Changes**
17+
7. Scroll down to the Tokens section and click **New Token**
18+
![Create New Token =800x](./images/create-auth-token.png)
19+
8. Copy the generated token to your CI secrets as an environment `SENTRY_DISTRIBUTION_AUTH_TOKEN`
20+

0 commit comments

Comments
 (0)