ios - 在 SwiftUI 中使用谷歌登录时来自 OIDAuthorizationService 的 NSInvalidArgumentException

标签 ios swift xcode swiftui google-signin

这个陌生的错误让我度过了糟糕的一天

    2020-08-15 10:00:38.630941+0100 Wicrypt[44349:3718177] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[OIDAuthorizationService presentAuthorizationRequest:presentingViewController:callback:]: unrecognized selector sent to class 0x106b47af0'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000107dfb4b2 __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x0000000107a4b26e objc_exception_throw + 48
    2   CoreFoundation                      0x0000000107e09f12 __CFExceptionProem + 0
    3   CoreFoundation                      0x0000000107dff9e8 ___forwarding___ + 1479
    4   CoreFoundation                      0x0000000107e01a18 _CF_forwarding_prep_0 + 120
    5   Wicrypt                             0x0000000106aac8d2 -[GIDSignIn authenticateInteractivelyWithOptions:] + 626
    6   Wicrypt                             0x0000000106aacd5f -[GIDSignIn authenticateWithOptions:] + 74
    7   Wicrypt                             0x0000000106aac59a -[GIDSignIn signInWithOptions:] + 509
    8   Wicrypt                             0x0000000106aabde6 -[GIDSignIn signIn] + 64
    9   Wicrypt                             0x000000010671810b $s7Wicrypt18GoogleSignInScreenV4bodyQrvg7SwiftUI9TupleViewVyAE0J0PAEE5frame5width6height9alignmentQr12CoreGraphics7CGFloatVSg_AqE9AlignmentVtFQOyAE6SpacerV_Qo__AiEEAjklMQrAQ_AqStFQOyAE6VStackVyAGyAE4TextV_AZtGG_Qo_AuzE6ButtonVyAZGtGyXEfU_yycfU0_ + 91
    10  SwiftUI                             0x00000001095e1d91 $s7SwiftUI18WrappedButtonStyle33_AEEDD090E917AC57C12008D974DC6805LLV4BodyV4bodyQrvgyycAA09PrimitivedE13ConfigurationVcfu_yycfu0_TA + 17
    11  SwiftUI                             0x000000010989c000 $s7SwiftUI25PressableGestureCallbacksV8dispatch5phase5stateyycSgAA0D5PhaseOyxG_SbztFyycfU_ + 32
    12  SwiftUI                             0x0000000109657bac $sIeg_ytIegr_TR + 12
    13  SwiftUI                             0x00000001094dc901 $sIeg_ytIegr_TRTA + 17
    14  SwiftUI                             0x00000001094fbcd9 $sIeg_ytIegr_TRTA.1980 + 9
    15  SwiftUI                             0x0000000109657bcc $sytIegr_Ieg_TR + 12
    16  SwiftUI                             0x0000000109657bac $sIeg_ytIegr_TR + 12
    17  SwiftUI                             0x000000010964a791 $sIeg_ytIegr_TRTA + 17
    18  SwiftUI                             0x000000010964a044 $s7SwiftUI6UpdateO3endyyFZ + 436
    19  SwiftUI                             0x0000000109688a9d $s7SwiftUI19EventBindingManagerC4sendyySDyAA0C2IDVAA0C4Type_pGF + 301
    20  SwiftUI                             0x0000000109ac2a9c $s7SwiftUI18EventBindingBridgeC4send_6sourceySDyAA0C2IDVAA0C4Type_pG_AA0cD6Source_ptFTf4nen_nAA22UIKitGestureRecognizerC_Tg5 + 2060
    21  SwiftUI                             0x0000000109ac0782 $s7SwiftUI22UIKitGestureRecognizerC4send025_062C14327F4C9197D92807A7H6DF7F3BLL7touches5event5phaseyShySo7UITouchCG_So7UIEventCAA10EventPhaseOtF + 66
    22  SwiftUI                             0x0000000109ac15e3 $s7SwiftUI22UIKitGestureRecognizerC12touchesBegan_4withyShySo7UITouchCG_So7UIEventCtFToTm + 131
    23  SwiftUI                             0x0000000109ac0858 $s7SwiftUI22UIKitGestureRecognizerC12touchesEnded_4withyShySo7UITouchCG_So7UIEventCtFTo + 40
    24  UIKitCore                           0x000000011388b2f5 -[UIGestureRecognizer _componentsEnded:withEvent:] + 217
    25  UIKitCore                           0x0000000113dd2162 -[UITouchesEvent _sendEventToGestureRecognizer:] + 674
    26  UIKitCore                           0x000000011387f6fb __47-[UIGestureEnvironment _updateForEvent:window:]_block_invoke + 70
    27  UIKitCore                           0x000000011387f380 -[UIGestureEnvironment _updateForEvent:window:] + 489
    28  UIKitCore                           0x0000000113d84bb8 -[UIWindow sendEvent:] + 4752
    29  UIKitCore                           0x0000000113d5e7dd -[UIApplication sendEvent:] + 408
    30  UIKitCore                           0x0000000113dee8c0 __processEventQueue + 15007
    31  UIKitCore                           0x0000000113de5398 __eventFetcherSourceCallback + 106
    32  CoreFoundation                      0x0000000107d69b04 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    33  CoreFoundation                      0x0000000107d69a43 __CFRunLoopDoSource0 + 157
    34  CoreFoundation                      0x0000000107d69187 __CFRunLoopDoSources0 + 222
    35  CoreFoundation                      0x0000000107d63c68 __CFRunLoopRun + 882
    36  CoreFoundation                      0x0000000107d63542 CFRunLoopRunSpecific + 538
    37  GraphicsServices                    0x0000000111c15db3 GSEventRunModal + 139
    38  UIKitCore                           0x0000000113d4014e -[UIApplication _run] + 912
    39  UIKitCore                           0x0000000113d451b1 UIApplicationMain + 101
    40  Wicrypt                             0x00000001066f786b main + 75
    41  libdyld.dylib                       0x000000010e009411 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[OIDAuthorizationService presentAuthorizationRequest:presentingViewController:callback:]: unrecognized selector sent to class 0x106b47af0'
