iOS (Swift) - Facebook SDK login error

Hello. I have implemented Facebook SDK login, i followed the instructions carefully. The app shows safari view controller, asks for user to login, after successful login, asks for app permissions, and once the user clicks on OK, it crashes on line 26 or 27 with message
[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[2]’

Here’s the complete code of the delegate method in AppDelegate

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        backendless = Backendless.sharedInstance()
        //for twitter
        let tresultuser = backendless?.userService.handleOpen(url as URL!)
        if tresultuser != nil {
            return true
        let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String
        let fbresult = FBSDKApplicationDelegate.sharedInstance().application(app, open: url, sourceApplication: sourceApplication, annotation: nil)
        let gresult = GIDSignIn.sharedInstance().handle(url, sourceApplication: sourceApplication, annotation: nil)
        if fbresult {
            let token = FBSDKAccessToken.current()
            let fieldsMapping = [
                "name" : "name",
                "email": "email"
            backendless?.userService.login( withFacebookSDK: token, fieldsMapping: fieldsMapping,
                response: { (user) -> Void in
                    print("user: \(user)")
                error: { (fault) -> Void in
                    print("Server reported an error: \(fault)")
        return gresult || fbresult

Hi Zeba,

I see you get a user object back on line 26. Have you verified in debugger what that object contains?


Hi Mark, the app crashes before printing that line.

What version of the SDK do you use?
Is the app on the 3.x or the 4.0 backend?

Its 3.x

And the version of the SDK?

It must be latest. I’ve just written pod ‘Backendless’ in podfile

Just so we have the same environment when reproducing the error, could you run “pod list” from a command line and let us know the version?

Also, is it the latest version of the Facebook SDK?

Finally, is the user object created in the Users table? Does it have both “email” and name" properties?

Okay Mark, here it is

my podfile just has these

pod ‘Backendless’
pod ‘FBSDKCoreKit’
pod ‘FBSDKLoginKit’
pod ‘FBSDKShareKit’
but pod list shows these
Backendless 4.0b3
Backendless-Light 3.0.44
Backendless-bis 3.0.44
Backendless-ios-SDK 3.0.44
Backendless-osx-SDK 3.0.43

Facebook-PromiseKit 0.1.0
Facebook-iOS-SDK 4.1.0
FacebookCore 0.2.0
FacebookImagePicker 2.0.11
FacebookLogin 0.2.0
FacebookManager 0.0.1
FacebookPicture 0.0.1
FacebookPopover 0.1.1
FacebookShare 0.2.0

It looks like the app uses the 4.0 library, but works with the 3.x backend. Could you check if the initApp call takes two (4.0) or three (3.x) arguments?

ohhh. It takes 3 arguments: app id, secret, and version number

how do i specify 3.x library in podfile? i could update that and see if it works

Try this:

pod ‘Backendless’, ‘~> 3.0’

Using Backendless (3.0.44)

I see there is a build 3.0.46, which has not been published to Cocoapods (it will hide the 4.0 build). Could you grab the library from the link below and see if the problem goes away?

Someone from the team corrected me saying that both 3.045 and 3.0.46 should be in Cocoapods. Could you try running “pod update” from the root directory of the project (the one where podspec file is at) and see if it updates it to the latest one?

Hi Mark! I just updated to backendless 3.0.46 via cocoapods.

Its throwing the same error

Thanks for verifying. Is the user created in the Users table? Are there values for name and email?

Yes Mark - the user was registered earlier as beckendless user. The app allows social login only for users registered as accounts previously.
And it was working fine when i was using easy facebook login. i had to switch to using SDK because easy login was launching out to safari app which apple doesnt accept - i needed SVC and i was told to use fbSDK for it.