How to import FacebookSDK in Header file of Swift iOS application - ios

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.

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/
Add #import <FacebookSDK/FacebookSDK.h> to the Xcode generated bridging header.
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 :)

Related

Unable to import spotify ios sdk Obj-C file in Xcode

I imported the Spotify SDK,
I put the name of the bridging file in the bridging header in the project build settings
The Obj-C compaitibilty header is enabled at TARGET level
I have tried using and "Spotify" on the imports in the bridging file
My bridging file is in the root director
Anyone have a guess as to what I am doing wrong?
I want to import this file so I can get back to developing. Maybe there is a setting somewhere I am missing?
As per the Spotify documentation, you should be using
#import <SpotifyiOS/SpotifyiOS.h>
in your bridging header.
Just go through the Spotify documentation once again, validate everything is as it should be and see if that helps.

Applying Facebook Login to iOS app in Swift

I need to copy said code
#import <FBSDKCoreKit/FBSDKCoreKit.h>
into my app delegate.m file as per Facebook's instructions.
However, I am using Swift not Objective-C and do I don't have .h and .m files for my app delegate (or anything else for that matter), is there any other way in which to import this into my app delegate.swift file?
No need to do that.
Drag the corresponding FBSDKCoreKit framework file in your Xcode project, then just do
import FBSDKCoreKit
in the Swift files.
No need for anything else.
The way you were referring to was for previous versions of the non-Swift SDK.
Reference: https://developers.facebook.com/docs/ios/getting-started/advanced#swift

Firebase bridging header not working

I'm building a Firebase app in swift, I installed the cocoa pod correctly then created an Objective-C file so it would make me a bridging header. When I try to import Firebase elsewhere in the app it says no such module found. I tried to build anyway because sometimes the error will go away but it failed.
Should I do something with my build settings? I've created bridging headers before and never had too (I thought Xcode did that automatically). I'm using version 7.2.1 (the latest) by the way.
Thanks for the help!
#ifndef FirebaseNetwork_Bridging_Header_h
#define FirebaseNetwork_Bridging_Header_h
#import <Firebase/Firebase.h>
#endif
The documentation from firebase says to use import Firebase when in swift. This however causes errors at compile time. After adding the bridging header and importing Firebase.h inside of it, you will be able to access the Firebase api in your swift files.
Make sure to insert the following line in your Podfile:
use_frameworks!
Then open the .xcworkspace file. Clean the build. Compile it.

iOS / WatchKit: Is there a way for the watch kit app(swift) to use the iOS code (Objective C)?

I thought about using a bridging header, but I keep getting fail to import bridging header. Is it possible for watch extension (written in swift) to use code from the iOS App (written in Objective C)? I need to make sure I am doing this correctly and professionally. If I can use bridging header, why am I getting the following error?
:0: error: failed to import bridging header
It might something as simple as a path problem. But what I normally do is create a dummy Objective-C file so that Xcode will create that bridging header for me, then I just copy and paste the path into the extension's build settings.
I've included a demo project which calls a method from an Objective-C file that is imported in the bridging header. I've also had to add the file in the extension's build phases for it to work. I hope this is what you're looking to solve.
https://dl.dropboxusercontent.com/u/5296996/WKTest.zip

Use of unresolved identifier PFFacebookUtils

I've done all is mentioned here (https://www.parse.com/docs/ios_guide#fbusers/iOS) for implement in iOS the Facebook Login.
The problem is that i have an compile error "Use of unresolved identifier PFFacebookUtils"
near che line
PFFacebookUtils.initializeFacebook()
in AppDelegate. I've correctly imported the Parse and Facebook Framework into my project.
Are there some bug knowed in Xcode 6 Beta?
Parse docs doesn't mention this yet: After downloading the Parse iOS SDK, You should include the ParseFacebookUtils.framework into your project, then import it in each file you want to use it, like you did for the Parse.framework itself:
#import <Parse/Parse.h>// This use to be enough to use Facebook utilities
#import <ParseFacebookUtils/PFFacebookUtils.h>// But now we should import this framework as well to use Facebook utilitis
Parse team has separated the Facebook related classes from Parse API, hence a ParseFacebookUtils.framework
You may need to
import ParseFacebookUtils
in your AppDelegate
If you want to use PFFacebookUtils or/and PFLogInViewController with swift, you have to do this:
For not V4 version:
#import <ParseFacebookUtils/PFFacebookUtils.h>in bridging header and then import ParseFacebookUtils in swift file. And call PFFacebookUtils.initializeFacebook() somewhere, of course best place for this is application didFinishLaunchingWithOptions.
For V4 version:
#import <ParseFacebookUtilsV4/PFFacebookUtils.h> in bridging header and import ParseFacebookUtilsV4 in swift file. And call PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions) in application didFinishLaunchingWithOptions.
Of course you should have set your bridging header correctly and import frameworks.
Resolved! #import in bridging header
After the update to Parse/FacebookUtils, to import you do #import <Parse/PFFacebookUtils.h>

Resources