SDKApplicationDelegate Use of unresolved identifier
Asked Answered
N

3

20

I have two pods installed for facebook login

pod 'FacebookCore'
pod 'FacebookLogin'

than imported FacebookCore in appdelegate. still it shows use of unresolved identifier error.

unresolved identifier error

I have also implemented tags in info.plist

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

Still not able to get SDKApplicationDelegate.

func application(_ app: UIApplication, open url: URL,
                 options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
    if SDKApplicationDelegate.shared.application(app, open: url, options: options) {
        return true
    }
    return false
}
Nutt answered 15/5, 2019 at 8:52 Comment(1)
instead of the answer, your question solved my issue, thank you : )Abri
G
41

Its because SDKApplicationDelegate is changed to 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
}

One more thing to do

class AppDelegate: UIResponder, UIApplicationDelegate

Also import these two pods

import FBSDKCoreKit
import FBSDKLoginKit 
Germander answered 15/5, 2019 at 8:59 Comment(4)
The error I get with this is ... Use of unresolved identifier 'ApplicationDelegate'; did you mean 'UIApplicationDelegate'? Replace 'ApplicationDelegate' with 'UIApplicationDelegate'Nutt
This return statement will work for all app switching? I have google, linkedIn, facebook. so this will work just for facebook or all of them?Nutt
@KrutikaSonawala....yes please see this #35510910Germander
Thanks for your help. Not sure why facebook have not there quick start guide linesGiagiacamo
L
12

Details

  • Xcode Version 10.3 (10G8)
  • Swift 5
  • FacebookCore (0.7.0)

Solution

just replace SDKApplicationDelegate with ApplicationDelegate

Code

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
}
Lillalillard answered 23/7, 2019 at 19:3 Comment(1)
This works as stated with swift 5 as of July 2019. Thanks!Led
B
1

To be able to have facebook login add these 2 methods

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)
}

import FBSDKCoreKit

import FBSDKLoginKit
Bolden answered 15/5, 2019 at 9:4 Comment(2)
with this the error is: Use of unresolved identifier 'FBSDKApplicationDelegate'; did you mean 'UIApplicationDelegate'? Replace 'FBSDKApplicationDelegate' with 'UIApplicationDelegate'Nutt
Importing will convert the code same as above answer. so this worked.Nutt

© 2022 - 2024 — McMap. All rights reserved.