简体   繁体   中英

SWIFT: “terminating with uncaught exception of type NSException” when sign in with facebook

I'm working in a small application that support users to sign in with Facebook, most of the code that relates to sign in with Facebook I used and referenced from this website

However, when I compiled the code has an error:

> 2015-11-06 15:38:38.357 eber_ios[1048:31523] *** Terminating app due
> to uncaught exception 'InvalidOperationException', reason: 'fbauth2 is
> missing from your Info.plist under LSApplicationQueriesSchemes and is
> required for iOS 9.0'
> *** First throw call stack: (     0   CoreFoundation                      0x0000000101369f65 __exceptionPreprocess + 165  1   libobjc.A.dylib   
> 0x0000000103220deb objc_exception_throw + 48  2   eber_ios            
> 0x00000001010d14d1 __56+[FBSDKInternalUtility
> checkRegisteredCanOpenURLScheme:]_block_invoke + 0    3  
> libdispatch.dylib                   0x0000000103d0449b
> _dispatch_client_callout + 8  4   libdispatch.dylib                   0x0000000103cefe28 dispatch_once_f + 543    5   eber_ios                
> 0x00000001010d067f +[FBSDKInternalUtility isFacebookAppInstalled] +
> 241   6   eber_ios                            0x00000001010b65ba
> -[FBSDKLoginManager logInParametersWithPermissions:] + 360    7   eber_ios                            0x00000001010b6991
> -[FBSDKLoginManager logInWithBehavior:] + 50  8   eber_ios                            0x00000001010b6949 -[FBSDKLoginManager logInWithPermissions:handler:]
> + 238     9   eber_ios                            0x00000001010b5667 -[FBSDKLoginManager logInWithReadPermissions:fromViewController:handler:] + 257  10 
> eber_ios                            0x00000001010b2135
> -[FBSDKLoginButton _buttonPressed:] + 1082    11  UIKit                               0x0000000101dab1fa -[UIApplication sendAction:to:from:forEvent:] + 92
>   12  UIKit                               0x0000000101f0f504
> -[UIControl sendAction:to:forEvent:] + 67     13  UIKit                               0x0000000101f0f7d0 -[UIControl _sendActionsForEvents:withEvent:] + 311
>   14  UIKit                               0x0000000101f0e906
> -[UIControl touchesEnded:withEvent:] + 601    15  UIKit                               0x0000000101e15aa3 -[UIWindow _sendTouchesForEvent:] + 835  16  UIKit 
> 0x0000000101e16691 -[UIWindow sendEvent:] + 865   17  UIKit            
> 0x0000000101dc8752 -[UIApplication sendEvent:] + 263  18  UIKit       
> 0x0000000101da3fcc _UIApplicationHandleEventQueue + 6693  19 
> CoreFoundation                      0x00000001012960a1
> __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17   20  CoreFoundation                      0x000000010128bfcc
> __CFRunLoopDoSources0 + 556   21  CoreFoundation                      0x000000010128b483 __CFRunLoopRun + 867     22  CoreFoundation           
> 0x000000010128ae98 CFRunLoopRunSpecific + 488     23  GraphicsServices   
> 0x0000000106816ad2 GSEventRunModal + 161  24  UIKit                   
> 0x0000000101da9676 UIApplicationMain + 171    25  eber_ios              
> 0x00000001010b137d main + 109     26  libdyld.dylib                      
> 0x0000000103d3892d start + 1  27  ???                                
> 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with
> uncaught exception of type NSException

What causes this error and how can I fix it? I'm using FacebookSDK 4.1.

Thank you.

Thanks to Anthony, I added the following key

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbauth2</string>
</array>

to info.plist and it worked. Thank you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM