Search code examples
angularfacebookcordovaionic-frameworkionic4

'FBSDKCoreKit/FBSDKCoreKit.h' file not found with Cordova & Ionic 4


I am trying to integrate a login with Facebook into my application but this error has me desperate. I have tried all the solutions that are proposed in other discussions but for the moment I could not solve it. My versions are as follows:

cordova --version 9.0.0 (cordova-lib@9.0.1)
ionic --version 5.4.15
cordova-ios: 5.1.1
@ionic/angular: 4.11.10

App.module.ts

import { Facebook } from '@ionic-native/facebook/ngx';

....

providers: [
    Facebook,
.....
]
.....

login.page.ts

import { Facebook, FacebookLoginResponse } from '@ionic-native/facebook/ngx';

constructor( private fb: Facebook)  { }

async loginFacebook( ) {
    this.fb.login(['public_profile', 'email']).then(async (res: FacebookLoginResponse) => {
      console.log('Logged into Facebook!', res);
    }).catch(err => {
      console.error(err);
    });
  }

When I execute the following command I get the error:

ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0"

/Users/PedroMadrigal/Desktop/escondite/platforms/ios/Escondite/Plugins/cordova-plugin-facebook4/FacebookConnectPlugin.h:13:9: fatal error: 'FBSDKCoreKit/FBSDKCoreKit.h' file not found

import FBSDKCoreKit/FBSDKCoreKit.h

1 error generated.

** BUILD FAILED **


Solution

  • The following versions work well for me:

    • "@ionic-native/facebook": "^5.15.1"
    • "cordova-plugin-facebook4": "^6.2.0"

    If you are using different versions in your app, try using these versions. First, remove the current plugin by running the following commands:

    ionic cordova plugin rm cordova-plugin-facebook
    
    npm uninstall --save @ionic-native/facebook
    

    Then, reinstall the plugin with the stated versions using:

    ionic cordova plugin add cordova-plugin-facebook4@6.2.0 --variable APP_ID="123456789" --variable APP_NAME="your app"
    
    npm install --save @ionic-native/facebook@5.15.1