FBLogin libc abi.dylib: завершается с неперехваченным исключением типа NSException

#ios #swift #xcode #dylib

#iOS #swift #xcode #dylib

Вопрос:

Я настроил все на основе документа FB 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:

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

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