How to import FacebookSDK into Swift iOS app header file

I am converting my application from Objective-C to swift. In my swift app, I created a header file as described in the following tutorial , but I am getting the error 'FacebookSDK / FacebookSDK.h' file not found , rather than importing facebookSDK in my app. Please introduce me how to import facebookSDK quickly.

+3


source to share


3 answers


Facebook supports the fast option with SDK v4.1, so no bridge headers are required . (by the way, they are also deprecated FacebookSDK

in favor of FBSDKCoreKit

this version)

Just import the module you need:



import FBSDKCoreKit
import FBSDKShareKit
import FBSDKLoginKit

      

+9


source


Here's an easy way to get it right:



  • Create a Swift project
  • File> New> Cocoa Touch Class> Objective-C Language> New
  • Xcode will ask you to create a bridge header, let Xcode create this header
  • Follow these steps: http://www.brianjcoleman.com/tutorial-facebook-login-in-swift/
  • Add #import <FacebookSDK/FacebookSDK.h>

    to the bridge header generated by Xcode.
  • Build
+1


source


You need to add it to your target build settings:

1. In Xcode, if you go to the build settings for your target and scroll all the way down you will find the "Swift Compiler - Code Generation" section.

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

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

This worked for me. Hope will work for you too :)

0


source







All Articles