FBLogin libc ++ abi.dylib: завершается с необработанным исключением типа NSException - PullRequest
1 голос
/ 10 апреля 2019

Я настроил все на основе 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")
}
}

1 Ответ

1 голос
/ 10 апреля 2019

Я пропустил добавление APP_ID в следующей конфигурации в info.plist После добавления app_ID приложение подключилось к FB.

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb{APP_ID}</string>
        </array>
    </dict>
</array>
...