ETDistribution is a Swift library that simplifies the process of distributing new app versions and checking for updates. It provides an easy-to-use API to verify if a new version is available and handles the update process seamlessly, ensuring your users are always on the latest release.
- 🚀 Automatic Update Check: Quickly determine if a new version is available.
- 🔑 Secure: No data is stored locally.
- 🎯 Objective-C Compatibility: Provides compatibility with both Swift and Objective-C.
- 🛠️ Flexible Update Handling: Customize how you handle updates.
- iOS 13.0+
- Xcode 12.0+
- Swift 5.0+
To integrate ETDistribution into your project, add the following line to your Package.swift:
dependencies: [
.package(url: "https://github.com/EmergeTools/ETDistribution.git", from: "v0.1.0")
]
- Clone the repository.
- Drag the ETDistribution folder into your Xcode project.
The ETDistribution library provides a simple API to check for updates:
import UIKit
import ETDistribution
ETDistribution.shared.checkForUpdate(apiKey: "YOUR_API_KEY") { result in
switch result {
case .success(let releaseInfo):
if let releaseInfo {
print("Update found: \(releaseInfo)")
guard let url = ETDistribution.shared.buildUrlForInstall(releaseInfo.downloadUrl) else {
return
}
DispatchQueue.main.async {
UIApplication.shared.open(url) { _ in
exit(0)
}
}
} else {
print("Already up to date")
}
case .failure(let error):
print("Error checking for update: \(error)")
}
}
For Objective-C:
[[ETDistribution sharedInstance] checkForUpdateWithApiKey:@"YOUR_API_KEY"
tagName:nil
onReleaseAvailable:^(DistributionReleaseInfo *releaseInfo) {
NSLog(@"Release info: %@", releaseInfo);
}
onError:^(NSError *error) {
NSLog(@"Error checking for update: %@", error);
}];
If you do not provide a completion handler, a default UI will be shown asking if the update should be installed.
An API key is required to authenticate requests. You can obtain your API key from the Emerge Tools dashboard. Once you have the key, you can pass it as a parameter to the checkForUpdate
method.
Tags can be used to associate builds, you could use tags to represent the dev branch, an internal project or any team builds. If the same binary has been uploaded with multiple tags, you can specify a tagName to differentiate between them. This is usually not needed, as the SDK will identify the tag automatically.
By default, if no completion closure is provided, the SDK will present an alert to the user, prompting them to install the release. You can customize this behavior using the closures provided by the API.
To see ETDistribution in action, check out our example project. The example demonstrates how to integrate and use the library in both Swift and Objective-C projects.
For more detailed documentation and additional examples, visit our Documentation Site.
The library is designed to skip update checks on the simulator. To test update functionality, run your app on a physical device.
When handling the response you can check the release version field to decide if it should be installed or not.