Skip to content

Commit bbec397

Browse files
committed
feat: add button to redirect user when this try to install a xcode version without signed
1 parent a434d26 commit bbec397

4 files changed

Lines changed: 31 additions & 1 deletion

File tree

Xcodes/Backend/AppState.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,11 @@ class AppState: ObservableObject {
610610
self.installationPublishers[id] = nil
611611
if case let .failure(error) = completion {
612612
// Prevent setting the app state error if it is an invalid session, we will present the sign in view instead
613-
if error as? AuthenticationError != .invalidSession {
613+
if let error = error as? AuthenticationError, case .notAuthorized = error {
614+
self.error = error
615+
self.presentedAlert = .unauthenticated
616+
617+
} else if error as? AuthenticationError != .invalidSession {
614618
self.error = error
615619
self.presentedAlert = .generic(title: localizeString("Alert.Install.Error.Title"), message: error.legibleLocalizedDescription)
616620
}

Xcodes/Frontend/Common/XcodesAlert.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ enum XcodesAlert: Identifiable {
77
case privilegedHelper
88
case generic(title: String, message: String)
99
case checkMinSupportedVersion(xcode: AvailableXcode, macOS: String)
10+
case unauthenticated
1011

1112
var id: Int {
1213
switch self {
@@ -15,6 +16,7 @@ enum XcodesAlert: Identifiable {
1516
case .generic: return 3
1617
case .checkMinSupportedVersion: return 4
1718
case .cancelRuntimeInstall: return 5
19+
case .unauthenticated: return 6
1820
}
1921
}
2022
}

Xcodes/Frontend/MainWindow.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,20 @@ struct MainWindow: View {
188188
action: { appState.presentedAlert = nil }
189189
)
190190
)
191+
case .unauthenticated:
192+
return Alert(
193+
title: Text("Alert.Install.Error.Title"),
194+
message: Text("Alert.Install.AuthError.Message"),
195+
primaryButton: .default(
196+
Text("OK"),
197+
action: {
198+
appState.presentedSheet = .signIn
199+
}
200+
),
201+
secondaryButton: .cancel(
202+
Text("Cancel")
203+
)
204+
)
191205
case let .checkMinSupportedVersion(xcode, deviceVersion):
192206
return Alert(
193207
title: Text("Alert.MinSupported.Title"),

Xcodes/Resources/Localizable.xcstrings

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,6 +1958,16 @@
19581958
}
19591959
}
19601960
},
1961+
"Alert.Install.AuthError.Message" : {
1962+
"localizations" : {
1963+
"en" : {
1964+
"stringUnit" : {
1965+
"state" : "translated",
1966+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
1967+
}
1968+
}
1969+
}
1970+
},
19611971
"Alert.Install.Error.Need.Xcode16.1" : {
19621972
"extractionState" : "manual",
19631973
"localizations" : {

0 commit comments

Comments
 (0)