Ios Swift Facebook登录在dispatch_中被破坏一次

Ios Swift Facebook登录在dispatch_中被破坏一次,ios,swift,facebook,Ios,Swift,Facebook,我正在尝试集成facebook登录,嗯: 我从开发者facebook网站下载了FacebookSDKs-iOS-4.18.0 2 之后,我在info.plist文件中添加了下一个xml: <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array&g

我正在尝试集成facebook登录,嗯:

我从开发者facebook网站下载了
FacebookSDKs-iOS-4.18.0 2

之后,我在
info.plist
文件中添加了下一个xml:

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb21200000000000</string>
            </array>
        </dict>
    </array>
    <key>FacebookAppID</key>
    <string>21200000000000</string>
    <key>FacebookDisplayName</key>
    <string>San Miguel Digital</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fb-messenger-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
    </array>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>{human-readable reason for photo access}</string>
LoginViewController.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    }
import Foundation
import UIKit
//import FacebookCore
//import FacebookLogin
import FBSDKCoreKit
import FBSDKLoginKit

class LoginViewController: UIViewController, FBSDKLoginButtonDelegate {

    override func viewDidLoad(){
        super.viewDidLoad()
        /*let loginButton = LoginButton(readPermissions: [ .publicProfile, .email ])
        loginButton.center = view.center

        view.addSubview(loginButton)*/

        if(FBSDKAccessToken.current() == nil){
            print("Is not logged in")
        }else{
            print("Currently is logged in")
        }

        let loginButton = FBSDKLoginButton()
        loginButton.readPermissions = ["public_profile", "email"]
        loginButton.center = self.view.center

        loginButton.delegate = self
        self.view.addSubview(loginButton)
    }

    func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {
        print("Logged out")
    }

    func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
        if(error == nil){
            print("Successfully logged")
        }else{
            print(error.localizedDescription)
        }
    }



}
当我在iphone设备上执行应用程序时,facebook登录按钮出现,但在日志错误中,我得到:

未登录到libc++abi.dylib:以未捕获异常终止 类型NSException警告:无法加载任何Objective-C类 信息。这将大大降低类型的质量 现有资料


我做错了什么?

您可能错过了两个功能。你可以通过谷歌“iOS Facebook登录”找到详细信息,然后选择第一个链接。我所做的完全按照指示去做

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
        FBSDKAppEvents.activateApp()
    }

    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

        return FBSDKApplicationDelegate.sharedInstance().application(app, open: url, options: options)
    }
我在
func loginButton
中检查您的实现。有一个示例可能是更好的实践:

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
    guard error == nil else {
        print("Login Error: \(error)" )
            return
    }

    if let token = FBSDKAccessToken.current()  {   
        if let req = FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"name"], tokenString: token.tokenString, version: nil, httpMethod: "GET") {        
            req.start() { 
                (conn, result, err) in
                if ((err) != nil) {
                    print("Error: \(err)")
                }
                else {
                    let data:[String:AnyObject] = result as! [String : AnyObject]
                    print("username: " + data["name"])
                }
            }
        }
    }
}

以NSException类型的未捕获异常终止
错误总是不止此消息。发布完整的异常日志和回溯。是否可以尝试使用Product->CleanFirst,发布完整的错误消息。第二,我上个月实现了这个功能。我非常确定AppDelegate至少应该添加3个函数。但是你似乎只添加了一个(或者在这里发布了一个?)@EricZhang这就是所有的错误,我试图显示更多,但是xcode不再显示。你能粘贴你正在使用的其他方法吗?也许我已经原谅了一些事情问题仍然存在
\u FuncPtr void(*)()(FBSDKCoreKit
\u46+[FBSDKInternalUtility isfacebook appinstalled]\u在FBSDKInternalUtility.m:493)0x0000000100e9e48c`
调度一次(&onceToken,^{[FBSDKInternalUtility checkregisteredcanopenurscheme:FBSDK\u CANOPENURL\u FACEBOOK]})这是代码。。。让我检查一下……顺便问一下,你确定FB21200000000是你的CbundleurlScheme吗?好的。我检查了两个CbundleurlScheme,FB21200000000非常奇怪…@Eic Zhang是一个示例ID,没有发布真实的