Hi everyone, 

Nowadays peoples are so lazy and they want all the things available on there to figure tips this also applies when people log in to any application web or Mobile. Generallythe user doesn’t want to fill out the registration form. So, they just want to use there existing information on social networking sites.
 
Here I am going to discuss how to implement “Login with Facebook” in an iOS application with swift. When the user wants to log in with Facebook into your app, they should have to give you permission to retrieve their information. To implement the Facebook login in your app you should follow the steps described below:-
Step : 1=> Please make an account on Facebook to create your app and register yourself as a developer. 

Step:2=> Import the Fb Framework SDK in your app. You can import the Fb SDK in two method :-

  1. Using  Cocaopods
  2. Manually you can import the SDK into your project with this link. (https://developers.facebook.com/docs/facebook-login/ios/?sdk=fbsdk)

Using Cocapods:-


  1.  Navigate to your project folder in a terminal window.
  2.  You have to follow the steps to install the Facebook SDK in your project. Before installing with Cocoapods please ensure you have to install cocoa pods in your system. 

Mannually:- 


  1. Download the SDK and unzip the archive to a downloaded file.
  2. Add Login kit to your project. Follow the below steps:-
    1. Open your application’s Xcode project.
    2. If you don’t have a Frameworks group in your project, create one by right-clicking on your project in Xcode’s Project Navigator and selecting New Group.
    3. Open the unzipped SDK folder.
    4. Drag the BoltsFBSDKCoreKit, FBSDKLoginKit files into your project’s Frameworks group.
    5. In the dialog appeared, select keep the “Copy items if needed” option selected, and click finish.

Step:-3==> Register and configure your app with Facebook.

  • Add your bundle identifier
  • Enable single Sign-on for your app.

After “step 3″ successfully implementation you will get a Facebook app ID.

Step:4 => Configure your info.plist.

  • Right-click on the info.plist file, and choose Open As Source Code
  • Copy and paste the following code into the body of your file (…).
  • To use any of the Facebook dialogs (e.g., Login, Share, App Invites, etc.) that can perform an app switch to the Facebook app, your application also needs to include the following into info.plist:

Step:5=> Connect your app delegate

Add the following code to your app delegate class. This initializes the SDK when your app launches and lets the SDK handle results from the native Facebook app when you perform a login or share action.

Step:6=> Add the following code where you want to retrive the user detail.

Hurray, You have successfully implemented the Facebook login to your app. If you have any queries, then please ask in the comment. 

Thank you, Good Day 🙂