How to import FacebookSDK in Header file of Swift iOS application

3 Solutions Collect From Internet About “How to import FacebookSDK in Header file of Swift iOS application”

Facebook supports swift natively as of SDK v4.1, so bridging headers are not required now. (by the way, they also deprecated FacebookSDK in favor of FBSDKCoreKit since this version)

Just import the module you need directly:

import FBSDKCoreKit
import FBSDKShareKit
import FBSDKLoginKit

Here is a simple way to do it right:

  1. Create a Swift project
  2. File > New > Cocoa Touch Class > Language Objective-C > Create
  3. Xcode asks you to create a bridging header, let Xcode create that header
  4. Do the steps in: http://www.brianjcoleman.com/tutorial-facebook-login-in-swift/
  5. Add #import <FacebookSDK/FacebookSDK.h> to the Xcode generated bridging header.
  6. Build

You need to add it to your target’s build settings:

1.In Xcode, if you go into the build settings for your target, and scroll all the way down you’ll find a “Swift Compiler – Code Generation” section.

2.Set “Objective-C Bridging Header” to <#PROJECT_NAME>Bridging-Header.h

3.Now create a Bridging-Header.h file.Import FacebookSDK/FacebookSDK.h to Bridging-Header.h.

This worked for me.Hope will work for u too 🙂