From Xcode 16.0 Beta I am getting the following error at didReceiveRemoteNotification of UIApplicationDelegate protocol:
Non-sendable type '[AnyHashable : Any]' in parameter of the protocol requirement satisfied by main actor-isolated instance method 'application(_:didReceiveRemoteNotification:)' cannot cross actor boundary; this is an error in the Swift 6 language mode
Generic struct 'Dictionary' does not conform to the 'Sendable' protocol (Swift.Dictionary)
How can I fix this warning before moving to Swift 6 mode.
@zoha131
Please add @MainActor
before the AppDelegate
class:
@MainActor
class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
UNUserNotificationCenter.current().delegate = self
return true
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) async -> UIBackgroundFetchResult {
return .noData
}
}