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

允我心安 提交于 2019-12-21 03:15:16

问题


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

回答1:


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/




回答2:


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'



回答3:


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.




回答4:


In terminal & Navigate to the project folder use

pod update

to update to current version 4.39.1




回答5:


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/




回答6:


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.



来源:https://stackoverflow.com/questions/35248412/ios-facebook-login-error-unknown-error-building-url-com-facebook-sdk-core-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!