How to import FacebookSDK in Header file of Swift iOS application
I am converting my application from Objective- C to swift . In my swift application I have created a header file as explained in following tutorial , but i am getting error ‘FacebookSDK/FacebookSDK.h’ file not found rather than I imported facebookSDK successfully in my application . Please guid me how to import facebookSDK in swift.
- An error was encountered while running (Domain = LaunchServicesError, Code = 0)
- Swift - Change view controller using action button
- Error compiling storyboard files using Xcode 6 beta 5
- Linking View Controllers through button
- Segue - index 0 beyond bounds for empty array
- Unable to run app in Simulator : An error was encountered while running (Domain = LaunchServicesError, Code = 0)
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:
- Create a Swift project
- File > New > Cocoa Touch Class > Language Objective-C > Create
- Xcode asks you to create a bridging header, let Xcode create that header
- Do the steps in: http://www.brianjcoleman.com/tutorial-facebook-login-in-swift/
#import <FacebookSDK/FacebookSDK.h>to the Xcode generated bridging header.
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 🙂
- How to tell if an iOS application has been newly installed or updated?
- Does bundle id need to be case sensitive?
- Facebook SDK for iOS: FBSDKShareDialog is not shown
- Accessing Google APIs from iPhone native app
- How to transfer “data” between two device (android,iphone)?
- Set starting point of content size for UIScrollView
- Streaming video over HTTP in IOS
- Use AppDelegate in today extension
- How to determine the correct altitude for an MKMapCamera focusing on an MKPolygon
- Why is asynchronous network testing difficult in Objective-C/Swift?
- iOS 6 debug console gone?
- How to loop audio while merging audio and video
- How to dismiss number pad keyboard by tapping anywhere
- iOS Keyboard Active but Invisible when UISearchBar is tapped
- Swift: How to set a default Value of a UIPickerView with three components in Swift?