Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
eonist committed Oct 15, 2023
1 parent c6f9385 commit d5e4a24
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 24 deletions.
1 change: 0 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ let package = Package(
/*swiftLanguageVersions: [.v5],*/
/*url: "https://github.com/sentryco/UpgradeAlert",*/
/*description: "A Swift package for showing upgrade alerts."*/

4 changes: 2 additions & 2 deletions Sources/UpgradeAlert/UpgradeAlert+Variables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extension UpgradeAlert {
* Default completion handler function.
* This function simply prints the outcome of the operation.
*/
public static let defaultComplete: Complete = { outcome in
public static let defaultComplete: Complete = { outcome in
Swift.print("default complete - outcome: \(String(describing: outcome))")
}
}
Expand All @@ -54,4 +54,4 @@ extension UpgradeAlert {
* - Note: By default, it uses the default configuration defined in UAConfig.
*/
public static var config: UAConfig = .defaultConfig
}
}
10 changes: 5 additions & 5 deletions Sources/UpgradeAlert/UpgradeAlert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension UpgradeAlert {
*/
public static func checkForUpdates(complete: Complete? = defaultComplete) { // complete: (_ appInfo: AppInfo?, error: NSError?)
// Perform network calls on a background thread
DispatchQueue.global(qos: .background).async {
DispatchQueue.global(qos: .background).async {
getAppInfo { appInfo, error in
// Fetch app information
guard let localVersion: String = Bundle.version, // Check if local version is available
Expand All @@ -48,10 +48,10 @@ extension UpgradeAlert {
return // Return from the function
} // No update needed, don't prompt user
// If an update is needed, show an alert on the main thread
DispatchQueue.main.async {
DispatchQueue.main.async {
Self.showAlert(appInfo: appInfo, complete: complete)
}
}
}
}
}
}
Expand Down Expand Up @@ -83,7 +83,7 @@ extension UpgradeAlert {
}
let result = try JSONDecoder().decode(LookupResult.self, from: data)
guard let info: AppInfo = result.results.first else { // Get the first app info from the result

throw NSError(domain: "no app info", code: 0) // If there is no app info, throw an NSError with the description "no app info"
}
completion?(info, nil)
Expand Down Expand Up @@ -155,4 +155,4 @@ extension UpgradeAlert {
}
#endif
}
}
}
2 changes: 1 addition & 1 deletion Sources/UpgradeAlert/ext/NSAlert+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ extension NSAlert {
//if anAlert.runModal() == .alertFirstButtonReturn {
// return .terminateNow
//}
//return .terminateLater
//return .terminateLater
2 changes: 1 addition & 1 deletion Sources/UpgradeAlert/ext/UIApplication+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ extension UIApplication {
.first { $0.isKeyWindow }
}
}
#endif
#endif
4 changes: 2 additions & 2 deletions Sources/UpgradeAlert/helper/AppInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct AppInfo: Decodable {
* The URL to the application's page on the App Store.
* This might be optional for macOS applications as they might not have an App Store page.
*/
public let trackViewUrl: String
public let trackViewUrl: String
/**
* Initializes a new instance of `AppInfo`.
* - Parameters:
Expand All @@ -28,4 +28,4 @@ public struct AppInfo: Decodable {
self.version = version
self.trackViewUrl = trackViewUrl
}
}
}
2 changes: 1 addition & 1 deletion Sources/UpgradeAlert/helper/LookupResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ struct LookupResult: Decodable {
// `results` is an array of `AppInfo` instances.
// Each `AppInfo` instance represents the information of an app retrieved from the Apple App Store API.
let results: [AppInfo]
}
}
8 changes: 4 additions & 4 deletions Sources/UpgradeAlert/helper/UAConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ public struct UAConfig {
/**
* Determines whether the upgrade is mandatory or optional.
*/
let isRequired: Bool
let isRequired: Bool
/**
* The title of the alert.
*/
let alertTitle: String
let alertTitle: String
/**
* The message of the alert. It's a function that takes the app name and version as parameters.
*/
let alertMessage: UpgradeAlert.AlertMessage
let alertMessage: UpgradeAlert.AlertMessage
/**
* The title of the button that allows the user to postpone the upgrade.
*/
Expand Down Expand Up @@ -67,4 +67,4 @@ extension UAConfig {
updateButtonTitle: "Update Now" // Default 'Update' button title.
)
}()
}
}
2 changes: 1 addition & 1 deletion Sources/UpgradeAlert/helper/UAError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public enum UAError: Error {
* The desc parameter provides more details about the error.
*/
case bundleErr(desc: String)
}
}
2 changes: 1 addition & 1 deletion Sources/UpgradeAlert/helper/UAOutcome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ public enum UAOutcome {
case notNow // The user has chosen to defer the upgrade.
case didOpenAppStoreToUpdate // The user has opened the App Store to perform the upgrade.
case error(error: UAError) // An error occurred during the upgrade process.
}
}
10 changes: 5 additions & 5 deletions Tests/UpgradeAlertTests/UpgradeAlertTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ final class UpgradeAlertTests: XCTestCase {
*/
func testUpdateCheck() throws {
// Skip the test if the app is in beta or running on a simulator because the update check will not work in these environments.
guard Bundle.isBeta else {
guard Bundle.isBeta else {
Swift.print("App is beta or simulator, skip checking for update")
return
return
}
// Call the checkForUpdates function of the UpgradeAlert module and handle the outcome.
UpgradeAlert.checkForUpdates { outcome in
UpgradeAlert.checkForUpdates { outcome in
if case .error(let err) = outcome {
Swift.print("Err: \(err.localizedDescription)")
} else {
} else {
// Opportunity to track user action here with GA etc
Swift.print("Outcome: \(String(describing: outcome))") // notNow, notNeeded, appStoreOpened
}
}
}
}
}

0 comments on commit d5e4a24

Please sign in to comment.