Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Xcodes/Backend/AppState+Update.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ extension AppState {
Current.defaults.setDate(Current.date(), forKey: "lastUpdated")
} catch is CancellationError {
} catch {
// Prevent setting the app state error if it is an invalid session, we will present the sign in view instead
if error as? AuthenticationError != .invalidSession {
if self.dataSource == .apple, Self.isUnauthorizedInstallError(error) || error as? AuthenticationError == .invalidSession {
// The Apple data source needs a developer session; ask the user to sign in rather than
// showing a raw 401.
self.presentedAlert = .unauthenticatedDataSource
} else if error as? AuthenticationError != .invalidSession {
// Prevent setting the app state error if it is an invalid session, we will present the sign in view instead
self.error = error
self.presentedAlert = .generic(title: localizeString("Alert.Update.Error.Title"), message: error.legibleLocalizedDescription)
}
Expand Down
2 changes: 2 additions & 0 deletions Xcodes/Frontend/Common/XcodesAlert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ enum XcodesAlert: Identifiable {
case generic(title: String, message: String)
case checkMinSupportedVersion(xcode: AvailableXcode, macOS: String)
case unauthenticated
case unauthenticatedDataSource

var id: Int {
switch self {
Expand All @@ -17,6 +18,7 @@ enum XcodesAlert: Identifiable {
case .checkMinSupportedVersion: return 4
case .cancelRuntimeInstall: return 5
case .unauthenticated: return 6
case .unauthenticatedDataSource: return 7
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions Xcodes/Frontend/MainWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,20 @@ struct MainWindow: View {
Text("Cancel")
)
)
case .unauthenticatedDataSource:
return Alert(
title: Text("Alert.Update.AuthError.Title"),
message: Text("Alert.Update.AuthError.Message"),
primaryButton: .default(
Text("Login"),
action: {
appState.presentedSheet = .signIn
}
),
secondaryButton: .cancel(
Text("Cancel")
)
)
case let .checkMinSupportedVersion(xcode, deviceVersion):
return Alert(
title: Text("Alert.MinSupported.Title"),
Expand Down
20 changes: 20 additions & 0 deletions Xcodes/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -4414,6 +4414,26 @@
}
}
},
"Alert.Update.AuthError.Message" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "The Apple data source lists Xcode releases from your Apple Developer account, so it needs you to be signed in. Sign in to refresh the list, or switch the data source to Xcode Releases in Settings."
}
}
}
},
"Alert.Update.AuthError.Title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Sign in to refresh from Apple"
}
}
}
},
"Alert.Update.Error.Title" : {
"comment" : "Update",
"extractionState" : "manual",
Expand Down