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.
source to share
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
source to share
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 :)
source to share