Posts

Post marked as solved
1 Replies
1.3k Views
Hello. I am trying to make a router object for my application using @EnvironmentObject. But the problem is the @Published property doesn't update the root view when the root view type is updated. How it should work A user clicks Sign in with Apple button Update the router.currentPage property of @EnvironmentObject when a user logs in successfully. RootView get notified for updating router.currentPage and change the root view in accordance to the updated currentPage type. Here are my codes below. MainApp.swift var body: some Scene {   WindowGroup { RootView().environmentObject(ViewRouter())   } } ViewRouter.swift enum Page {  case signin  case tasklist } final class ViewRouter: ObservableObject {  @Published var currentPage: Page = .signin  } RootView.swift struct RootView: View {  @EnvironmentObject var router: ViewRouter  var body: some View {   if router.currentPage == .signin {    SigninView()   } else {    TaskListView()   }  } } SigninView.swift struct SigninView: View {  @EnvironmentObject var router: ViewRouter  @State var signInHandler: SignInWithAppleCoordinator?     var window: UIWindow? {   guard let scene = UIApplication.shared.connectedScenes.first,      let windowSceneDelegate = scene.delegate as? UIWindowSceneDelegate,      let window = windowSceneDelegate.window else {    return nil   }   return window  }     var body: some View {   MyAppleIDButton().colorScheme(.light)    .frame(width: 280, height: 38, alignment: .center)    .onTapGesture {     signInWithAppleButtonTapped()    }  }     func signInWithAppleButtonTapped() {   guard let _window = self.window else { return }   signInHandler = SignInWithAppleCoordinator(window: _window)   signInHandler?.signIn { (user) in    router.currentPage = .tasklist   }  } }
Posted
by DEVFIT.
Last updated
.
Post not yet marked as solved
1 Replies
425 Views
Hello.I have two issues related to Apple Watch development.1. Cannot pairing Apple Watch with iPhone.I cannot see my Apple Watch pariing with iPhone in the Device menu of Xcode. It shows "null" value of paired Apple Watch.But actually Apple Watch is working well with iPhone.2. Automatic Code Signing issueI developed watchos independent app based on watchos 6 and then I tried to do Automatic Code Signing.By the way Xcode doesn't create an app id in the developer portal.Pleaes let me know if someone can help me.Thanks
Posted
by DEVFIT.
Last updated
.