-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Add iOS auto-update SDK #15711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
noahsmartin
wants to merge
4
commits into
master
Choose a base branch
from
iOSUpdateSDK
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+105
−19
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
docs/platforms/apple/guides/ios/build-distribution/auto-update.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| --- | ||
| title: Auto-Update SDK | ||
| sidebar_title: Auto-Update SDK | ||
| sidebar_order: 10 | ||
| description: Enable automatic update checks and installations for internal iOS builds using the Sentry Auto-Update SDK. | ||
| --- | ||
|
|
||
| <Include name="feature-available-for-user-group-early-adopter" /> | ||
|
|
||
| <Alert level="warning"> | ||
|
|
||
| The Auto-Update SDK is designed for **internal builds only** and should never be used in production builds distributed through the App Store. | ||
|
|
||
| </Alert> | ||
|
|
||
| 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. | ||
|
|
||
| ## Pre-requisites | ||
|
|
||
| The SDK can only be installed using Swift Package Manager. | ||
|
|
||
| You'll also need an [internal integration token](#create-an-integration-token) with Build Distribution permissions. | ||
|
|
||
| <Include name="build-distribution/create-integration-token" /> | ||
|
|
||
| ## Installation | ||
|
|
||
| Add a dependency on the `SentryDistribution` target contained in the sentry-cocoa package (https://github.com/getsentry/sentry-cocoa) | ||
|
|
||
| ```swift {filename:Package.swift} | ||
| .package(url: "https://github.com/getsentry/sentry-cocoa", from: "{{@inject packages.version('sentry.cocoa') }}"), | ||
|
|
||
| .target(name: "MyTarget", dependencies: ["SentryDistribution"]), | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| 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: | ||
|
|
||
| ```swift {filename:MyView.swift} | ||
| import SentryDistribution | ||
| import SwiftUI | ||
|
|
||
| struct MyView: View { | ||
| var body: some View { | ||
| Button("Check For Update") { | ||
| UpdateUtil.checkForUpdates() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| enum UpdateUtil { | ||
| static func checkForUpdates() { | ||
| let params = CheckForUpdateParams( | ||
| accessToken: "MY_TOKEN", | ||
| organization: "MY_ORGANIZATION", | ||
| project: "MY_PROJECT") | ||
noahsmartin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Updater.checkForUpdate(params: params) { result in | ||
| handleUpdateResult(result: result) | ||
| } | ||
noahsmartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| static func handleUpdateResult(result: Result<UpdateCheckResponse, Error>) { | ||
| guard case let .success(releaseInfo) = result else { | ||
| if case let .failure(error) = result { | ||
| print("Error checking for update: \(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) | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Security Considerations | ||
|
|
||
| - **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. | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| ## Create an Integration Token | ||
|
|
||
| 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** | ||
|  | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: indentation |
||
| 8. Copy the generated token to your CI secrets as an environment `SENTRY_DISTRIBUTION_AUTH_TOKEN` | ||
|
|
||
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.