Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Facebook Login Error - Unknown Error building URL (com.facebook.sdk.core error 3)

I am using Facebook login for my iOS app being developed for iOS 8 and onwards. (Latest Facebook SDK is being used)

I have followed all the essential steps described by the Facebook official guide. However, when I click the login button it gives me the following error:

Unknown Error building URL (com.facebook.sdk.core error 3)

I have checked, to look what I might have done wrong, but everything seems as per guide, and I have been stuck here for a day.

Code for FB Login Delegate:

class FBLoginDelegate: NSObject,  FBSDKLoginButtonDelegate  {


func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!){
    if(error == nil){
        print("Logged In from Btn")
    }else{
        print("Error: \(error.localizedDescription)") //Here it gives the error 
    }

}
}

Code for FB login button:

      var fbLoginBtnDelegate = FBLoginDelegate()
    let fbBtnWidth = self.view.bounds.width - (self.fbContainerLeftConstraint.constant + self.fbContainerRightConstraint.constant)
    let fbLoginButton = FBSDKLoginButton(frame: CGRectMake(0,0,fbBtnWidth,self.fbButtonContainer.bounds.size.height))

    self.fbButtonContainer.addSubview(fbLoginButton)
    fbLoginButton.readPermissions = ["public_profile", "user_friends", "email", "user_birthday"]
    fbLoginButton.delegate = fbLoginBtnDelegate
like image 414
Muhammad Sadiq Alvi Avatar asked Feb 07 '16 00:02

Muhammad Sadiq Alvi


3 Answers

If you upgraded the Facebook iOS SDK to version 4.39.0, there is a bug that causes this error. Downgrade to 4.38.1 will help you solve this problem. Be sure to downgrade both FBSDKCoreKit and FBSDKLoginKit.

pod 'FBSDKCoreKit', '~> 4.38.0' pod 'FBSDKLoginKit', '~> 4.38.0' 

Be sure to clean the build folder and re-build the SDK.

update: This bug has been fixed in 4.39.1 SDK release. https://developers.facebook.com/docs/ios/change-log-4x/

like image 56
David Liu Avatar answered Sep 23 '22 02:09

David Liu


This is a Facebook SDK bug in version 4.39.0 which is causing this error. In order to solve this bug, simply downgrade both CoreKit and LoginKit to 4.38.0, clear derived data as well as clean build folder (CMD + OPTION + SHIFT + K). Whereas 4.38.1 also works fine.

pod 'FBSDKCoreKit', '~> 4.38.0' pod 'FBSDKLoginKit', '~> 4.38.0' 

If you are using FacebookCore and FacebookLogin then do like the following.

pod 'FacebookCore' pod 'FacebookLogin' pod 'FBSDKCoreKit', '~> 4.38.0' pod 'FBSDKLoginKit', '~> 4.38.0' 
like image 37
shanezzar Avatar answered Sep 25 '22 02:09

shanezzar


For me, the problem was that the Facebook App ID indicated in CFBundleURLTypes > CFBundleURLSchemes in Info.plist were spelled out incorrectly.

I was importing the app ID from an .xcconfig file so that its underlying value changes depending on whether I'm running a Debug or Release scheme. However, when I printed out the plist file, there were unnecessary quotation marks around the app ID when read from the xcconfig files. For example, where the URL scheme should be fb012345678, it was fb"012345678".

I tried hardcoding the app IDs correctly into the Info.plist as stated in the Facebook guide, and the FBSDKLoginButton just worked. Safari came up to display the Facebook login screen. You don't have to hardcode the IDs though--just make sure they are substituted correctly in Info.plist.

like image 31
MLQ Avatar answered Sep 24 '22 02:09

MLQ