0

My app stopped to work after update to 16.5 In my second iPhone where I didn’t update the app work fine and on emulators too, the old versions are the 16.3.1. In my app I use firebase authentication, cloud messaging, realtime database. The login work fine, when I choose the city the user is correctly subscribed on the topic for manage the firebase cloud messaging but THE VIEW DON’T CHANGE after the click on the list of the cities managed by .ontapgesture where I set the value true of movetonextview and then I have the control of the view with an “if movenextview is true {set the scrollview with the buttons}”. I had verify that the movenextview and the city is setted correctly, when I relog, the app switched automatically the view correctly as it should do. Now when I tap on the button “change city” it should change the view but it doesn’t again. I checked toughly the code and I can’t find an error. The app doesn’t work ONLY on the device 16.5-16.6 when I put the app on the device 16.3.1 it works and it works on the emulator of Xcode too where the version is 16.1. Of course the debug don’t give me result when I tap the button.

Thanks for the attention.

Here piece of code that I used..



import SwiftUI

class ViewModel: ObservableObject {
 
    @Published var willMoveToNextScreen:Bool = false

}
struct ContentView: View {
    
    
    @StateObject var viewModel = ViewModel()
    
    @State var first5comuni:[String] = ["Roma", "Verona", "Milano"]
    
    var body: some View
    {
        if viewModel.willMoveToNextScreen == true {
            ScrollView {
                Button ("LocalizedStringKey", action: {
                    viewModel.willMoveToNextScreen = false
                })
            }
        }
        else  if viewModel.willMoveToNextScreen == false {
            
            ScrollView {
                ForEach(first5comuni, id: \.self) { index in
                    Text(index)
                        .opacity(0.5)
                        .frame(width: .infinity, height: 35, alignment: .center)
                        .onTapGesture {
                            viewModel.willMoveToNextScreen = true
                        }
                }
            }
            
        }
    }
}

I tried to upgrade the second iphone and the app stopped to work. I think is the new upgrade problem.

  • Why are you storing `willMoveToNextScreen` in user defaults (AppStorage)? Similarly with `willMovetoNextScreen2` - it is @ State but comes from some storage class. Clean up your navigation logic. – Paulw11 May 23 '23 at 08:21
  • Because I need to check after login if the stored value is true or false.. and if I remove the willMovetoNextScreen2 and I use only AppStorage the app stop work, I don't know why, maybe it can't receive the change true/false – Xing Guang Wu May 23 '23 at 09:42
  • Create a proper model object to manage your app state. Make it an @ObservableObject and publish the properties you need to manage your app's state. – Paulw11 May 23 '23 at 09:49
  • I did it but it works same... on the emulator is good but on device stopped work... – Xing Guang Wu May 23 '23 at 10:23
  • ` import SwiftUI class ViewModel: ObservableObject { @Published var willMoveToNextScreen:Bool = false } struct ContentView: View { @StateObject var viewModel =ViewModel() // // //` then i pick it with viewModel.willMoveToNextScreen, it's correct? – Xing Guang Wu May 23 '23 at 10:38
  • You should [edit] your question to include a [mcve] – Paulw11 May 23 '23 at 10:44
  • I can reproduce it but in the minimal example it works... when I use my code where I putted firebase messaging, firebase database, firebase authentication, json decode, it doesn't work.... only on emulator and ios 16.3.1 works... – Xing Guang Wu May 23 '23 at 11:26
  • I would suggest looking at the release notes to see what might be affecting your code this isn’t reproducible. – lorem ipsum May 23 '23 at 11:30

0 Answers0