Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift SDKApplicationDelegate未解析标识符的使用_Swift_Fbsdk_Fbsdkloginkit - Fatal编程技术网

Swift SDKApplicationDelegate未解析标识符的使用

Swift SDKApplicationDelegate未解析标识符的使用,swift,fbsdk,fbsdkloginkit,Swift,Fbsdk,Fbsdkloginkit,我已经为facebook登录安装了两个pod pod 'FacebookCore' pod 'FacebookLogin' 而不是在appdelegate中导入FacebookCore。它仍然显示未解决的标识符错误的使用 我还在info.plist中实现了标记 <array> <string>fb---------</string> </array> <key>FacebookAppID</key> <string

我已经为facebook登录安装了两个pod

pod 'FacebookCore'
pod 'FacebookLogin'
而不是在appdelegate中导入FacebookCore。它仍然显示未解决的标识符错误的使用

我还在info.plist中实现了标记

<array>
<string>fb---------</string>
</array>
<key>FacebookAppID</key>
<string>-----------</string>
<key>FacebookDisplayName</key>
<string>-----------</string>

其原因是
SDKApplicationDelegate
更改为
ApplicationDelegate

func application(_ app: UIApplication, open url: URL,
                 options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
    if ApplicationDelegate.shared.application(app, open: url, options: options) {
        return true
    }
    return false
}
还有一件事要做

class AppDelegate: UIResponder, UIApplicationDelegate
也要导入这两个豆荚

import FBSDKCoreKit
import FBSDKLoginKit 

要让facebook登录,请添加以下两种方法

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

    if #available(iOS 9.0, *) {
        let sourceApplication: String? = options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String
        return FBSDKApplicationDelegate.sharedInstance().application(app, open: url,sourceApplication: sourceApplication, annotation: nil)
    }

    return true
}

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {

    return FBSDKApplicationDelegate.sharedInstance().application(application, open: url as URL?, sourceApplication: sourceApplication, annotation: annotation)
}

细节
  • Xcode版本10.3(10G8)
  • 斯威夫特5
  • FacebookCore(0.7.0)
解决方案 只需将
SDKApplicationDelegate
替换为
ApplicationDelegate

func application(_ app: UIApplication, open url: URL,
                 options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
    if ApplicationDelegate.shared.application(app, open: url, options: options) {
        return true
    }
    return false
}
代码
我犯的错误是。。。使用未解析标识符“ApplicationLegate”;你是说“大使”吗?将“ApplicationLegate”替换为“UIApplicationLegate”。此返回语句是否适用于所有应用程序切换?我有谷歌,linkedIn,facebook。那么这只适用于facebook还是所有人?@KrutikaSonawala……是的,请看这个谢谢你的帮助。不确定facebook为什么没有快速入门指南行,错误是:使用未解析标识符“FBSDKApplicationDelegate”;你是说“大使”吗?将“FBSDKApplicationDelegate”替换为“UIApplicationDelegate”,导入将转换与上述答案相同的代码。这是有效的。这是截至2019年7月swift 5的规定。谢谢你的问题解决了我的问题,而不是答案,谢谢:)
import FBSDKCoreKit

import FBSDKLoginKit
import FacebookCore

//....

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 {
    guard let urlScheme = url.scheme else { return false }
    if urlScheme.hasPrefix("fb") {
        return ApplicationDelegate.shared.application(app, open: url, options: options)
    }
    return true
}