22

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
halfer
  • 19,824
  • 17
  • 99
  • 186
Muhammad Sadiq Alvi
  • 1,099
  • 1
  • 13
  • 23

6 Answers6

64

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/

David Liu
  • 952
  • 7
  • 15
7

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'
shanezzar
  • 1,031
  • 13
  • 17
2

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.

Matthew Quiros
  • 13,385
  • 12
  • 87
  • 132
1

In terminal & Navigate to the project folder use

pod update

to update to current version 4.39.1

Community
  • 1
  • 1
Ionz
  • 97
  • 1
  • 4
0

I was following the react-native-fbsdk instructions in which you are supposed to copy Framework files/folders into the project. Thus, the Cocoapod approach given above didn't work for me.

What I did is remove the existing Framework files from the project (Right-click on Framework items -> Delete -> Yes Remove all), and then add the previous versions of the Frameworks again by downloading them from:

https://developers.facebook.com/docs/ios/downloads/

Darko Maksimovic
  • 1,155
  • 12
  • 14
0

I had to do two things to get this working.

1. Downgrade pods to

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

2. Remove -ObjC from other linker flags

Although this has been suggested in facebook developer portal. This was generating the below error:

com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Unknown error building URL.

Hope this helps.

shakil080
  • 351
  • 2
  • 5