FBLogin libc++abi.dylib:以 NSException 类型的未捕获异常终止
FBLogin libc++abi.dylib: terminating with uncaught exception of type NSException
我已经根据 FB doco 配置了所有内容 https://developers.facebook.com/docs/ios/getting-started/ 但是我的应用程序在单击 FBLoginButton
后崩溃了,您能告诉我我的代码中缺少什么吗?
这是我的播客
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
我正在基于 swift 4.2
、xcode 10
和 ios 12
进行开发
这是我的 AppDelegate 代码和 ViewController:
AppDelegate
import UIKit
import FBSDKCoreKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application,
didFinishLaunchingWithOptions: launchOptions)
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = UINavigationController(rootViewController: ViewController())
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let handled = FBSDKApplicationDelegate.sharedInstance().application(app, open: url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as! String?, annotation: options[UIApplication.OpenURLOptionsKey.annotation])
return handled
}
//...
}
和ViewController
import UIKit
import FBSDKLoginKit
class ViewController: UIViewController, FBSDKLoginButtonDelegate{
override func viewDidLoad() {
super.viewDidLoad()
let loginButton = FBSDKLoginButton()
view.addSubview(loginButton)
loginButton.frame = CGRect(x: 16, y: 50, width: view.frame.width - 32, height: 50)
loginButton.delegate = self
}
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
if error != nil {
print(error)
return
}
print("Successfully logged in with facebook...")
}
func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {
print("Did log out of facebook")
}
}
我在info.plist
中的以下配置中错过了添加APP_ID 添加app_ID后,应用程序连接到FB。
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb{APP_ID}</string>
</array>
</dict>
</array>
我已经根据 FB doco 配置了所有内容 https://developers.facebook.com/docs/ios/getting-started/ 但是我的应用程序在单击 FBLoginButton
后崩溃了,您能告诉我我的代码中缺少什么吗?
这是我的播客
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
我正在基于 swift 4.2
、xcode 10
和 ios 12
进行开发
这是我的 AppDelegate 代码和 ViewController:
AppDelegate
import UIKit
import FBSDKCoreKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application,
didFinishLaunchingWithOptions: launchOptions)
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = UINavigationController(rootViewController: ViewController())
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let handled = FBSDKApplicationDelegate.sharedInstance().application(app, open: url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as! String?, annotation: options[UIApplication.OpenURLOptionsKey.annotation])
return handled
}
//...
}
和ViewController
import UIKit
import FBSDKLoginKit
class ViewController: UIViewController, FBSDKLoginButtonDelegate{
override func viewDidLoad() {
super.viewDidLoad()
let loginButton = FBSDKLoginButton()
view.addSubview(loginButton)
loginButton.frame = CGRect(x: 16, y: 50, width: view.frame.width - 32, height: 50)
loginButton.delegate = self
}
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
if error != nil {
print(error)
return
}
print("Successfully logged in with facebook...")
}
func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {
print("Did log out of facebook")
}
}
我在info.plist
中的以下配置中错过了添加APP_ID 添加app_ID后,应用程序连接到FB。
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb{APP_ID}</string>
</array>
</dict>
</array>