Localytics Causing Crash in SwiftUI - Could not cast value of type 'LLAppDelegateProxy' to 'SwiftUI.AppDelegate'

87 views Asked by At

I have a SwiftUI app and it uses Localytics for push notification. Recently in a view I added .focused(), and when entering this view, the app crashed with error "Could not cast value of type 'LLAppDelegateProxy' to 'SwiftUI.AppDelegate'".

It's not a big problem if the crash happens only to .focused. What worries me is I would see this crash in other places without knowing the root cause. Appreciate on any thought on this issue.

Here is how my app and view looks like:

@main
struct MyApp: App {
  @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
  ......
}
class AppDelegate: NSObject, UIApplicationDelegate {
  func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: LaunchOptions = nil) -> Bool {
    startLocalytics()
    true
  }
}
Struct MyView: View {
  @FocusState var isFocused: Bool
  var body: some View {
    TextField(......)
      .focused($isFocused)
  }
}
0

There are 0 answers