I faced the same problem recently and my workaround is to create a view modifier for authenticated views and use it only for such screens/views:
import SwiftUI
struct GuardedOnAppearViewModifier: ViewModifier {
let perform: () -> Void
@EnvironmentObject private var accountState: AccountState
func body(content: Content) -> some View {
content
.onAppear {
guard accountState.isAuthorized else { return }
perform()
}
}
}
extension View {
func onGuardedAppear(perform: @escaping () -> Void) -> some View {
modifier(GuardedOnAppearViewModifier(perform: perform))
}
}
So when I'm logging out none of my onAppear method of authorized views will be called during the removal of NavigationView.
Post
Replies
Boosts
Views
Activity
I have the same issue and as figured it out some of my pods installed by Cocoapods causing it, because for example when I deleted Firebase pods, "Export Localizations" build worked fine. But still I don't know how to fix it by keeping needed pods
A workaround is to call the async version of the function like this:
Task {
let result = await ATTrackingManager.requestTrackingAuthorization()
// ...
}
Because it looks like they broke only the function with completion handler:
ATTrackingManager.requestTrackingAuthorization(completionHandler: { _ in })