terminating with uncaught exception of type NSException
CoreSimulator 732.7 - Device: iPhone 11 (7A79AEEA-ED4B-4DCD-BC33-81C73615B7A7) - Runtime: iOS 14.0 (18A5332e) - DeviceType: iPhone 11

我已经设置了必要的委托(delegate)

GIDSignIn.sharedInstance()?.delegate = googleDelegate

我也正确设置了呈现 Controller

GIDSignIn.sharedInstance()!.presentingViewController = window.rootViewController

我见过的最接近的资源是:https://openid.github.io/AppAuth-iOS/docs/latest/category_o_i_d_authorization_service_07_i_o_s_08.html#details

请提供任何帮助或引用

最佳答案

这可能是来自 docs 的必要步骤如果您不使用 pod:

Add the ObjC linker flag to the app target's build settings:

Other Linker Flags: $(OTHER_LDFLAGS) -ObjC

关于ios - 在 SwiftUI 中使用谷歌登录时来自 OIDAuthorizationService 的 NSInvalidArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63421507/

相关文章:

ios - 在 Xcode 6 中添加多个第三方 SDK 时搜索库路径

ios - exceptedActivityTypes 在 Swift 3 中不起作用

SWIFT:仅获取路径

ios - 如何防止 UITableView 向下滚动?

iphone - Xcode 调试器 : view value of variable

c++ - 我可以在 XCode 4 或 OSX Lion 中使用 C++11 的最新功能吗?

ios - 如何设置 SKProductsRequest 超时秒? SKProductsRequest 的默认超时秒数是多少?

ios - UILabel 自动调整大小 Swift

c++ - 将 C++ 库集成到 iPhone 应用程序中

ios - 如何在 Xcode 中导出应用程序文件