p2 / OAuth2

OAuth2 framework for macOS and iOS, written in Swift.
Other
1.14k stars 275 forks source link

Xcode 14 Beta will get "This method should not be called on the main thread as it may lead to UI unresponsiveness." warning #399

Closed rushairer closed 5 months ago

rushairer commented 1 year ago

Run as a Mac app in macOS 13 beta with Xcode 14 beta, I got this warning infomation.

This method should not be called on the main thread as it may lead to UI unresponsiveness.
2022-09-21_00-05-34

func authorize() {

#if os(iOS)
        let rootViewController = (UIApplication.shared.connectedScenes.first as? UIWindowScene)?.windows.first?.rootViewController
#elseif os(macOS)
        let rootViewController = NSApplication.shared.keyWindow?.windowController
#endif

        if rootViewController != nil {
            self.oauth.authConfig.authorizeEmbedded = true
            self.oauth.authConfig.authorizeContext = rootViewController
            self.oauth.authConfig.ui.useSafariView = false
            self.oauth.authConfig.ui.useAuthenticationSession = true
            self.oauth.authConfig.ui.prefersEphemeralWebBrowserSession = true
        }

        self.oauth.authorize() { [unowned self] authParameters, error in
            if let error = error {
                print("Authorization was canceled or went wrong: \(error).")
            } else {
                fetchViewer()
            }
        }
    }
ossus-lib commented 5 months ago

I don't think this is a real issue, reopen if it is.