Facebook for swift 4.2 执行错误

Facebook for swift 4.2 implementation error

您好,我正在做一个需要 Facebook 登录按钮才能让我们的用户使用 Facebook 帐户登录的项目。但问题是我收到错误。文档似乎很旧,而且无论如何都不起作用。 Here 用于 swift.

我的项目有 swift 4.2。在我的 pod 文件中,我使用了以下依赖项

pod 'FacebookCore' 
pod 'FacebookLogin'

在我的 AppDelegate 中,以下是我的代码

import FacebookCore

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
  SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
  return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
  return SDKApplicationDelegate.shared.application(app, open: url, options: options)
}

我收到以下错误。不管我构建我的项目多少次,清理它多少次

Error: Use of unresolved identifier 'SDKApplicationDelegate'

请告诉我这里有什么问题?我必须在这里做什么以及我缺少什么。如果 swift 有什么好的教程请分享给我 link

谢谢

最近发现一个项目实现FB登录。开始了

在 Podfile 中 pod 'FBSDKLoginKit'

在 AppDelegate 中

import UIKit
import FBSDKCoreKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        ApplicationDelegate
            .shared
            .application(application,
                         didFinishLaunchingWithOptions: launchOptions)
        ...
        return true
    }

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

            return ApplicationDelegate.shared.application(app, open: url, options: options)
    }
}

编辑 2019/10/29

测试 https://developers.facebook.com/docs/swift/implement-the-sdk

播客文件:

  pod 'FacebookCore'
  pod 'FacebookLogin'
  pod 'FacebookShare'

AppDelegate:

import UIKit
import FacebookCore

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        ...

        ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
        return true
    }

    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        return ApplicationDelegate.shared.application(app, open: url, options: options)
    }
}

看来他们在文档中犯了一个错误,SDKApplicationDelegate 必须重命名 ApplicationDelegate